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

chanel

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

chanel - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

304

build/index.js

@@ -1,8 +0,287 @@

var EventEmitter = require('events').EventEmitter
var inherits = require('util').inherits
(function(
// Reliable reference to the global object (i.e. window in browsers).
global,
inherits(Channel, EventEmitter)
// Dummy constructor that we use as the .constructor property for
// functions that return Generator objects.
GeneratorFunction
) {
var hasOwn = Object.prototype.hasOwnProperty;
module.exports = Channel
if (global.wrapGenerator) {
return;
}
function wrapGenerator(innerFn, self) {
return new Generator(innerFn, self || null);
}
global.wrapGenerator = wrapGenerator;
if (typeof exports !== "undefined") {
exports.wrapGenerator = wrapGenerator;
}
var GenStateSuspendedStart = "suspendedStart";
var GenStateSuspendedYield = "suspendedYield";
var GenStateExecuting = "executing";
var GenStateCompleted = "completed";
// Returning this object from the innerFn has the same effect as
// breaking out of the dispatch switch statement.
var ContinueSentinel = {};
wrapGenerator.mark = function(genFun) {
genFun.constructor = GeneratorFunction;
return genFun;
};
// Ensure isGeneratorFunction works when Function#name not supported.
if (GeneratorFunction.name !== "GeneratorFunction") {
GeneratorFunction.name = "GeneratorFunction";
}
wrapGenerator.isGeneratorFunction = function(genFun) {
var ctor = genFun && genFun.constructor;
return ctor ? GeneratorFunction.name === ctor.name : false;
};
function Generator(innerFn, self) {
var generator = this;
var context = new Context();
var state = GenStateSuspendedStart;
function invoke(method, arg) {
if (state === GenStateExecuting) {
throw new Error("Generator is already running");
}
if (state === GenStateCompleted) {
throw new Error("Generator has already finished");
}
while (true) {
var delegate = context.delegate;
if (delegate) {
try {
var info = delegate.generator[method](arg);
// Delegate generator ran and handled its own exceptions so
// regardless of what the method was, we continue as if it is
// "next" with an undefined arg.
method = "next";
arg = void 0;
} catch (uncaught) {
context.delegate = null;
// Like returning generator.throw(uncaught), but without the
// overhead of an extra function call.
method = "throw";
arg = uncaught;
continue;
}
if (info.done) {
context[delegate.resultName] = info.value;
context.next = delegate.nextLoc;
} else {
state = GenStateSuspendedYield;
return info;
}
context.delegate = null;
}
if (method === "next") {
if (state === GenStateSuspendedStart &&
typeof arg !== "undefined") {
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
throw new TypeError(
"attempt to send " + JSON.stringify(arg) + " to newborn generator"
);
}
if (state === GenStateSuspendedYield) {
context.sent = arg;
} else {
delete context.sent;
}
} else if (method === "throw") {
if (state === GenStateSuspendedStart) {
state = GenStateCompleted;
throw arg;
}
context.dispatchException(arg);
}
state = GenStateExecuting;
try {
var value = innerFn.call(self, context);
// If an exception is thrown from innerFn, we leave state ===
// GenStateExecuting and loop back for another invocation.
state = context.done
? GenStateCompleted
: GenStateSuspendedYield;
var info = {
value: value,
done: context.done
};
if (value === ContinueSentinel) {
if (context.delegate && method === "next") {
// Deliberately forget the last sent value so that we don't
// accidentally pass it on to the delegate.
arg = void 0;
}
} else {
return info;
}
} catch (thrown) {
if (method === "next") {
context.dispatchException(thrown);
} else {
arg = thrown;
}
}
}
}
generator.next = invoke.bind(generator, "next");
generator.throw = invoke.bind(generator, "throw");
}
Generator.prototype.toString = function() {
return "[object Generator]";
};
function Context() {
this.reset();
}
Context.prototype = {
constructor: Context,
reset: function() {
this.next = 0;
this.sent = void 0;
this.tryStack = [];
this.done = false;
this.delegate = null;
// Pre-initialize at least 20 temporary variables to enable hidden
// class optimizations for simple generators.
for (var tempIndex = 0, tempName;
hasOwn.call(this, tempName = "t" + tempIndex) || tempIndex < 20;
++tempIndex) {
this[tempName] = null;
}
},
stop: function() {
this.done = true;
if (hasOwn.call(this, "thrown")) {
var thrown = this.thrown;
delete this.thrown;
throw thrown;
}
return this.rval;
},
keys: function(object) {
return Object.keys(object).reverse();
},
pushTry: function(catchLoc, finallyLoc, finallyTempVar) {
if (finallyLoc) {
this.tryStack.push({
finallyLoc: finallyLoc,
finallyTempVar: finallyTempVar
});
}
if (catchLoc) {
this.tryStack.push({
catchLoc: catchLoc
});
}
},
popCatch: function(catchLoc) {
var lastIndex = this.tryStack.length - 1;
var entry = this.tryStack[lastIndex];
if (entry && entry.catchLoc === catchLoc) {
this.tryStack.length = lastIndex;
}
},
popFinally: function(finallyLoc) {
var lastIndex = this.tryStack.length - 1;
var entry = this.tryStack[lastIndex];
if (!entry || !hasOwn.call(entry, "finallyLoc")) {
entry = this.tryStack[--lastIndex];
}
if (entry && entry.finallyLoc === finallyLoc) {
this.tryStack.length = lastIndex;
}
},
dispatchException: function(exception) {
var finallyEntries = [];
var dispatched = false;
if (this.done) {
throw exception;
}
// Dispatch the exception to the "end" location by default.
this.thrown = exception;
this.next = "end";
for (var i = this.tryStack.length - 1; i >= 0; --i) {
var entry = this.tryStack[i];
if (entry.catchLoc) {
this.next = entry.catchLoc;
dispatched = true;
break;
} else if (entry.finallyLoc) {
finallyEntries.push(entry);
dispatched = true;
}
}
while ((entry = finallyEntries.pop())) {
this[entry.finallyTempVar] = this.next;
this.next = entry.finallyLoc;
}
},
delegateYield: function(generator, resultName, nextLoc) {
this.delegate = {
generator: generator,
resultName: resultName,
nextLoc: nextLoc
};
return ContinueSentinel;
}
};
}).apply(this, Function("return [this, function GeneratorFunction(){}]")());
var EventEmitter = require('events').EventEmitter;
var inherits = require('util').inherits;
inherits(Channel, EventEmitter);
module.exports = Channel;
function Channel(options) {

@@ -40,2 +319,4 @@ if (!(this instanceof Channel))

// read queue;
// read queue

@@ -50,2 +331,4 @@ Object.defineProperty(Channel.prototype, 'queue', {

// you can read from a channel if there's a read queue or if this channel is not closed;
// you can read from a channel if there's a read queue or if this channel is not closed

@@ -56,3 +339,3 @@ Object.defineProperty(Channel.prototype, 'readable', {

}
})
});

