@snap/camera-kit
Version:
Camera Kit Web
39 lines • 780 B
JavaScript
export class OkResult {
constructor(value) {
this.value = value;
this.ok = true;
}
unwrap() {
return this.value;
}
unwrapErr() {
throw new Error("Ok Result cannot unwrapErr.");
}
map(m) {
return new OkResult(m(this.value));
}
flatMap(m) {
return m(this.value);
}
}
export const Ok = (value) => new OkResult(value);
export class ErrResult {
constructor(value) {
this.value = value;
this.ok = false;
}
unwrap() {
throw this.value;
}
unwrapErr() {
return this.value;
}
map() {
return this;
}
flatMap() {
return this;
}
}
export const Err = (value) => new ErrResult(value);
//# sourceMappingURL=result.js.map