MCPcopy Create free account
hub / github.com/denoland/std / disposableStack

Function disposableStack

internal/_testing.ts:5–20  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3// partial `DisposableStack` polyfill
4// https://github.com/tc39/proposal-explicit-resource-management
5export function disposableStack() {
6 return {
7 disposables: [] as Disposable[],
8 defer(fn: () => void) {
9 this.disposables.push({ [Symbol.dispose]: fn });
10 },
11 use(val: Disposable) {
12 this.disposables.push(val);
13 },
14 [Symbol.dispose]() {
15 for (let i = this.disposables.length - 1; i >= 0; --i) {
16 this.disposables[i]![Symbol.dispose]();
17 }
18 },
19 };
20}

Callers 5

mockLittleEndianFunction · 0.90
format_test.tsFile · 0.90
_os_test.tsFile · 0.90
is_glob_test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected