Package Exports
- run-series
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 (run-series) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
run-series

Run an array of functions in series
install
npm install run-series
usage
series(tasks, [callback])
Run the functions in the tasks
array in series, each one running once the previous
function has completed. If any functions in the series pass an error to its callback, no
more functions are run, and callback
is immediately called with the value of the error.
Otherwise, callback
receives an array of results when tasks
have completed.
arguments
tasks
- An array containing functions to run, each function is passed acallback(err, result)
which it must call on completion with an errorerr
(which can benull
) and an optional result value.callback(err, results)
- An optional callback to run once all the functions have completed. This function gets a results array containing all the result arguments passed to the task callbacks.
example
var series = require('run-series')
series([
function (callback) {
// do some stuff ...
callback(null, 'one')
},
function (callback) {
// do some stuff ...
callback(null, 'two')
}
],
// optional callback
function (err, results) {
// the results array will equal ['one','two']
})
series.waterfall(tasks, [callback])
Runs the tasks
array of functions in series, each passing their results to the next in
the array. However, if any of the tasks
pass an error to their own callback, the next
function is not executed, and the main callback
is immediately called with the error.
arguments
tasks
- An array of functions to run, each function is passed acallback(err, result1, result2, ...)
it must call on completion. The first argument is an error (which can benull
) and any further arguments will be passed as arguments in order to the next task.callback(err, [results])
- An optional callback to run once all the functions have completed. This will be passed the results of the last task's callback.
example
var series = require('run-series')
series.waterfall([
function (callback) {
callback(null, 'one', 'two')
},
function (arg1, arg2, callback) {
// arg1 now equals 'one' and arg2 now equals 'two'
callback(null, 'three')
},
function (arg1, callback) {
// arg1 now equals 'three'
callback(null, 'done', 'wohoo')
}
], function (err, result1, result2) {
// result1 now equals 'done'
// result2 now equals 'wohoo'
})
This module is basically equavalent to
async.series
and
async.waterfall
, but it's
handy to just have the functions you need instead of the kitchen sink. Modularity!
Especially handy if you're serving to the browser and need to reduce your javascript
bundle size.
Works great in the browser with browserify!
license
MIT. Copyright (c) Feross Aboukhadijeh.