Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 1x 1x 16x 16x | import { isFunction } from "@benneq/function";
import { isObject } from "@benneq/object";
/**
* Checks if a `value` is a {@link PromiseLike} object.
*
* @example
* Returns `true` if the value is a {@link PromiseLike} object
* ```ts
* const value = new Promise(() => {});
* const result = isPromiseLike(value);
* console.log(result); // true
* ```
*
* @typeParam T - the {@link PromisLike} value type
* @param value - the value to check
* @returns `true` if `value` is a {@link PromiseLike} object, otherwise `false`
*/
export const isPromiseLike = <T>(value: unknown): value is PromiseLike<T> => {
return isObject(value) && isFunction(value["then"]);
};
|