Skip to content

isAsyncDisposable

function isAsyncDisposable(value): value is AsyncDisposable;

Defined in: is-disposable.ts:16

Check if a value has a Symbol.asyncDispose method (async disposable), i.e. whether it can be bound with await using.

Only objects pass: a function carrying the symbol returns false.

Parameter Type
value unknown

value is AsyncDisposable

import { defer, deferSync, isAsyncDisposable } from "@xtandard/lib";
isAsyncDisposable(defer(() => {})); // true
isAsyncDisposable(deferSync(() => {})); // false (sync only)
isAsyncDisposable({ [Symbol.asyncDispose]: async () => {} }); // true