nsuite - v1.0.1
    Preparing search index...

    Function withTimeout

    • Wraps a promise with a timeout. If the promise does not resolve or reject within the specified time, it will be rejected with a ${TIMEOUT_ERROR_MESSAGE} error.

      Type Parameters

      • T

      Parameters

      • promise: Promise<T>

        The promise to wrap with a timeout.

      • OptionaltimeoutMs: number = DEFAULT_PROMISE_TIME_OUT

        The timeout duration in milliseconds.

      Returns Promise<T>

      • A new promise that either resolves with the original promise's value or rejects with a timeout error if the timeout duration is exceeded.
      import { withTimeout } from "nsuite";
      const newPromise = withTimeout(promise, 3000);