index.d.ts•2.33 kB
/// <reference path="typings/node/node.d.ts" />
import events = require('events');
declare class Queue extends events.EventEmitter {
private _runAll;
private _shiftRun;
private _shift;
private _next;
private _paused;
private _pausedOn;
private _count;
private _options;
private _queue;
private _runResults;
private _index;
action: (inputObject?: any) => any;
constructor(inputAction: any);
/**
* Internal function run when a run has completed.
*/
private complete();
/**
* Internal function for handling task completion and run/shift decisions.
*/
private _taskCompleteHandler(data);
/**
* Called by the action function when task complete. Data saved to results.
*/
done(data?: any): any;
/**
* Adds the item to the end of the queue.
*/
add(input: any): any[];
/**
* Removes the queue item at provided index. Returns queue.
*/
remove(input: number): any[];
/**
* Performs the next task. Returns what the action returns.
*/
next(count?: number): any;
/**
* Processes entire queue and stores results.
*/
run(index?: number): void;
/**
* Runs the next task and removes it once complete.
* Returns what the action returns.
*/
shift(count?: number): any;
/**
* Processes entire queue removing each item once completed.
*/
shiftRun(): void;
/**
* Returns the first results of a run and removes it.
*/
shiftResults(): any;
/**
* Returns the results array.
*/
results(): any[];
/**
* Pauses a run or Shiftrun once current task is complete.
*/
pause(): void;
/**
* Continues a run or shiftrun after a pause.
*/
resume(): void;
/**
* Resets the index, clears the queue, and wipes results.
*/
reset(): void;
/**
* Sets the queue if provided, returns the queue.
*/
queue(newQueue?: any[]): any[];
/**
* Sets the index if input provided, then returns the index
*/
index(setIndex?: number): number;
}
export = Queue;