Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

concat instead of pushing to results

  • Loading branch information...
commit a8011b13cf499705fd091affb6a1237fd6cbcc1e 1 parent 6896812
@isaacs isaacs authored
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/chain.js
View
6 lib/chain.js
@@ -1,8 +1,8 @@
module.exports = chain
var bindActor = require("./bind-actor.js")
chain.first = {} ; chain.last = {}
-function chain (things, res, cb) {
- if (!cb) cb = res , res = []
+function chain (things, cb) {
+ var res = []
;(function LOOP (i, len) {
if (i >= len) return cb(null,res)
if (Array.isArray(things[i]))
@@ -14,7 +14,7 @@ function chain (things, res, cb) {
if (!things[i]) return LOOP(i + 1, len)
things[i](function (er, data) {
if (er) return cb(er, res)
- if (data !== undefined) res.push(er || data)
+ if (data !== undefined) res = res.concat(data)
LOOP(i + 1, len)
})
})(0, things.length) }
Please sign in to comment.
Something went wrong with that request. Please try again.