@benev/slate
Version:
frontend web stuff
19 lines • 418 B
JavaScript
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