You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
523 B
14 lines
523 B
import { __assign } from "tslib"; |
|
/** @internal */ |
|
export function withCleanup(item, cleanup) { |
|
var _a; |
|
return __assign(__assign({}, item), (_a = {}, _a[Symbol.dispose] = function () { |
|
cleanup(item); |
|
// if `item` already has a cleanup function, we also need to call the original cleanup function |
|
// (e.g. if something is wrapped in `withCleanup` twice) |
|
if (Symbol.dispose in item) { |
|
item[Symbol.dispose](); |
|
} |
|
}, _a)); |
|
} |
|
//# sourceMappingURL=withCleanup.js.map
|