Skip to content
Run an array of functions in series
Branch: master
Clone or download
feross Merge pull request #19 from feross/greenkeeper/airtap-0.1.0
chore(package): update airtap to version 0.1.0
Latest commit 6d0e695 Jul 27, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test JavaScript Standard Style Mar 19, 2015
.airtap.yml fix airtap Mar 17, 2018
.npmignore name function Apr 26, 2018
.travis.yml zuul -> airtap Mar 17, 2018
LICENSE license Aug 10, 2014
README.md
img.png add readme Apr 13, 2014
index.js name function Apr 26, 2018
package.json

README.md

run-series travis npm downloads javascript style guide

Run an array of functions in series

series Sauce Test Status

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 a callback(err, result) which it must call on completion with an error err (which can be null) 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']
})

This module is basically equavalent to async.series, 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!

see also

license

MIT. Copyright (c) Feross Aboukhadijeh.

You can’t perform that action at this time.