Skip to Content
GuardisPromise

isPromise

Check whether the given value is Promise

Import

import { isPromise } from '@fullstacksjs/toolbox';

Signature

function isPromise(x: unknown): x is Promise<unknown> {};

Examples

isPromise(null) // false isPromise(undefined) // false isPromise(42) // false isPromise('then') // false isPromise(true) // false isPromise({}) // false isPromise([]) // false isPromise([true]) // false isPromise(() => {}) // false isPromise({ then: true }) // false isPromise({ then: fn }) // true
Last updated on