@@ -73,2 +356,4 @@ Channel.prototype.open = function () {

// wait for the first push event (returns true)
// or close event (returns false);
// or close event (returns false)

@@ -138,2 +423,7 @@ Channel.prototype.pushed = wrapGenerator.mark(function() {

* If `null`, just means closing the channel.
*/;
/**
* Push a function to the channel.
* If `null`, just means closing the channel.
*/

@@ -247,3 +537,3 @@

}, this);
})
});

@@ -337,2 +627,2 @@ Channel.prototype.next = function (done) {

}, this);
})
});

9

index.js

@@ -1,6 +0,3 @@

try {
module.exports = require('./lib')
} catch (err) {
if (err.message !== 'Unexpected token *') throw err
module.exports = require('./build')
}
module.exports = require('generator-supported')
? require('./lib')
: require('./build');
{
"name": "chanel",
"version": "1.0.3",
"version": "1.0.4",
"description": "Channel-based control-flow for parallel tasks with concurrency control",
"scripts": {
"test": "make test",
"prepublish": "make build"
},
"repository": {

@@ -23,2 +19,5 @@ "type": "git",

},
"dependencies": {
"generator-supported": "~0.0.1"
},
"devDependencies": {

@@ -28,4 +27,9 @@ "co": "^3.0.2",

"should": "^3.0.0",
"regenerator": "~0.3.4"
"regenerator": "~0.3.8",
"gnode": "*"
},
"scripts": {
"test": "NODE=gnode make test",
"prepublish": "make clean build"
},
"engines": {

@@ -32,0 +36,0 @@ "node": ">= 0.11.3"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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