jty
    Preparing search index...

    Function isPromiseLike

    • Checks if a value is Promise-like (thenable).

      Returns true for native Promise instances and for values that expose a callable .then method. This is useful when you do not care whether the value is literally a Promise instance and only need awaitable behavior.

      Parameters

      • x: unknown

      Returns x is PromiseLike<unknown>

      This function does not care if there is a .catch method or not. Only presence of .then is sufficient to be considered Promise-like.

      isPromiseLike(Promise.resolve(123)) => true
      isPromiseLike({ then: () => {} }) => true
      isPromiseLike(() => {}) => false
      isPromiseLike({ then: true }) => false