timing/RateLimiter.js
/**
		 * Adds an item to the work queue and returns a promise that will
		 * resolve after the item completes execution.
		 *
		 * @param {Function} actionToEnqueue - The action to execute.
		 * @returns {Promise}
		 */
Adds an item to the work queue and returns a promise that will
resolve after the item completes execution.

@param {Function} actionToEnqueue - The action to execute.
@returns {Promise}
Adds an item to the work queue and returns a promise that will resolve after the item completes execution . @param { Function } actionToEnqueue - The action to execute . @returns { Promise }
enqueue(actionToEnqueue) {
			return promise.build((resolveCallback, rejectCallback) => {
				assert.argumentIsRequired(actionToEnqueue, 'actionToEnqueue', Function);
				if (this.getIsDisposed()) {
					throw new Error('Unable to enqueue action, the rate limiter has been disposed.');
				}
				this._workQueue.enqueue(() => {
					Promise.resolve()
						.then(() => {
							return actionToEnqueue();
						}).then((result) => {
							resolveCallback(result);
						}).catch((error) => {
							rejectCallback(error);
						}).then(() => {
							checkStart.call(this);
						});
				});
				checkStart.call(this);
			});
		}
enqueue ( actionToEnqueue ) { return promise . build ( ( resolveCallback , rejectCallback ) => { assert . argumentIsRequired ( actionToEnqueue , 'actionToEnqueue' , Function ) ; if ( this . getIsDisposed ( ) ) { throw new Error ( 'Unable to enqueue action, the rate limiter has been disposed.' ) ; } this . _workQueue . enqueue ( ( ) => { Promise . resolve ( ) . then ( ( ) => { return actionToEnqueue ( ) ; } ) . then ( ( result ) => { resolveCallback ( result ) ; } ) . catch ( ( error ) => { rejectCallback ( error ) ; } ) . then ( ( ) => { checkStart . call ( this ) ; } ) ; } ) ; checkStart . call ( this ) ; } ) ; }
Adds an item to the work queue and returns a promise that will
 resolve after the item completes execution.
Adds an item to the work queue and returns a promise that will resolve after the item completes execution .