@vgerbot/async
    Preparing search index...

    Class RateLimitExecutor

    A task executor that limits the rate of task execution. Enforces a maximum number of requests per time window using a sliding window algorithm.

    // Allow max 10 requests per second
    const executor = new RateLimitExecutor(10, 1000);

    for (let i = 0; i < 20; i++) {
    executor.exec(async (token) => {
    console.log(`Request ${i}`);
    return i;
    });
    }
    // First 10 execute immediately, next 10 wait for the window to reset

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Checks if the executor is shut down and throws ExecutorShutdownError if so. Subclasses should call this at the start of exec().

      Parameters

      • message: string = "Executor permanently shut down"

        Optional custom error message

      Returns void

      if the executor is shut down