substance
Version:
Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing system. It is developed to power our online editing platform [Substance](http://substance.io).
18 lines (16 loc) • 408 B
JavaScript
/*
Run the functions in the tasks collection in series.
NOTE: You can not access results of the executed functions
*/
export function series (tasks, cb, i) {
i = i || 0
tasks[i](function (err, ...args) {
// Always stop execution on error
if (err) return cb(err)
if (i === tasks.length - 1) {
cb(err, ...args) // we are done
} else {
series(tasks, cb, i + 1)
}
})
}