UNPKG

@hazae41/box

Version:

Rust-like Box and similar objects for TypeScript

36 lines (33 loc) 626 B
'use strict'; /** * 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; } } exports.Cell = Cell; //# sourceMappingURL=index.cjs.map