promise-throttle - v2.1.0
    Preparing search index...

    Class PromiseThrottle

    Limits the amount of functions returning promises that are called per second.

    const throttle = new PromiseThrottle({ requestsPerSecond: 2 });

    const response = await throttle.add(() => fetch('https://example.com/a'));
    console.log(response.status);
    Index
    • Queues a function, which is called when the throttling allows it.

      Type Parameters

      • T

      Parameters

      Returns Promise<T>

      A promise resolved or rejected with the result of the function. If the function throws, the promise is rejected with the thrown error.

    • Queues several functions with the same options.

      Type Parameters

      • T

      Parameters

      Returns Promise<T[]>

      A promise resolved with the results of all the functions, in the same order, or rejected with the first error.