-
Notifications
You must be signed in to change notification settings - Fork 0
kerwal/tasks-each
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
tasks-each
----------
tasks-each is a simple function for calling one or many functions, sequentially, for one or many items.
currently relies on the module 'async', but not for long.
installation
------------
npm i kerwal/tasks-each
usage
-----
const tasks_each = require("tasks-each");
const {EventEmitter} = require("events");
const items = ["Elephant", "Donkey", "Moose"];
function task1(item, next) {
next("result 1");
// pass an Error object to next() to cause the string of tasks to cancel
}
function task2(item, next) {
next("result 2");
}
var emitter = new EventEmitter();
emitter.on('task starting', (device, task) => {
// ...
});
emitter.on('item finished', (device, results) => {
// ...
// results expected: [["result 1", "result 2"], ["result 1", "result 2"]]
});
tasks_each([task1, task2], items, emitter)
.then(() => {
})
.catch((error) => {
});About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published