Function isPromise

  • Determines if an element is a Promise object.

    Remarks

    Function used to check if an element is a Promise<U> object by validating that it is an object that contains a thenable function and is an instance of Promise.

    Example

    isPromise(1) // false
    isPromise(Promise.resolve(1)) // true
    isPromise({ then: () => {} }) // false
    isPromise({ then: 1 }) // false

    Returns

    true if element is a Promise<U> object

    Type Parameters

    • U

    Parameters

    • Optional element: U | Promise<U>

      element of type U or Promise<U> to validate as a Promise

    Returns element is Promise<U>

Generated using TypeDoc v0.23.24