regenerator
Advanced tools
Comparing version 0.4.6 to 0.4.7
@@ -41,3 +41,3 @@ # Contributing to Regenerator | ||
Complete your CLA here: <https://developers.facebook.com/opensource/cla> | ||
Complete your CLA here: <https://code.facebook.com/cla> | ||
@@ -44,0 +44,0 @@ ## Bugs |
156
lib/visit.js
@@ -15,7 +15,43 @@ /** | ||
var b = types.builders; | ||
var isArray = types.builtInTypes.array; | ||
var isObject = types.builtInTypes.object; | ||
var NodePath = types.NodePath; | ||
var hoist = require("./hoist").hoist; | ||
var Emitter = require("./emit").Emitter; | ||
exports.transform = function(ast) { | ||
return types.traverse(ast, visitNode); | ||
exports.transform = function(node) { | ||
function postOrderTraverse(path) { | ||
assert.ok(path instanceof NodePath); | ||
var value = path.value; | ||
if (isArray.check(value)) { | ||
path.each(postOrderTraverse); | ||
return; | ||
} | ||
if (!isObject.check(value)) { | ||
return; | ||
} | ||
types.eachField(value, function(name, child) { | ||
var childPath = path.get(name); | ||
if (childPath.value !== child) { | ||
childPath.replace(child); | ||
} | ||
postOrderTraverse(childPath); | ||
}); | ||
if (n.Node.check(value)) { | ||
visitNode.call(path, value, postOrderTraverse); | ||
} | ||
} | ||
if (node instanceof NodePath) { | ||
postOrderTraverse(node); | ||
return node.value; | ||
} | ||
var rootPath = new NodePath({ root: node }); | ||
postOrderTraverse(rootPath.get("root")); | ||
return rootPath.value.root; | ||
}; | ||
@@ -48,5 +84,8 @@ | ||
// TODO Ensure $callee is not the name of any hoisted variable. | ||
var outerFnId = node.id || (node.id = b.identifier("$callee")); | ||
var innerFnId = b.identifier(node.id.name + "$"); | ||
// TODO Ensure these identifiers are named uniquely. | ||
var contextId = makeContextId(); | ||
var functionId = node.id ? b.identifier(node.id.name + "$") : null/*Anonymous*/; | ||
var argsId = b.identifier("$args"); | ||
@@ -74,3 +113,4 @@ var wrapGeneratorId = b.identifier("wrapGenerator"); | ||
var wrapGenArgs = [ | ||
emitter.getContextFunction(functionId), | ||
emitter.getContextFunction(innerFnId), | ||
outerFnId, | ||
b.thisExpression() | ||
@@ -105,7 +145,76 @@ ]; | ||
if (path) { | ||
var firstStmtPath = path.get("body", 0); | ||
firstStmtPath.replace( | ||
b.expressionStatement(b.callExpression(markMethod, [node.id])), | ||
firstStmtPath.value | ||
); | ||
// Here we turn the FunctionDeclaration into a named | ||
// FunctionExpression that will be assigned to a variable of the | ||
// same name at the top of the enclosing block. This is important | ||
// for a very subtle reason: named function expressions can refer to | ||
// themselves by name without fear that the binding may change due | ||
// to code executing outside the function, whereas function | ||
// declarations are vulnerable to the following rebinding: | ||
// | ||
// function f() { return f } | ||
// var g = f; | ||
// f = "asdf"; | ||
// g(); // "asdf" | ||
// | ||
// One way to prevent the problem illustrated above is to transform | ||
// the function declaration thus: | ||
// | ||
// var f = function f() { return f }; | ||
// var g = f; | ||
// f = "asdf"; | ||
// g(); // f | ||
// g()()()()(); // f | ||
// | ||
// In the code below, we transform generator function declarations | ||
// in the following way: | ||
// | ||
// gen().next(); // { value: gen, done: true } | ||
// function *gen() { | ||
// return gen; | ||
// } | ||
// | ||
// becomes something like | ||
// | ||
// var gen = wrapGenerator.mark(function *gen() { | ||
// return gen; | ||
// }); | ||
// gen().next(); // { value: gen, done: true } | ||
// | ||
// which ensures that the generator body can always reliably refer | ||
// to gen by name. | ||
// Remove the FunctionDeclaration so that we can add it back as a | ||
// FunctionExpression passed to wrapGenerator.mark. | ||
this.replace(); | ||
// Change the type of the function to be an expression instead of a | ||
// declaration. Note that all the other fields are the same. | ||
node.type = "FunctionExpression"; | ||
var varDecl = b.variableDeclaration("var", [ | ||
b.variableDeclarator( | ||
node.id, | ||
b.callExpression(markMethod, [node]) | ||
) | ||
]); | ||
if (node.comments) { | ||
// Copy any comments preceding the function declaration to the | ||
// variable declaration, to avoid weird formatting consequences. | ||
varDecl.comments = node.comments; | ||
node.comments = null; | ||
} | ||
var bodyPath = path.get("body"); | ||
var bodyLen = bodyPath.value.length; | ||
for (var i = 0; i < bodyLen; ++i) { | ||
var firstStmtPath = bodyPath.get(i); | ||
if (!shouldNotHoistAbove(firstStmtPath)) { | ||
firstStmtPath.replace(varDecl, firstStmtPath.value); | ||
return; | ||
} | ||
} | ||
bodyPath.value.push(varDecl); | ||
} | ||
@@ -119,2 +228,31 @@ | ||
function shouldNotHoistAbove(stmtPath) { | ||
var value = stmtPath.value; | ||
n.Statement.assert(value); | ||
// If the first statement is a "use strict" declaration, make sure to | ||
// insert hoisted declarations afterwards. | ||
if (n.ExpressionStatement.check(value) && | ||
n.Literal.check(value.expression) && | ||
value.expression.value === "use strict") { | ||
return true; | ||
} | ||
if (n.VariableDeclaration.check(value)) { | ||
for (var i = 0; i < value.declarations.length; ++i) { | ||
var decl = value.declarations[i]; | ||
if (n.CallExpression.check(decl.init) && | ||
n.MemberExpression.check(decl.init.callee) && | ||
n.Identifier.check(decl.init.callee.object) && | ||
n.Identifier.check(decl.init.callee.property) && | ||
decl.init.callee.object.name === "wrapGenerator" && | ||
decl.init.callee.property.name === "mark") { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
function renameArguments(funcPath, argsId) { | ||
@@ -121,0 +259,0 @@ assert.ok(funcPath instanceof types.NodePath); |
@@ -19,3 +19,3 @@ { | ||
], | ||
"version": "0.4.6", | ||
"version": "0.4.7", | ||
"homepage": "http://github.com/facebook/regenerator", | ||
@@ -34,3 +34,3 @@ "repository": { | ||
"esprima": "git://github.com/ariya/esprima.git#harmony", | ||
"recast": "~0.5.13", | ||
"recast": "~0.5.17", | ||
"private": "~0.1.2", | ||
@@ -37,0 +37,0 @@ "defs": "~0.6.2" |
@@ -24,3 +24,3 @@ regenerator [](https://travis-ci.org/facebook/regenerator) | ||
cd path/to/node_modules | ||
git clone git://github.com/benjamn/regenerator.git | ||
git clone git://github.com/facebook/regenerator.git | ||
cd regenerator | ||
@@ -27,0 +27,0 @@ npm install . |
@@ -28,4 +28,4 @@ /** | ||
function wrapGenerator(innerFn, self, tryList) { | ||
return new Generator(innerFn, self || null, tryList || []); | ||
function wrapGenerator(innerFn, outerFn, self, tryList) { | ||
return new Generator(innerFn, outerFn, self || null, tryList || []); | ||
} | ||
@@ -47,4 +47,11 @@ | ||
var Gp = Generator.prototype; | ||
var GFp = GeneratorFunction.prototype = Object.create(Function.prototype); | ||
GFp.constructor = GeneratorFunction; | ||
GFp.prototype = Gp; | ||
Gp.constructor = GFp; | ||
wrapGenerator.mark = function(genFun) { | ||
genFun.constructor = GeneratorFunction; | ||
genFun.__proto__ = GFp; | ||
genFun.prototype = Object.create(Gp); | ||
return genFun; | ||
@@ -63,4 +70,4 @@ }; | ||
function Generator(innerFn, self, tryList) { | ||
var generator = this; | ||
function Generator(innerFn, outerFn, self, tryList) { | ||
var generator = outerFn ? Object.create(outerFn.prototype) : this; | ||
var context = new Context(tryList); | ||
@@ -181,2 +188,4 @@ var state = GenStateSuspendedStart; | ||
generator.throw = invoke.bind(generator, "throw"); | ||
return generator; | ||
} | ||
@@ -183,0 +192,0 @@ |
@@ -10,2 +10,2 @@ /** | ||
*/ | ||
(function(t,r,e){function n(t,r,e){return new i(t,r||null,e||[])}function i(t,r,n){function i(n,i){if(l===f)throw new Error("Generator is already running");if(l===u)throw new Error("Generator has already finished");for(;;){var o=a.delegate;if(o){try{var c=o.generator[n](i);n="next",i=e}catch(y){a.delegate=null,n="throw",i=y;continue}if(!c.done)return l=h,c;a[o.resultName]=c.value,a.next=o.nextLoc,a.delegate=null}if("next"===n){if(l===s&&"undefined"!=typeof i)throw new TypeError("attempt to send "+JSON.stringify(i)+" to newborn generator");l===h?a.sent=i:delete a.sent}else if("throw"===n){if(l===s)throw l=u,i;a.dispatchException(i)&&(n="next",i=e)}l=f;try{var d=t.call(r,a);l=a.done?u:h;var c={value:d,done:a.done};if(d!==p)return c;a.delegate&&"next"===n&&(i=e)}catch(v){l=u;"next"===n?a.dispatchException(v):i=v}}}var o=this,a=new c(n),l=s;o.next=i.bind(o,"next"),o.throw=i.bind(o,"throw")}function o(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2]),this.tryEntries.push(r)}function a(t,r){var e=t.completion||{};e.type=0===r?"normal":"return",delete e.arg,t.completion=e}function c(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(o,this),this.reset()}var l=Object.prototype.hasOwnProperty;if(!t.wrapGenerator){t.wrapGenerator=n,"undefined"!=typeof exports&&(exports.wrapGenerator=n);var s="suspendedStart",h="suspendedYield",f="executing",u="completed",p={};n.mark=function(t){return t.constructor=r,t},"GeneratorFunction"!==r.name&&(r.name="GeneratorFunction"),n.isGeneratorFunction=function(t){var e=t&&t.constructor;return e?r.name===e.name:!1},i.prototype.toString=function(){return"[object Generator]"},c.prototype={constructor:c,reset:function(){this.prev=0,this.next=0,this.sent=e,this.done=!1,this.delegate=null,this.tryEntries.forEach(a);for(var t,r=0;l.call(this,t="t"+r)||20>r;++r)this[t]=null},stop:function(){this.done=!0;var t=this.tryEntries[0],r=t.completion;if("throw"===r.type)throw r.arg;return this.rval},keys:function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function n(){for(;r.length;){var e=r.pop();if(e in t)return n.value=e,n.done=!1,n}return n.done=!0,n}},dispatchException:function(t){function r(r,n){return o.type="throw",o.arg=t,e.next=r,!!n}if(this.done)throw t;for(var e=this,n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n],o=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var a=l.call(i,"catchLoc"),c=l.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},_findFinallyEntry:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc<=this.prev&&l.call(e,"finallyLoc")&&(e.finallyLoc===t||this.prev<e.finallyLoc))return e}},abrupt:function(t,r){var e=this._findFinallyEntry(),n=e?e.completion:{};return n.type=t,n.arg=r,e?this.next=e.finallyLoc:this.complete(n),p},complete:function(t){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type&&(this.rval=t.arg,this.next="end"),p},finish:function(t){var r=this._findFinallyEntry(t);return this.complete(r.completion)},"catch":function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var i=n.arg;a(e,r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={generator:t,resultName:r,nextLoc:e},p}}}}).apply(this,Function("return [this, function GeneratorFunction(){}]")()); | ||
(function(t,r,e){function n(t,r,e,n){return new o(t,r,e||null,n||[])}function o(t,r,n,o){function i(r,o){if(y===u)throw new Error("Generator is already running");if(y===f)throw new Error("Generator has already finished");for(;;){var i=l.delegate;if(i){try{var a=i.generator[r](o);r="next",o=e}catch(c){l.delegate=null,r="throw",o=c;continue}if(!a.done)return y=h,a;l[i.resultName]=a.value,l.next=i.nextLoc,l.delegate=null}if("next"===r){if(y===s&&"undefined"!=typeof o)throw new TypeError("attempt to send "+JSON.stringify(o)+" to newborn generator");y===h?l.sent=o:delete l.sent}else if("throw"===r){if(y===s)throw y=f,o;l.dispatchException(o)&&(r="next",o=e)}y=u;try{var d=t.call(n,l);y=l.done?f:h;var a={value:d,done:l.done};if(d!==p)return a;l.delegate&&"next"===r&&(o=e)}catch(v){y=f,"next"===r?l.dispatchException(v):o=v}}}var a=r?Object.create(r.prototype):this,l=new c(o),y=s;return a.next=i.bind(a,"next"),a.throw=i.bind(a,"throw"),a}function i(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2]),this.tryEntries.push(r)}function a(t,r){var e=t.completion||{};e.type=0===r?"normal":"return",delete e.arg,t.completion=e}function c(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(i,this),this.reset()}var l=Object.prototype.hasOwnProperty;if(!t.wrapGenerator){t.wrapGenerator=n,"undefined"!=typeof exports&&(exports.wrapGenerator=n);var s="suspendedStart",h="suspendedYield",u="executing",f="completed",p={},y=o.prototype,d=r.prototype=Object.create(Function.prototype);d.constructor=r,d.prototype=y,y.constructor=d,n.mark=function(t){return t.__proto__=d,t.prototype=Object.create(y),t},"GeneratorFunction"!==r.name&&(r.name="GeneratorFunction"),n.isGeneratorFunction=function(t){var e=t&&t.constructor;return e?r.name===e.name:!1},o.prototype.toString=function(){return"[object Generator]"},c.prototype={constructor:c,reset:function(){this.prev=0,this.next=0,this.sent=e,this.done=!1,this.delegate=null,this.tryEntries.forEach(a);for(var t,r=0;l.call(this,t="t"+r)||20>r;++r)this[t]=null},stop:function(){this.done=!0;var t=this.tryEntries[0],r=t.completion;if("throw"===r.type)throw r.arg;return this.rval},keys:function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function n(){for(;r.length;){var e=r.pop();if(e in t)return n.value=e,n.done=!1,n}return n.done=!0,n}},dispatchException:function(t){function r(r,n){return i.type="throw",i.arg=t,e.next=r,!!n}if(this.done)throw t;for(var e=this,n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],i=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var a=l.call(o,"catchLoc"),c=l.call(o,"finallyLoc");if(a&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(a){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},_findFinallyEntry:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc<=this.prev&&l.call(e,"finallyLoc")&&(e.finallyLoc===t||this.prev<e.finallyLoc))return e}},abrupt:function(t,r){var e=this._findFinallyEntry(),n=e?e.completion:{};return n.type=t,n.arg=r,e?this.next=e.finallyLoc:this.complete(n),p},complete:function(t){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type&&(this.rval=t.arg,this.next="end"),p},finish:function(t){var r=this._findFinallyEntry(t);return this.complete(r.completion)},"catch":function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;a(e,r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={generator:t,resultName:r,nextLoc:e},p}}}}).apply(this,Function("return [this, function GeneratorFunction(){}]")()); |
@@ -16,2 +16,3 @@ /** | ||
var regenerator = require("../main"); | ||
var mochaDir = path.dirname(require.resolve("mocha")); | ||
@@ -28,7 +29,6 @@ function convert(es6File, es5File, callback) { | ||
function bundle(es5File, browserFile, callback) { | ||
var browserify = require("browserify"); | ||
var b = browserify(); | ||
b.add(es5File); | ||
b.bundle(function(err, src) { | ||
function bundle(es5Files, browserFile, callback) { | ||
var bundle = require("browserify")(); | ||
es5Files.forEach(bundle.add, bundle); | ||
bundle.bundle(function(err, src) { | ||
if (err) { | ||
@@ -72,2 +72,12 @@ return callback(err); | ||
function makeMochaCopyFunction(fileName) { | ||
return function copy(callback) { | ||
var src = path.join(mochaDir, fileName); | ||
var dst = path.join(__dirname, fileName); | ||
fs.unlink(dst, function() { | ||
fs.symlink(src, dst, callback); | ||
}); | ||
}; | ||
} | ||
if (semver.gte(process.version, "0.11.2")) { | ||
@@ -96,3 +106,4 @@ enqueue("mocha", [ | ||
enqueue(bundle, [ | ||
"./test/tests.es5.js", | ||
["./runtime/dev.js", | ||
"./test/tests.es5.js"], | ||
"./test/tests.browser.js" | ||
@@ -111,13 +122,2 @@ ]); | ||
var mochaDir = path.dirname(require.resolve("mocha")); | ||
function makeMochaCopyFunction(fileName) { | ||
return function copy(callback) { | ||
var src = path.join(mochaDir, fileName); | ||
var dst = path.join(__dirname, fileName); | ||
fs.unlink(dst, function() { | ||
fs.symlink(src, dst, callback); | ||
}); | ||
}; | ||
} | ||
flush(); |
@@ -12,6 +12,3 @@ /** | ||
var assert = require("assert"); | ||
var runningNatively = false; | ||
try { | ||
runningNatively = !!Function("return function*(){}")(); | ||
} catch (e) {} | ||
var runningInTranslation = /\bwrapGenerator\b/.test(function*(){}); | ||
@@ -37,2 +34,15 @@ function check(g, yields, returnValue) { | ||
function assertAlreadyFinished(generator) { | ||
try { | ||
generator.next(); | ||
assert.ok(false, "should have thrown an exception"); | ||
} catch (err) { | ||
assert.ok(err instanceof Error); | ||
assert.strictEqual( | ||
err.message, | ||
"Generator has already finished" | ||
); | ||
} | ||
} | ||
describe("wrapGenerator", function() { | ||
@@ -139,3 +149,3 @@ it("should be defined globally", function() { | ||
describe("throw", function() { | ||
(runningNatively ? xit : it)("should complete generator", function() { | ||
(runningInTranslation ? it : xit)("should complete generator", function() { | ||
function *gen(x) { | ||
@@ -153,12 +163,3 @@ throw 1; | ||
try { | ||
u.next(); | ||
assert.ok(false, "should have thrown an exception"); | ||
} catch (err) { | ||
assert.ok(err instanceof Error); | ||
assert.strictEqual( | ||
err.message, | ||
"Generator has already finished" | ||
); | ||
} | ||
assertAlreadyFinished(u); | ||
}); | ||
@@ -217,3 +218,5 @@ }); | ||
it('should get a reference to the caught error', function () { | ||
var gen2 = gen().next().value(); | ||
var genFun2 = gen().next().value; | ||
assert.ok(wrapGenerator.isGeneratorFunction(genFun2)); | ||
var gen2 = genFun2(); | ||
var res = gen2.next(); | ||
@@ -702,12 +705,3 @@ assert.ok(res.value instanceof ReferenceError); | ||
try { | ||
g.next(); | ||
assert.ok(false, "should have thrown an exception"); | ||
} catch (err) { | ||
assert.ok(err instanceof Error); | ||
assert.strictEqual( | ||
err.message, | ||
"Generator has already finished" | ||
); | ||
} | ||
assertAlreadyFinished(g); | ||
}); | ||
@@ -1118,3 +1112,3 @@ }); | ||
describe("generator .throw method", function() { | ||
(runningNatively ? xit : it)("should complete generator", function() { | ||
(runningInTranslation ? it : xit)("should complete generator", function() { | ||
function *gen(x) { | ||
@@ -1135,12 +1129,3 @@ yield 2; | ||
try { | ||
u.next(); | ||
assert.ok(false, "should have thrown an exception"); | ||
} catch (err) { | ||
assert.ok(err instanceof Error); | ||
assert.strictEqual( | ||
err.message, | ||
"Generator has already finished" | ||
); | ||
} | ||
assertAlreadyFinished(u); | ||
}); | ||
@@ -1647,1 +1632,70 @@ | ||
}); | ||
describe("for loop with var decl and no update expression", function() { | ||
// https://github.com/facebook/regenerator/issues/103 | ||
function *range() { | ||
for (var i = 0; false; ) { | ||
} | ||
} | ||
it("should compile and run", function() { | ||
check(range(), []); | ||
}); | ||
}); | ||
describe("generator function prototype", function() { | ||
it("should follow the expected object model", function() { | ||
var GeneratorFunctionPrototype = f.__proto__; | ||
var GeneratorFunction = GeneratorFunctionPrototype.constructor; | ||
assert.strictEqual(GeneratorFunction.name, 'GeneratorFunction'); | ||
assert.strictEqual(GeneratorFunction.prototype, | ||
GeneratorFunctionPrototype); | ||
assert.strictEqual(GeneratorFunctionPrototype.prototype.constructor, | ||
GeneratorFunctionPrototype); | ||
assert.strictEqual(GeneratorFunctionPrototype.prototype, | ||
f.prototype.__proto__); | ||
assert.strictEqual(GeneratorFunctionPrototype.__proto__, | ||
Function.prototype); | ||
var g = f(); | ||
assert.ok(g instanceof f); | ||
assert.strictEqual(g.__proto__, f.prototype); | ||
assert.deepEqual([], Object.getOwnPropertyNames(f.prototype)); | ||
// assert.deepEqual([], Object.getOwnPropertyNames(g)); | ||
f.prototype.x = 42; | ||
var g2 = f(); | ||
assert.strictEqual(g2.x, 42); | ||
var g3 = new f(); | ||
assert.strictEqual(g3.x, 42); | ||
function* f2() { | ||
yield 1; | ||
} | ||
assert.strictEqual(f.__proto__, f2.__proto__); | ||
assert.strictEqual(f.hasOwnProperty('constructor'), false); | ||
assert.strictEqual(f.__proto__.constructor.name, 'GeneratorFunction'); | ||
// Intentionally at the end to test hoisting. | ||
function* f() { | ||
yield this; | ||
} | ||
function* f() { | ||
yield 1; | ||
} | ||
var f2 = f; | ||
f = 42; | ||
var g = f2(); | ||
assert.deepEqual(g.next(), { value: 1, done: false }); | ||
assert.deepEqual(g.next(), { value: void 0, done: true }); | ||
assert.ok(g instanceof f2); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
119821
3519
2
Updatedrecast@~0.5.17