run-series
Advanced tools
Comparing version 0.3.1 to 0.4.0
25
index.js
module.exports = series | ||
module.exports.waterfall = waterfall | ||
module.exports.waterfall = require('./waterfall') | ||
@@ -26,24 +26,1 @@ function series (tasks, cb) { | ||
} | ||
function waterfall (tasks, cb) { | ||
var current = 0 | ||
cb = cb || function () {} | ||
function done (err) { | ||
var args = Array.prototype.slice.call(arguments, 1) | ||
if (err) return cb(err, args) | ||
if (++current >= tasks.length) { | ||
cb.apply(undefined, [null].concat(args)) | ||
} else { | ||
tasks[current].apply(undefined, args.concat(done)) | ||
} | ||
} | ||
if (tasks.length) { | ||
tasks[0](done) | ||
} else { | ||
cb(null, []) | ||
} | ||
} | ||
{ | ||
"name": "run-series", | ||
"description": "Run an array of functions in series", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh", |
@@ -1,2 +0,2 @@ | ||
# run-series [![travis](https://img.shields.io/travis/feross/run-series.svg)](https://travis-ci.org/feross/run-series) [![npm](https://img.shields.io/npm/v/run-series.svg)](https://npmjs.org/package/run-series) [![gittip](https://img.shields.io/gittip/feross.svg)](https://www.gittip.com/feross/) | ||
# run-series [![travis](https://img.shields.io/travis/feross/run-series.svg)](https://travis-ci.org/feross/run-series) [![npm](https://img.shields.io/npm/v/run-series.svg)](https://npmjs.org/package/run-series) | ||
@@ -52,6 +52,6 @@ ### Run an array of functions in series | ||
#### waterfall(tasks, [callback]) | ||
#### 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 | ||
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. | ||
@@ -58,0 +58,0 @@ |
var series = require('../') | ||
var waterfall = require('../waterfall') | ||
var test = require('tape') | ||
test('require(run-series/waterfall) usage', function (t) { | ||
t.equal(waterfall, series.waterfall) | ||
t.end() | ||
}) | ||
test('waterfall: functions pass results to next function', function (t) { | ||
@@ -5,0 +11,0 @@ t.plan(8) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100107
12
177