Comparing version 0.3.0 to 0.3.1
59
index.js
@@ -262,6 +262,29 @@ var EventEmitter = require('events').EventEmitter; | ||
.parEach(limit, function (x, i) { | ||
cb.apply((function () { | ||
var self = this; | ||
var next = function () { | ||
res[i] = arguments[1]; | ||
this.apply(this, arguments); | ||
}).bind(this), arguments); | ||
self.apply(self, arguments); | ||
}; | ||
next.stack = self.stack; | ||
next.stack_ = self.stack_; | ||
next.vars = self.vars; | ||
next.args = self.args; | ||
next.error = self.error; | ||
next.into = function (key) { | ||
return function () { | ||
res[key] = arguments[1]; | ||
self.apply(self, arguments); | ||
}; | ||
}; | ||
next.ok = function () { | ||
var args = [].slice.call(arguments); | ||
args.unshift(null); | ||
return next.apply(next, args); | ||
}; | ||
cb.apply(next, arguments); | ||
}) | ||
@@ -280,8 +303,30 @@ .seq(function () { | ||
this.seqEach(function (x, i) { | ||
var self = (function () { | ||
var self = this; | ||
var next = function () { | ||
res[i] = arguments[1]; | ||
if (i == len - 1) context.stack = res; | ||
this.apply(this, arguments); | ||
}).bind(this); | ||
cb.apply(self, arguments); | ||
self.apply(self, arguments); | ||
}; | ||
next.stack = self.stack; | ||
next.stack_ = self.stack_; | ||
next.vars = self.vars; | ||
next.args = self.args; | ||
next.error = self.error; | ||
next.into = function (key) { | ||
return function () { | ||
res[key] = arguments[1]; | ||
self.apply(self, arguments); | ||
}; | ||
}; | ||
next.ok = function () { | ||
var args = [].slice.call(arguments); | ||
args.unshift(null); | ||
return next.apply(next, args); | ||
}; | ||
cb.apply(next, arguments); | ||
}); | ||
@@ -288,0 +333,0 @@ }; |
{ | ||
"name" : "seq", | ||
"version" : "0.3.0", | ||
"version" : "0.3.1", | ||
"description" : "Chainable asynchronous flow control with sequential and parallel primitives and pipeline-style error handling", | ||
@@ -5,0 +5,0 @@ "main" : "./index.js", |
@@ -728,1 +728,28 @@ var Seq = require('seq'); | ||
}; | ||
exports.nextOk = function () { | ||
var to = setTimeout(function () { | ||
assert.fail('seq never fired'); | ||
}, 500); | ||
function moo1 (cb) { cb(3) } | ||
function moo2 (cb) { cb(4) } | ||
Seq() | ||
.par_(function (next) { moo1(next.ok) }) | ||
.par_(function (next) { moo2(next.ok) }) | ||
.seq_(function (next, x, y) { | ||
assert.eql(x, 3); | ||
assert.eql(y, 4); | ||
next.ok([ 1, 2, 3 ]) | ||
}) | ||
.flatten() | ||
.parMap_(function (next, x) { | ||
next.ok(x * 100) | ||
}) | ||
.seq_(function (next) { | ||
clearTimeout(to); | ||
assert.deepEqual(next.stack, [ 100, 200, 300 ]); | ||
}) | ||
; | ||
}; |
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
48007
1241