-
-
Notifications
You must be signed in to change notification settings - Fork 0
disposable
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isDisposable(it: unknown): it is Disposable;Checks if a value is an object that implements the Disposable API.
| Name | Info |
|---|---|
it |
The value to check. |
true if the value is an object that implements the Disposable API, or
false otherwise.
Explicit Resource Management
import { isDisposable } from "@nick/is/disposable";
const disposable = {
[Symbol.dispose]() {
return;
},
};
const asyncDisposable = {
async [Symbol.asyncDispose]() {
await Promise.resolve();
},
};
isDisposable(disposable); // true
isDisposable(asyncDisposable); // falseAn object that can have its resources explicitly released when it is no longer
needed. Objects that implement this interface can be used with the using and
await using statements, which automatically dispose of their resources when
they are no longer needed.
Explicit Resource Management
SymbolDispose(): void;Releases the resources held by this object.