UNPKG

@barchart/common-js

Version:
26 lines (25 loc) 899 B
/** * A work queue that restricts the rate at which items are * processed. * * @public * @extends {Disposable} */ export default class RateLimiter extends Disposable { /** * @param {number} windowMaximumCount - The maximum number of items which can be processed during a timeframe (positive integer). * @param {number} windowDurationMilliseconds - The number of milliseconds in the timeframe (positive integer). */ constructor(windowMaximumCount: number, windowDurationMilliseconds: number); /** * Adds an item to the work queue and returns a promise that will * resolve after the item completes execution. * * @public * @param {Function} actionToEnqueue - The action to execute. * @returns {Promise} */ public enqueue(actionToEnqueue: Function): Promise<any>; #private; } import Disposable from './../lang/Disposable.js';