AsyncDisposableStack() constructor

The AsyncDisposableStack() constructor creates AsyncDisposableStack objects.

Syntax

js
new AsyncDisposableStack()

Note: AsyncDisposableStack() can only be constructed with new. Attempting to call it without new throws a TypeError.

Parameters

None.

Return value

A new AsyncDisposableStack object.

Examples

undefined

Creating an AsyncDisposableStack

js
const disposer = new AsyncDisposableStack();
disposer.defer(() => console.log("Disposed!"));
await disposer.disposeAsync();
// Logs: Disposed!

Specifications

See also