regenerator
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -22,2 +22,10 @@ /** | ||
// Makes a unique context identifier. This is needed to handle retrieval of | ||
// tempvars from contexts up the scope in nested generator situation. | ||
// see issue #70 | ||
var nextCtxId = 0; | ||
function makeContextId() { | ||
return b.identifier("$ctx" + nextCtxId++); | ||
} | ||
function visitNode(node) { | ||
@@ -41,3 +49,3 @@ if (!n.Function.check(node) || !node.generator) { | ||
// TODO Ensure these identifiers are named uniquely. | ||
var contextId = b.identifier("$ctx"); | ||
var contextId = makeContextId(); | ||
var functionId = node.id ? b.identifier(node.id.name + "$") : null/*Anonymous*/; | ||
@@ -44,0 +52,0 @@ var argsId = b.identifier("$args"); |
14
main.js
@@ -90,11 +90,17 @@ /** | ||
function runtime() { | ||
require(runtime.dev); | ||
} | ||
runtime.dev = path.join(__dirname, "runtime", "dev.js"); | ||
runtime.min = path.join(__dirname, "runtime", "min.js"); | ||
// To modify an AST directly, call require("regenerator").transform(ast). | ||
regenerator.transform = transform; | ||
regenerator.runtime = { | ||
dev: path.join(__dirname, "runtime", "dev.js"), | ||
min: path.join(__dirname, "runtime", "min.js") | ||
}; | ||
// To include the runtime in the current node process, call | ||
// require("regenerator").runtime(). | ||
regenerator.runtime = runtime; | ||
// To transform a string of ES6 code, call require("regenerator")(source); | ||
module.exports = regenerator; |
@@ -19,3 +19,3 @@ { | ||
], | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"homepage": "http://github.com/facebook/regenerator", | ||
@@ -22,0 +22,0 @@ "repository": { |
@@ -171,2 +171,24 @@ /** | ||
describe("nested generators in try-catch", function() { | ||
function *gen() { | ||
try { | ||
nonExistent; | ||
} catch (e) { | ||
yield function* () { | ||
yield e; | ||
} | ||
} | ||
} | ||
it('should get a reference to the caught error', function () { | ||
var gen2 = gen().next().value(); | ||
var res = gen2.next(); | ||
assert.ok(res.value instanceof ReferenceError); | ||
// Note that we don't do strict equality over the message because it varies | ||
// across browsers (if we ever want to run tests in browsers). | ||
assert.ok(res.value.message.match(/nonExistent/)); | ||
}); | ||
}); | ||
describe("try-finally generator", function() { | ||
@@ -173,0 +195,0 @@ function *usingThrow(condition) { |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
96717
2798
3