npm install seqx
Executes tasks sequentially. The result of a task is passed to the next. Returns promises which resolve when tasks are completed. Fires events when tasks are completed.
Install with npm
```
npm install seqx --save
`javascript
var seqx = require("seqx")
task = function (result, id, context) { }
executor = seqx({context: someObj, manual: false});
var taskPromise = executor.add(task);
`
1. result The result from the previous task. Can be undefined.id
2. The task's id which is an incrementing counter.context
3. An optional context object which is was supplied when the executor was created.
`javascript`
function task(result, id, context) {
return valueForNextTask;
}
* context {Object} - A custom context object which is passed to each taskmanual
* {Boolean} - If set, start must be called on the executor to begin task execution.
Creates a sequential executor.
* task {Function}- task function to be executed
* return {Promise}- A promise which resolves when the task completes and returns the output, if any.
Adds a task to the executor's queue.
task {Function}- task function to be executedn {Number} - Number of times to sequentially execute the task. Each time, the output of a previous iteration is provided to the next.return {Promise}- A promise which resolves when the task completes and returns the output, if any.Adds a task multiple times to the executor's queue.
manual: true option is provided to the constructor seq(). start is automatically called for auto start executors.seqx emits the following events:abort() is called.