Skip to content

isSyncDisposable

function isSyncDisposable(value): value is Disposable;

Defined in: is-disposable.ts:37

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

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

Parameter Type
value unknown

value is Disposable

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