UNPKG

@hazae41/box

Version:

Rust-like Box and similar objects for TypeScript

34 lines (32 loc) 607 B
/** * An interior mutable reference */ class Cell { value; /** * A mutable reference * @param value */ constructor(value) { this.value = value; } [Symbol.dispose]() { this.value[Symbol.dispose](); } async [Symbol.asyncDispose]() { await this.value[Symbol.asyncDispose](); } get() { return this.value; } set(value) { this.value = value; } getAndSet(value) { const old = this.value; this.value = value; return old; } } export { Cell }; //# sourceMappingURL=index.mjs.map