degenerator
Advanced tools
Comparing version 1.0.3 to 1.0.4
21
index.js
@@ -43,2 +43,3 @@ | ||
// first pass is to find the `function` nodes and turn them into `function *` | ||
@@ -49,8 +50,10 @@ // generator functions. We also add the names of the functions to the `names` | ||
visitFunction: function(path) { | ||
// got a "function" expression/statement, | ||
// convert it into a "generator function" | ||
path.node.generator = true; | ||
if (path.node.id) { | ||
// got a "function" expression/statement, | ||
// convert it into a "generator function" | ||
path.node.generator = true; | ||
// add function name to `names` array | ||
names.push(path.node.id.name); | ||
// add function name to `names` array | ||
names.push(path.node.id.name); | ||
} | ||
@@ -62,3 +65,3 @@ this.traverse(path); | ||
// second pass is for adding `yield` statements to any function | ||
// invokations that match the given `names` array. | ||
// invocations that match the given `names` array. | ||
types.visit(ast, { | ||
@@ -106,2 +109,8 @@ visitCallExpression: function(path) { | ||
name = callee.object.name + '.' + (callee.property.name || callee.property.raw); | ||
} else if ('FunctionExpression' == callee.type) { | ||
if (callee.id) { | ||
name = callee.id.name; | ||
} else { | ||
return false; | ||
} | ||
} else { | ||
@@ -108,0 +117,0 @@ throw new Error('don\'t know how to get name for: ' + callee.type); |
{ | ||
"name": "degenerator", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Turns sync functions into async generator functions", | ||
@@ -16,3 +16,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"esprima": "2.x.x", | ||
"esprima": "3.x.x", | ||
"escodegen": "1.x.x", | ||
@@ -22,4 +22,4 @@ "ast-types": "0.x.x" | ||
"devDependencies": { | ||
"mocha": "~2.0.1" | ||
"mocha": "3.x.x" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15357
17
274
+ Addedesprima@3.1.3(transitive)
- Removedesprima@2.7.3(transitive)
Updatedesprima@3.x.x