• Get an async iterable that yields on an interval until aborted.

    Parameters

    • ms: number

      The amount of time to wait between intervals, in milliseconds

    • Optionaloptions: Options

      The options for the timer

    Returns AsyncGenerator<undefined, void, unknown>

    An async iterable that yields on each intervals

    let controller = new AbortController();
    for await (let _ of interval(1000, { signal: controller.signal })) {
    // Do something every second until aborted
    }