Comparing version 1.0.2 to 1.0.3
@@ -74,27 +74,27 @@ var EventEmitter = require('events').EventEmitter | ||
return wrapGenerator(function($ctx) { | ||
while (1) switch ($ctx.next) { | ||
return wrapGenerator(function($ctx0) { | ||
while (1) switch ($ctx0.next) { | ||
case 0: | ||
if (!this.closed) { | ||
$ctx.next = 5; | ||
$ctx0.next = 5; | ||
break; | ||
} | ||
$ctx.rval = false; | ||
delete $ctx.thrown; | ||
$ctx.next = 17; | ||
$ctx0.rval = false; | ||
delete $ctx0.thrown; | ||
$ctx0.next = 17; | ||
break; | ||
case 5: | ||
if (!this.queue) { | ||
$ctx.next = 10; | ||
$ctx0.next = 10; | ||
break; | ||
} | ||
$ctx.rval = true; | ||
delete $ctx.thrown; | ||
$ctx.next = 17; | ||
$ctx0.rval = true; | ||
delete $ctx0.thrown; | ||
$ctx0.next = 17; | ||
break; | ||
case 10: | ||
self = this; | ||
$ctx.next = 13; | ||
$ctx0.next = 13; | ||
@@ -121,9 +121,9 @@ return function (done) { | ||
case 13: | ||
$ctx.rval = $ctx.sent; | ||
delete $ctx.thrown; | ||
$ctx.next = 17; | ||
$ctx0.rval = $ctx0.sent; | ||
delete $ctx0.thrown; | ||
$ctx0.next = 17; | ||
break; | ||
case 17: | ||
case "end": | ||
return $ctx.stop(); | ||
return $ctx0.stop(); | ||
} | ||
@@ -185,4 +185,4 @@ }, this); | ||
return wrapGenerator(function($ctx) { | ||
while (1) switch ($ctx.next) { | ||
return wrapGenerator(function($ctx1) { | ||
while (1) switch ($ctx1.next) { | ||
case 0: | ||
@@ -195,3 +195,3 @@ self = this; | ||
if (!!self.discard) { | ||
$ctx.next = 15; | ||
$ctx1.next = 15; | ||
break; | ||
@@ -201,3 +201,3 @@ } | ||
if (!(self.results.length && 0 in self.results)) { | ||
$ctx.next = 13; | ||
$ctx1.next = 13; | ||
break; | ||
@@ -210,3 +210,3 @@ } | ||
if (!(res instanceof Error)) { | ||
$ctx.next = 9; | ||
$ctx1.next = 9; | ||
break; | ||
@@ -218,12 +218,12 @@ } | ||
case 9: | ||
$ctx.rval = res; | ||
delete $ctx.thrown; | ||
$ctx.next = 24; | ||
$ctx1.rval = res; | ||
delete $ctx1.thrown; | ||
$ctx1.next = 24; | ||
break; | ||
case 13: | ||
$ctx.next = 18; | ||
$ctx1.next = 18; | ||
break; | ||
case 15: | ||
if (!self.results.length) { | ||
$ctx.next = 18; | ||
$ctx1.next = 18; | ||
break; | ||
@@ -237,12 +237,12 @@ } | ||
case 18: | ||
$ctx.next = 20; | ||
$ctx1.next = 20; | ||
return this.next; | ||
case 20: | ||
$ctx.rval = $ctx.sent; | ||
delete $ctx.thrown; | ||
$ctx.next = 24; | ||
$ctx1.rval = $ctx1.sent; | ||
delete $ctx1.thrown; | ||
$ctx1.next = 24; | ||
break; | ||
case 24: | ||
case "end": | ||
return $ctx.stop(); | ||
return $ctx1.stop(); | ||
} | ||
@@ -253,3 +253,12 @@ }, this); | ||
Channel.prototype.next = function (done) { | ||
this.once(this.discard ? 'callback' : String(this.resultIndex), function () { | ||
var event = this.discard | ||
? 'callback' | ||
: String(this.resultIndex) | ||
var self = this | ||
this.once(event, onevent) | ||
if (!this.closed && !this.queue) this.once('close', onclose) | ||
function onevent() { | ||
cleanup() | ||
if (!this.discard) { | ||
@@ -271,3 +280,13 @@ var res = this.results.shift() | ||
} | ||
}) | ||
} | ||
function onclose() { | ||
cleanup() | ||
done() | ||
} | ||
function cleanup() { | ||
self.removeListener(event, onevent) | ||
self.removeListener('close', onclose) | ||
} | ||
} | ||
@@ -278,7 +297,7 @@ | ||
return wrapGenerator(function($ctx) { | ||
while (1) switch ($ctx.next) { | ||
return wrapGenerator(function($ctx2) { | ||
while (1) switch ($ctx2.next) { | ||
case 0: | ||
if (!this.discard) { | ||
$ctx.next = 8; | ||
$ctx2.next = 8; | ||
break; | ||
@@ -288,13 +307,13 @@ } | ||
if (!this.readable) { | ||
$ctx.next = 5; | ||
$ctx2.next = 5; | ||
break; | ||
} | ||
return $ctx.delegateYield(this.read(), "t0", 3); | ||
return $ctx2.delegateYield(this.read(), "t0", 3); | ||
case 3: | ||
$ctx.next = 1; | ||
$ctx2.next = 1; | ||
break; | ||
case 5: | ||
delete $ctx.thrown; | ||
$ctx.next = 18; | ||
delete $ctx2.thrown; | ||
$ctx2.next = 18; | ||
break; | ||
@@ -305,21 +324,21 @@ case 8: | ||
if (!this.readable) { | ||
$ctx.next = 14; | ||
$ctx2.next = 14; | ||
break; | ||
} | ||
return $ctx.delegateYield(this.read(), "t1", 11); | ||
return $ctx2.delegateYield(this.read(), "t1", 11); | ||
case 11: | ||
results.push($ctx.t1); | ||
$ctx.next = 9; | ||
results.push($ctx2.t1); | ||
$ctx2.next = 9; | ||
break; | ||
case 14: | ||
$ctx.rval = results; | ||
delete $ctx.thrown; | ||
$ctx.next = 18; | ||
$ctx2.rval = results; | ||
delete $ctx2.thrown; | ||
$ctx2.next = 18; | ||
break; | ||
case 18: | ||
case "end": | ||
return $ctx.stop(); | ||
return $ctx2.stop(); | ||
} | ||
}, this); | ||
}) |
@@ -171,3 +171,12 @@ var EventEmitter = require('events').EventEmitter | ||
Channel.prototype.next = function (done) { | ||
this.once(this.discard ? 'callback' : String(this.resultIndex), function () { | ||
var event = this.discard | ||
? 'callback' | ||
: String(this.resultIndex) | ||
var self = this | ||
this.once(event, onevent) | ||
if (!this.closed && !this.queue) this.once('close', onclose) | ||
function onevent() { | ||
cleanup() | ||
if (!this.discard) { | ||
@@ -189,3 +198,13 @@ var res = this.results.shift() | ||
} | ||
}) | ||
} | ||
function onclose() { | ||
cleanup() | ||
done() | ||
} | ||
function cleanup() { | ||
self.removeListener(event, onevent) | ||
self.removeListener('close', onclose) | ||
} | ||
} | ||
@@ -192,0 +211,0 @@ |
{ | ||
"name": "chanel", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Channel-based control-flow for parallel tasks with concurrency control", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
16685
466