class Maybe extends Inspectable {
$value;
constructor(x) {
super();
this.$value = x;
}
static of(x) {
return new Maybe(x);
}
isNothing() {
return this.$value === null || this.$value === undefined;
}
map(fn) {
return this.isNothing() ? this : Maybe.of(fn(this.$value));
}
valueToString() {
return this.isNothing() ? 'Nothing' : `Just ${this.$value}`
}
}