Promise

Utility functions for promise

Description:
  • Utility functions for promise

Source:

Methods

(static) withTimeout(promise, timeoutMsopt) → {Promise.<T>}

Description:
  • 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.

Source:
Example
import { withTimeout } from "nsuite";
const newPromise = withTimeout(promise, 3000);
Parameters:
Name Type Attributes Default Description
promise Promise.<T>

The promise to wrap with a timeout.

timeoutMs number <optional>
3000

The timeout duration in milliseconds.

Returns:
  • A new promise that either resolves with the original promise's value or rejects with a timeout error if the timeout duration is exceeded.
Type
Promise.<T>