Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coro

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coro - npm Package Compare versions

Comparing version 0.6.1 to 0.6.2

68

lib/coro.js

@@ -13,6 +13,11 @@

return function (error) {
var result = error ? null : Array.prototype.slice.call(arguments, 1);
if (coros.length && coro === coros[coros.length - 1]) {
coro.save(error, result);
return;
}
var val, err;
coros.push(coro);
try {
val = error ? coro.generator.throw(error) : coro.generator.next(Array.prototype.slice.call(arguments, 1));
val = error ? coro.generator.throw(error) : coro.generator.next(result);
}

@@ -28,7 +33,11 @@ catch (e) {

var coro = currentCoro();
return function (error, res) {
return function (error, result) {
if (coros.length && coro === coros[coros.length - 1]) {
coro.save(error, result);
return;
}
var val, err;
coros.push(coro);
try {
val = error ? coro.generator.throw(error) : coro.generator.next(res);
val = error ? coro.generator.throw(error) : coro.generator.next(result);
}

@@ -45,6 +54,11 @@ catch (e) {

return function (error) {
var result = error ? null : arguments[n];
if (coros.length && coro === coros[coros.length - 1]) {
coro.save(error, result);
return;
}
var val, err;
coros.push(coro);
try {
val = error ? coro.generator.throw(error) : coro.generator.next(arguments[n]);
val = error ? coro.generator.throw(error) : coro.generator.next(result);
}

@@ -61,6 +75,11 @@ catch (e) {

return function () {
var result = Array.prototype.slice.call(arguments, 0);
if (coros.length && coro === coros[coros.length - 1]) {
coro.save(null, result);
return;
}
var val, err;
coros.push(coro);
try {
val = coro.generator.next(Array.prototype.slice.call(arguments, 0));
val = coro.generator.next(result);
}

@@ -77,2 +96,6 @@ catch (e) {

return function (first) {
if (coros.length && coro === coros[coros.length - 1]) {
coro.save(null, first);
return;
}
var val, err;

@@ -93,6 +116,11 @@ coros.push(coro);

return function () {
var result = arguments[n];
if (coros.length && coro === coros[coros.length - 1]) {
coro.save(null, result);
return;
}
var val, err;
coros.push(coro);
try {
val = coro.generator.next(arguments[n]);
val = coro.generator.next(result);
}

@@ -109,2 +137,6 @@ catch (e) {

return function (error) {
if (coros.length && coro === coros[coros.length - 1]) {
coro.save(error);
return;
}
var val, err;

@@ -129,5 +161,6 @@ coros.push(coro);

Coro.prototype.handle = function (err, result) {
var val, err;
coros.pop();
if (err || result.done) {
this.handleResult(err, result);
if (err || this.savedError || result.done) {
this.handleResult(err || this.savedError, result);
}

@@ -137,2 +170,13 @@ else if (result.value && result.value.then) {

}
else if (this.savedResult) {
coros.push(this);
try {
val = this.generator.next(this.savedResult);
}
catch (e) {
err = e;
}
this.savedResult = null;
this.handle(err, val);
}
};

@@ -180,2 +224,10 @@

Coro.prototype.save = function (error, result) {
if (this.savedResult || this.savedError) {
throw new Error('more than one coro callback called without yield');
}
this.savedError = error;
this.savedResult = result;
};
exports.run = function (makeGenerator, args, callback) {

@@ -182,0 +234,0 @@

2

package.json
{
"name" : "coro",
"version" : "0.6.1",
"version" : "0.6.2",
"main" : "lib/coro",

@@ -5,0 +5,0 @@ "author": "Tom Yandell <tom@yandell.me.uk> (https://github.com/tomyan)",

@@ -30,3 +30,3 @@ Library for managing Coroutines using Harmony generators. Supports both Node core style callbacks and promises.

});
}).done();

@@ -60,3 +60,3 @@ coro.run(generator, args, callback) takes the following arguments:

});
}).done();

@@ -85,3 +85,3 @@ Callback based APIs

});
}).done();

@@ -101,3 +101,3 @@ ### coro.resumeFirst()

});
}).done();

@@ -118,3 +118,3 @@ ### coro.resumeNth(n)

});
}).done();

@@ -136,3 +136,3 @@ ### coro.resumeNoThrow()

});
}).done();

@@ -164,3 +164,3 @@ This is also useful for callback APIs that don't follow Node's conventions for indicating an error in the first parameter.

});
}).done();

@@ -209,3 +209,3 @@ Using this method for handling promises isn't recommended - use the built in promise support described above.

// deal with errors
});
}).done();

@@ -228,3 +228,3 @@

// this is the instance of my thing
});
}).done();

@@ -231,0 +231,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc