@hazae41/box
Version:
Rust-like Box and similar objects for TypeScript
37 lines (35 loc) • 685 B
JavaScript
class Deferred {
value;
constructor(value) {
this.value = value;
}
static void() {
return new Deferred(() => { });
}
[Symbol.dispose]() {
this.value();
}
async [Symbol.asyncDispose]() {
this[Symbol.dispose]();
}
get() {
return this.value;
}
}
class AsyncDeferred {
value;
constructor(value) {
this.value = value;
}
static void() {
return new AsyncDeferred(async () => { });
}
async [Symbol.asyncDispose]() {
await this.value();
}
get() {
return this.value;
}
}
export { AsyncDeferred, Deferred };
//# sourceMappingURL=index.mjs.map