Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

run-series

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

run-series - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

test/waterfall.js

45

index.js

@@ -1,18 +0,15 @@

module.exports = function (tasks, cb) {
module.exports = series
module.exports.waterfall = waterfall
function series (tasks, cb) {
var current = 0
var results = []
cb = cb || function () {}
function done (err, result) {
if (err) {
cb && cb(err, results)
cb = null
return
}
if (err) return cb(err, results)
results.push(result)
current += 1
if (current >= tasks.length) {
cb && cb(null, results)
cb = null
if (++current >= tasks.length) {
cb(null, results)
} else {

@@ -26,5 +23,27 @@ tasks[current](done)

} else {
cb && cb(null, [])
cb = null
cb(null, [])
}
}
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[current](done)
} else {
cb(null, [])
}
}
{
"name": "run-series",
"description": "Run an array of functions in series",
"version": "0.2.0",
"version": "0.3.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh",

@@ -19,3 +19,3 @@ # 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/)

function has completed. If any functions in the series pass an error to its callback, no
more functions are run, and 1callback1 is immediately called with the value of the error.
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.

@@ -22,0 +22,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc