| number | const a = Math.random() * 1e3;
const b = Math.random() * 1e3;
const c = a + b;
| ready |
| boxed | class Instant {
#n;
constructor(n) {
this.#n = n;
}
valueOf() {
return this.#n;
}
plus(other) {
return new Instant(this.valueOf() + other.valueOf());
}
}
class Duration {
#n;
constructor(n) {
this.#n = n;
}
valueOf() {
return this.#n;
}
}
const a = new Instant(Math.random() * 1e3);
const b = new Duration(Math.random() * 1e3);
const c = a.plus(b);
| ready |
| branded | const Time = {
Duration: {
fromMillis: (millis) => millis
},
Milliseconds: {
of: (value) => value
},
StreamTime: {
fromMillis: (millis) => millis,
addDuration: (time, duration) => {
return (time + duration);
}
}
};
const a = Time.StreamTime.fromMillis(Time.Milliseconds.of(Math.random() * 1e3));
const b = Time.Duration.fromMillis(Time.Milliseconds.of(Math.random() * 1e3));
const c = Time.StreamTime.addDuration(a, b);
| ready |
| branded: arithmetic + no rewrap | const Time = {
Duration: {
fromMillis: (millis) => millis
},
Milliseconds: {
of: (value) => value
},
StreamTime: {
fromMillis: (millis) => millis,
addDuration: (time, duration) => {
return (time + duration);
}
}
};
const a = Time.StreamTime.fromMillis(Time.Milliseconds.of(Math.random() * 1e3));
const b = Time.Duration.fromMillis(Time.Milliseconds.of(Math.random() * 1e3));
const c = Time.StreamTime.fromMillis(a + b);
| ready |
| branded: arithmetic + rewrap | const Time = {
Duration: {
fromMillis: (millis) => millis
},
Milliseconds: {
of: (value) => value
},
StreamTime: {
fromMillis: (millis) => millis,
addDuration: (time, duration) => {
return (time + duration);
}
}
};
const a = Time.StreamTime.fromMillis(Time.Milliseconds.of(Math.random() * 1e3));
const b = Time.Duration.fromMillis(Time.Milliseconds.of(Math.random() * 1e3));
const c = a + b;
| ready |
| branded w/o millis | const Time = {
Duration: {
of: (value) => value
},
StreamTime: {
of: (value) => value
}
};
const a = Time.StreamTime.of(Math.random() * 1e3);
const b = Time.Duration.of(Math.random() * 1e3);
const c = a + b;
| ready |