Function resolveAfter

  • Returns a promise that resolves with the specified value after a given delay.

    Returns

    A Promise that resolves to value after ms milliseconds.

    Example

    await resolveAfter(1000, 'hello'); // resolves with 'hello' after 1 second
    await resolveAfter(500); // resolves with undefined after 0.5 seconds

    Remarks

    • Useful for simulating delays or asynchronous timing in tests or animations.
    • The function does not reject; it always resolves after the specified timeout.

    Type Parameters

    • T

      The type of the value to resolve.

    Parameters

    • ms: number

      The delay in milliseconds before the promise resolves.

    • Optional value: T

      Optional value to resolve the promise with (defaults to undefined if not provided).

    Returns Promise<T | undefined>

Generated using TypeDoc