Permalink
Browse files

ok in par{Each,Map}_ now works

  • Loading branch information...
1 parent 2763301 commit 3d55791e46e68d7cfb1e227a0d92f45f904204a0 @substack committed Jun 7, 2011
Showing with 18 additions and 5 deletions.
  1. +15 −3 index.js
  2. +3 −2 test/seq.js
View
@@ -259,10 +259,22 @@ function builder (saw, xs) {
Seq()
.extend(context.stack)
.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.ok = function () {
+ var args = [].slice.call(arguments);
+ args.unshift(null);
+ return next.apply(next, args);
+ };
+
+ next.stack = self.stack;
+
+ cb.apply(next, arguments);
})
.seq(function () {
context.stack = res;
View
@@ -742,12 +742,13 @@ exports.nextOk = function () {
assert.eql(y, 4);
next.ok([ 1, 2, 3 ])
})
+ .flatten()
.parMap_(function (next, x) {
next.ok(x * 100)
})
- .seq(function (next) {
+ .seq_(function (next) {
clearTimeout(to);
- assert.equal(next.stack, [ 100, 200, 300 ]);
+ assert.deepEqual(next.stack, [ 100, 200, 300 ]);
})
;
};

0 comments on commit 3d55791

Please sign in to comment.