UNPKG

@benev/slate

Version:
23 lines (17 loc) 365 B
/** @deprecated use `Trashbin` instead */ export class Trashcan { #can: (() => void)[] = [] bag = <T>(item: T) => ({ dump: (destroy: (item: T) => void) => { this.#can.push(() => destroy(item)) return item } }) mark = (fn: () => void) => { this.#can.push(fn) } dispose = () => { this.#can.forEach(destroy => destroy()) this.#can = [] } }