-
-
Notifications
You must be signed in to change notification settings - Fork 0
promise like
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isPromiseLike<T>(it: unknown): it is PromiseLike<T>;Check if the given value is a PromiseLike type, which includes both native
Promise instances and custom promise-like objects with a .then method
(sometimes referred to as "thenables").
| Name | Info |
|---|---|
it |
The value to check. |
true if the value is a PromiseLike, false otherwise.
Async/Await
import { isPromiseLike } from "jsr:@nick/is/promise-like";
console.log(isPromiseLike(Promise.resolve())); // true
console.log(isPromiseLike({ then: () => {} })); // true
console.log(isPromiseLike({})); // false