Package Exports
- asyncer.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (asyncer.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
asyncer.js
Run groups of (a)sync functions.
☁️ Installation
$ npm i --save asyncer.js📋 Example
const asyncer = require("asyncer.js");
let log = console.log;
let tasks = [
// Execute this sync function
() => { log("First"); }
// *Then* execute an async one
, cb => {
setTimeout(() => {
log("Waited a second");
cb();
}, 1000);
}
// Another async function
, cb => {
setTimeout(() => {
log("Waited another second");
cb();
}, 1000);
}
// *Then* Execute the following group
, [
// ...containing a sync function
() => { log("First in nested group"); }
, {
// ...and a group of parallel functions
// to run in the same time
parallel: [
cb => {
setTimeout(() => {
log("In parallel 1");
cb();
}, 1000);
}
, cb => {
setTimeout(() => {
log("Second one in parallel, but I'll be faster.");
cb();
}, 100);
}
]
}
// After that group of parallel function, execute
// this group of parallel functions
, {
parallel: [
cb => {
setTimeout(() => {
log("Waited a second in another parallel group.");
cb();
}, 1000);
}
, cb => {
setTimeout(() => {
log("Waited 100ms ");
cb();
}, 100);
}
]
}
]
// Run another sync function
, () => { log("Almost done."); }
// An another async one
, cb => {
setTimeout(() => {
log("Last");
cb();
}, 1000);
}
];
// Pass the array above to asyncer
asyncer(tasks, err => {
console.log("Everything was done.");
// =>
// First
// Waited a second
// Waited another second
// First in nested group
// Second one in parallel, but I'll be faster.
// In parallel 1
// Waited 100ms
// Waited a second in another parallel group.
// Almost done.
// Last
// Everything was done.
});📝 Documentation
asyncer(tasks, cb)
Run groups of (a)sync functions.
Params
- Array|Object
tasks: The tasks to run in parallel or one by one. - Function
cb: The callback function.
😋 How to contribute
Have an idea? Found a bug? See how to contribute.
💰 Donations
Another way to support the development of my open-source modules is to set up a recurring donation, via Patreon. 🚀
PayPal donations are appreciated too! Each dollar helps.
Thanks! ❤️
💫 Where is this library used?
If you are using this library in one of your projects, add it in this list. ✨
transformer—Transform data using synchronous and asynchronous functions.
