UNPKG

@benev/slate

Version:
19 lines 418 B
export class Trashbin { #fns = []; disposer = (fn) => { this.#fns.push(fn); }; disposable = (x) => { return this.bag(x, () => x.dispose()); }; bag = (x, fn) => { this.disposer(() => fn(x)); return x; }; dispose = () => { for (const fn of this.#fns.reverse()) fn(); this.#fns = []; }; } //# sourceMappingURL=trashbin.js.map