async-to-gen
Advanced tools
Comparing version 1.1.4 to 1.1.5
11
index.js
@@ -203,2 +203,3 @@ var babylon = require('babylon'); | ||
envRecord.referencesArgs = true; | ||
editor.overwrite(node.start, node.end, 'argument$'); | ||
} | ||
@@ -339,3 +340,3 @@ } | ||
if (node.referencesArgs) { | ||
argNames.push('arguments'); | ||
argNames.push('argument$'); | ||
argValues.push('arguments'); | ||
@@ -436,2 +437,3 @@ } | ||
function leaveForAwait(editor, node, ast) { | ||
var envRecord = currentScope(ast); | ||
var idx = findTokenIndex(ast.tokens, node.start) + 1; | ||
@@ -445,3 +447,8 @@ while (ast.tokens[idx].value !== 'await') { | ||
editor.move(node.left.start, node.left.end, node.body.start + 1); | ||
editor.insertLeft(node.left.end, '=yield{__await:' + tmpName + '};'); | ||
editor.insertLeft( | ||
node.left.end, | ||
envRecord.generator ? | ||
'=yield{__await:' + tmpName + '};' : | ||
'=yield ' + tmpName + ';' | ||
); | ||
editor.insertLeft(node.left.start, 'let ' + tmpName); | ||
@@ -448,0 +455,0 @@ } |
{ | ||
"name": "async-to-gen", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Transform async functions to generator functions with speed and simplicity.", | ||
@@ -5,0 +5,0 @@ "author": "Lee Byron <lee@leebyron.com> (http://leebyron.com/)", |
@@ -79,3 +79,3 @@ async-to-gen | ||
Using the require hook allows you to automatically compile files on the fly when | ||
requiring in node: | ||
requiring in node, useful during development: | ||
@@ -87,3 +87,7 @@ ```js | ||
As always, don't forget to use `async-to-gen` to compile files before distributing | ||
your code on npm, as using the require hook affects the whole runtime and not | ||
just your module. | ||
## Use in Build Systems: | ||
@@ -90,0 +94,0 @@ |
35644
7
469
294