Function timeoutReject

  • Creates a promise that is rejected after the given amount of time. A typical use case is to wait for another promise until a specified timeout using:

    Promise.race([ promiseToPerform, timeoutReject(timeout, 'Timeout error message') ]);
    

    Type Parameters

    • T

    Parameters

    • ms: number

      timeout in milliseconds

    • Optional message: string

      error message on promise rejection

    Returns Promise<T>

    rejection promise