UNPKG

defer-close

Version:

A lightweight utility for adding JavaScript's Disposable and AsyncDisposable interfaces to any object

16 lines (15 loc) 241 B
// index.ts function deferClose(obj, fn) { const r = Object.assign(obj, { [Symbol.dispose]() { fn(obj); }, async[Symbol.asyncDispose]() { await fn(obj); } }); return r; } export { deferClose as default };