New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

regenerator

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regenerator - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

30

lib/visit.js

@@ -41,2 +41,3 @@ /**

var argsId = b.identifier("$args");
var wrapGeneratorId = b.identifier("wrapGenerator");
var shouldAliasArguments = renameArguments(node, argsId);

@@ -63,3 +64,3 @@ var vars = hoist(node);

outerBody.push(b.returnStatement(
b.callExpression(b.identifier("wrapGenerator"), [
b.callExpression(wrapGeneratorId, [
emitter.getContextFunction(),

@@ -71,2 +72,29 @@ b.thisExpression()

node.body = b.blockStatement(outerBody);
var markMethod = b.memberExpression(
wrapGeneratorId,
b.identifier("mark"),
false
);
if (n.FunctionDeclaration.check(node)) {
var path = this.parent;
while (path && !(n.BlockStatement.check(path.value) ||
n.Program.check(path.value))) {
path = path.parent;
}
if (path) {
var firstStmtPath = path.get("body", 0);
firstStmtPath.replace(
b.expressionStatement(b.callExpression(markMethod, [node.id])),
firstStmtPath.value
);
}
} else {
n.FunctionExpression.assert(node);
this.replace(b.callExpression(markMethod, [node]));
}
}

@@ -73,0 +101,0 @@

2

package.json

@@ -19,3 +19,3 @@ {

],
"version": "0.2.7",
"version": "0.2.8",
"homepage": "http://github.com/facebook/regenerator",

@@ -22,0 +22,0 @@ "repository": {

@@ -35,2 +35,16 @@ /**

// Dummy constructor that we use as the .constructor property for
// functions that return Generator objects.
function GeneratorFunction() {}
wrapGenerator.mark = function(genFun) {
genFun.constructor = GeneratorFunction;
return genFun;
};
wrapGenerator.isGeneratorFunction = function(genFun) {
var ctor = genFun && genFun.constructor;
return ctor ? "GeneratorFunction" === ctor.name : false;
};
function Generator(innerFn, self) {

@@ -37,0 +51,0 @@ var generator = this;

@@ -9,2 +9,2 @@ /**

*/
!function(t){function e(t,e){return new n(t,e||null)}function n(t,e){function n(){f=h;do var n=t.call(e,u);while(n===l);return f=u.done?c:o,{value:n,done:u.done}}function i(){if(f===h)throw new Error("Generator is already running");if(f===c)throw new Error("Generator has already finished")}var s=this,u=new r,f=a;s.next=function(t){if(i(),u.delegate){try{var e=u.delegate.next(t)}catch(r){return u.delegate=null,s.throw(r)}if(e&&!e.done)return e;u.delegate=null}for(f===o&&(u.sent=t);;)try{return n()}catch(a){u.dispatchException(a)}},s.throw=function(t){if(i(),u.delegate){try{var e=u.delegate.throw(t)}catch(r){t=r}if(e&&!e.done)return e;u.delegate=null}if(f===a)throw f=c,t;for(;;){u.dispatchException(t);try{return n()}catch(o){t=o}}}}function r(){this.reset()}var i=Object.prototype.hasOwnProperty;if(!t.wrapGenerator){t.wrapGenerator=e,"undefined"!=typeof exports&&(exports.wrapGenerator=e);var a="suspendedStart",o="suspendedYield",h="executing",c="completed",l={};r.prototype={constructor:r,reset:function(){this.next=0,this.sent=void 0,this.tryStack=[],this.done=!1,this.delegate=null;for(var t,e=0;i.call(this,t="t"+e)||20>e;++e)this[t]=null},stop:function(){if(this.done=!0,i.call(this,"thrown")){var t=this.thrown;throw delete this.thrown,t}return this.rval},keys:function(t){return Object.keys(t).reverse()},pushTry:function(t,e,n){e&&this.tryStack.push({finallyLoc:e,finallyTempVar:n}),t&&this.tryStack.push({catchLoc:t})},popCatch:function(t){var e=this.tryStack.length-1,n=this.tryStack[e];n&&n.catchLoc===t&&(this.tryStack.length=e)},popFinally:function(t){var e=this.tryStack.length-1,n=this.tryStack[e];n&&i.call(n,"finallyLoc")||(n=this.tryStack[--e]),n&&n.finallyLoc===t&&(this.tryStack.length=e)},dispatchException:function(t){var e=[],n=!1;if(this.done)throw t;this.thrown=t,this.next="end";for(var r=this.tryStack.length-1;r>=0;--r){var i=this.tryStack[r];if(i.catchLoc){this.next=i.catchLoc,n=!0;break}i.finallyLoc&&(e.push(i),n=!0)}for(;i=e.pop();)this[i.finallyTempVar]=this.next,this.next=i.finallyLoc},delegateYield:function(t,e){this.next=e;var n=t.next(this.sent);return n.done?(this.delegate=null,l):(this.delegate=t,n.value)}}}}(Function("return this")());
!function(t){function e(t,e){return new r(t,e||null)}function n(){}function r(t,e){function n(){d=h;do var n=t.call(e,f);while(n===l);return d=f.done?s:c,{value:n,done:f.done}}function r(){if(d===h)throw new Error("Generator is already running");if(d===s)throw new Error("Generator has already finished")}function o(t,e){var n=f.delegate;if(n){try{var r=n.generator[t](e)}catch(i){return f.delegate=null,u.throw(i)}if(r){if(!r.done)return r;f[n.resultName]=r.value,f.next=n.nextLoc}f.delegate=null}}var u=this,f=new i,d=a;u.next=function(t){r();var e=o("next",t);if(e)return e;for(d===c&&(f.sent=t);;)try{return n()}catch(i){f.dispatchException(i)}},u.throw=function(t){r();var e=o("throw",t);if(e)return e;if(d===a)throw d=s,t;for(;;){f.dispatchException(t);try{return n()}catch(i){t=i}}}}function i(){this.reset()}var o=Object.prototype.hasOwnProperty;if(!t.wrapGenerator){t.wrapGenerator=e,"undefined"!=typeof exports&&(exports.wrapGenerator=e);var a="suspendedStart",c="suspendedYield",h="executing",s="completed",l={};e.mark=function(t){return t.constructor=n,t},e.isGeneratorFunction=function(t){var e=t&&t.constructor;return e?"GeneratorFunction"===e.name:!1},i.prototype={constructor:i,reset:function(){this.next=0,this.sent=void 0,this.tryStack=[],this.done=!1,this.delegate=null;for(var t,e=0;o.call(this,t="t"+e)||20>e;++e)this[t]=null},stop:function(){if(this.done=!0,o.call(this,"thrown")){var t=this.thrown;throw delete this.thrown,t}return this.rval},keys:function(t){return Object.keys(t).reverse()},pushTry:function(t,e,n){e&&this.tryStack.push({finallyLoc:e,finallyTempVar:n}),t&&this.tryStack.push({catchLoc:t})},popCatch:function(t){var e=this.tryStack.length-1,n=this.tryStack[e];n&&n.catchLoc===t&&(this.tryStack.length=e)},popFinally:function(t){var e=this.tryStack.length-1,n=this.tryStack[e];n&&o.call(n,"finallyLoc")||(n=this.tryStack[--e]),n&&n.finallyLoc===t&&(this.tryStack.length=e)},dispatchException:function(t){var e=[],n=!1;if(this.done)throw t;this.thrown=t,this.next="end";for(var r=this.tryStack.length-1;r>=0;--r){var i=this.tryStack[r];if(i.catchLoc){this.next=i.catchLoc,n=!0;break}i.finallyLoc&&(e.push(i),n=!0)}for(;i=e.pop();)this[i.finallyTempVar]=this.next,this.next=i.finallyLoc},delegateYield:function(t,e,n){var r=t.next(this.sent);return r.done?(this.delegate=null,this[e]=r.value,this.next=n,l):(this.delegate={generator:t,resultName:e,nextLoc:n},r.value)}}}}(Function("return this")());

@@ -966,1 +966,41 @@ /**

});
describe("isGeneratorFunction", function() {
it("should work for function declarations", function() {
// Do the assertions up here to make sure the generator function is
// marked at the beginning of the block the function is declared in.
assert.strictEqual(
wrapGenerator.isGeneratorFunction(genFun),
true
);
assert.strictEqual(
wrapGenerator.isGeneratorFunction(normalFun),
false
);
function normalFun() {
return 0;
}
function *genFun() {
yield 0;
}
});
it("should work for function expressions", function() {
assert.strictEqual(
wrapGenerator.isGeneratorFunction(function *genFun() {
yield 0;
}),
true
);
assert.strictEqual(
wrapGenerator.isGeneratorFunction(function normalFun() {
return 0;
}),
false
);
});
});
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