Comparing version 0.0.0 to 0.0.1
30
index.js
const pushable = require('pull-pushable') | ||
const thunkify = require('./thunkify') | ||
const thunkifyer = require('thunkifyer') | ||
const util = require('util') | ||
const EE = require('events').EventEmitter | ||
function co(gen) { | ||
if(!(this instanceof co)) { | ||
return new co(gen) | ||
function cooperator(gen) { | ||
if(!(this instanceof cooperator)) { | ||
return new cooperator(gen) | ||
} | ||
@@ -20,3 +20,3 @@ | ||
} | ||
util.inherits(co, EE) | ||
util.inherits(cooperator, EE) | ||
@@ -36,3 +36,3 @@ ;(function() { | ||
try { | ||
this.handle(this.gen.next(val)) | ||
this._handle(this.gen.next(val)) | ||
} catch(e) { | ||
@@ -45,3 +45,3 @@ this.emit('error', e) | ||
try { | ||
this.handle(this.gen.throw(err)) | ||
this._handle(this.gen.throw(err)) | ||
} catch(e) { | ||
@@ -52,3 +52,3 @@ this.emit('error', e) | ||
this.handle = function(res) { | ||
this._handle = function(res) { | ||
try { | ||
@@ -81,7 +81,7 @@ var self = this | ||
try { | ||
res = thunkify(res) | ||
res = thunkifyer(res) | ||
} catch(e) {} | ||
if(isGenerator(res)) { | ||
co(res).on('done', function(val) { | ||
cooperator(res).on('done', function(val) { | ||
self._send(val) | ||
@@ -92,3 +92,3 @@ }).on('error', function(err) { | ||
return | ||
} else if(thunkify.is(res)) { | ||
} else if(thunkifyer.is(res)) { | ||
res(function(err, res) { | ||
@@ -115,5 +115,5 @@ // TODO: what if there are multiple arguments | ||
} | ||
}).call(co.prototype) | ||
}).call(cooperator.prototype) | ||
co.wrap = function(fn, thisVal) { | ||
cooperator.wrap = function(fn, thisVal) { | ||
var res = function() { | ||
@@ -123,3 +123,3 @@ var args = [].slice.call(arguments) | ||
return function(cb) { | ||
return co(fn.apply(thisVal, args)).on('error', function(err) { | ||
return cooperator(fn.apply(thisVal, args)).on('error', function(err) { | ||
if(cb) | ||
@@ -152,2 +152,2 @@ cb(err) | ||
module.exports = co | ||
module.exports = cooperator |
{ | ||
"name": "cooperator", | ||
"description": "Like co but lets you also output data", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"author": "CoderPuppy", | ||
"dependencies": { | ||
"thunkifyer": "^0.0.0" | ||
"thunkifyer": "^0.0.0", | ||
"pull-pushable": "^1.1.4" | ||
} | ||
} |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
4295
4
142
1
33
2
+ Addedpull-pushable@^1.1.4
+ Addedpull-core@1.0.0(transitive)
+ Addedpull-pushable@1.1.4(transitive)
+ Addedpull-stream@2.18.3(transitive)