Command-Pool
Library for limiting parallel work.
Installation:
npm install --save command-pool
Usage:
API:
Static method .start (returns a Promise):
CommandPoolstartcommandArguments parallelCount callback;
- commandArguments (Array) - Array of arguments for commands or count of iterations;
- parallelCount (Optional, Number, Default = 1) - Count of parallel work tasks;
- callback (Function(arg, i, next)) - Function that calls on task, you must return a Promise or call next();
CommandPoolstarttasksCount parallelCount callback;
- tasksCount (Number) - Count of iterations;
- parallelCount (Optional, Number, Default = 1) - Count of parallel work tasks;
- callback (Function(i, next)) - Function that calls on task, you must return a Promise or call next();
Example:
var CommandPool = ; CommandPoolstart5 3 { console; ;};
Output:
0 started
1 started
2 started
0 resolved
3 started
1 resolved
4 started
3 resolved
2 resolved
4 resolved
RESULT: [ 'OK', 'OK', 'OK', 'OK', 'OK' ]
Caution:
Work only in node version >= 0.12.