Skip to content

Commit

Permalink
issue #254 - fixed some glitches in generators-fast transform and uni…
Browse files Browse the repository at this point in the history
…t tests
  • Loading branch information
bjouhier committed Mar 7, 2015
1 parent 805419e commit 256f876
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/generators-fast/flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
function() {
var funnel = exports.funnel(max);
this.collect = function*(_, count, trim) {
return (yield galaxy.invoke((function(callback) {
return (yield galaxy.invoke(function(callback) {
if (typeof(callback) != "function") throw new Error("invalid call to collect: no callback");
var results = trim ? [] : new Array(fns.length);
count = count < 0 ? fns.length : Math.min(count, fns.length);
Expand All @@ -125,7 +125,7 @@
} , fns[i]);
})(i);
}
}, "call", [this, _], 1));
}, "call", [this , _], 1));
};
this.collectOne = function*(_) {
var result = (yield this.collect(_, 1, true));
Expand Down Expand Up @@ -334,7 +334,7 @@
/// * `flows.sleep(_, millis)`
/// Sleeps `millis` ms.
exports.sleep = function*(_, millis) {
return (yield galaxy.invoke(null, setTimeout, [_, millis], 0));
return (yield galaxy.invoke(null, setTimeout, [_ , millis], 0));
};

exports.eventHandler = function(fn) {
Expand Down
6 changes: 4 additions & 2 deletions lib/generators-fast/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function transform(source, options) {
skipTo(expr.range[0]);
buffer += '(yield galaxy.invoke(';
if (expr.type === 'MemberExpression') {
skipTo(expr.object.range[0]);
if (!expr.computed) {
// Method call: foo.bar(_)
walk(expr.object);
Expand All @@ -191,9 +192,9 @@ function transform(source, options) {
}
// Render arguments
buffer += ', [';
skipTo(args[0].range[0]);
for (var ii = 0; ii < args.length; ++ii) {
catchup(args[ii].range[0]);
skipTo(args[ii].range[0]);
if (ii > 0) buffer += ', ';
if (ii !== idx) {
walk(args[ii]);
catchup(args[ii].range[1]);
Expand Down Expand Up @@ -271,6 +272,7 @@ function transform(source, options) {
var isPromise = args[idx].operator === "void";
catchup(this.range[0]);
buffer += 'galaxy.' + (isPromise ? 'promise' : 'spin') + '.call(this, ';
skipTo(expr.range[0]);
walk(expr);
catchup(expr.range[1]);
if (isPromise) buffer += ', [';
Expand Down
6 changes: 3 additions & 3 deletions test/common/flows-test._js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ asyncTest("collectAll", 4, function(_) {
return function(_) {
count++;
peak = Math.max(count, peak);
setTimeout(_, 10);
setTimeout(~_, 10);
total = delay(_, i) + total;
count--;
return 2 * i;
Expand All @@ -359,7 +359,7 @@ asyncTest("collectOne", 4, function(_) {
return function(_) {
count++;
peak = Math.max(count, peak);
setTimeout(_, 10);
setTimeout(~_, 10);
total = delay(_, i) + total;
count--;
return 2 * i;
Expand All @@ -382,7 +382,7 @@ asyncTest("collectAll with limit", 1, function(_) {
return function(_) {
count++;
peak = Math.max(count, peak);
setTimeout(_, 10);
setTimeout(~_, 10);
total = delay(_, i) + total;
count--;
return 2 * i;
Expand Down

0 comments on commit 256f876

Please sign in to comment.