@babel/plugin-proposal-async-generator-functions
Advanced tools
Comparing version 7.0.0-beta.43 to 7.0.0-beta.44
@@ -9,5 +9,5 @@ "use strict"; | ||
function _core() { | ||
const data = require("@babel/core"); | ||
var data = require("@babel/core"); | ||
_core = function () { | ||
_core = function _core() { | ||
return data; | ||
@@ -19,47 +19,13 @@ }; | ||
const buildForAwait = (0, _core().template)(` | ||
async function wrapper() { | ||
var ITERATOR_COMPLETION = true; | ||
var ITERATOR_HAD_ERROR_KEY = false; | ||
var ITERATOR_ERROR_KEY; | ||
try { | ||
for ( | ||
var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY, STEP_VALUE; | ||
( | ||
STEP_KEY = await ITERATOR_KEY.next(), | ||
ITERATOR_COMPLETION = STEP_KEY.done, | ||
STEP_VALUE = await STEP_KEY.value, | ||
!ITERATOR_COMPLETION | ||
); | ||
ITERATOR_COMPLETION = true) { | ||
} | ||
} catch (err) { | ||
ITERATOR_HAD_ERROR_KEY = true; | ||
ITERATOR_ERROR_KEY = err; | ||
} finally { | ||
try { | ||
if (!ITERATOR_COMPLETION && ITERATOR_KEY.return != null) { | ||
await ITERATOR_KEY.return(); | ||
} | ||
} finally { | ||
if (ITERATOR_HAD_ERROR_KEY) { | ||
throw ITERATOR_ERROR_KEY; | ||
} | ||
} | ||
} | ||
} | ||
`); | ||
var buildForAwait = (0, _core().template)("\n async function wrapper() {\n var ITERATOR_COMPLETION = true;\n var ITERATOR_HAD_ERROR_KEY = false;\n var ITERATOR_ERROR_KEY;\n try {\n for (\n var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY, STEP_VALUE;\n (\n STEP_KEY = await ITERATOR_KEY.next(),\n ITERATOR_COMPLETION = STEP_KEY.done,\n STEP_VALUE = await STEP_KEY.value,\n !ITERATOR_COMPLETION\n );\n ITERATOR_COMPLETION = true) {\n }\n } catch (err) {\n ITERATOR_HAD_ERROR_KEY = true;\n ITERATOR_ERROR_KEY = err;\n } finally {\n try {\n if (!ITERATOR_COMPLETION && ITERATOR_KEY.return != null) {\n await ITERATOR_KEY.return();\n }\n } finally {\n if (ITERATOR_HAD_ERROR_KEY) {\n throw ITERATOR_ERROR_KEY;\n }\n }\n }\n }\n"); | ||
function _default(path, { | ||
getAsyncIterator | ||
}) { | ||
const { | ||
node, | ||
scope, | ||
parent | ||
} = path; | ||
const stepKey = scope.generateUidIdentifier("step"); | ||
const stepValue = scope.generateUidIdentifier("value"); | ||
const left = node.left; | ||
let declar; | ||
function _default(path, _ref) { | ||
var getAsyncIterator = _ref.getAsyncIterator; | ||
var node = path.node, | ||
scope = path.scope, | ||
parent = path.parent; | ||
var stepKey = scope.generateUidIdentifier("step"); | ||
var stepValue = scope.generateUidIdentifier("value"); | ||
var left = node.left; | ||
var declar; | ||
@@ -72,3 +38,3 @@ if (_core().types.isIdentifier(left) || _core().types.isPattern(left) || _core().types.isMemberExpression(left)) { | ||
let template = buildForAwait({ | ||
var template = buildForAwait({ | ||
ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"), | ||
@@ -85,6 +51,6 @@ ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"), | ||
const isLabeledParent = _core().types.isLabeledStatement(parent); | ||
var isLabeledParent = _core().types.isLabeledStatement(parent); | ||
const tryBody = template[3].block.body; | ||
const loop = tryBody[0]; | ||
var tryBody = template[3].block.body; | ||
var loop = tryBody[0]; | ||
@@ -98,5 +64,5 @@ if (isLabeledParent) { | ||
node: template, | ||
declar, | ||
loop | ||
declar: declar, | ||
loop: loop | ||
}; | ||
} |
@@ -9,5 +9,5 @@ "use strict"; | ||
function _helperPluginUtils() { | ||
const data = require("@babel/helper-plugin-utils"); | ||
var data = require("@babel/helper-plugin-utils"); | ||
_helperPluginUtils = function () { | ||
_helperPluginUtils = function _helperPluginUtils() { | ||
return data; | ||
@@ -20,5 +20,5 @@ }; | ||
function _helperRemapAsyncToGenerator() { | ||
const data = _interopRequireDefault(require("@babel/helper-remap-async-to-generator")); | ||
var data = _interopRequireDefault(require("@babel/helper-remap-async-to-generator")); | ||
_helperRemapAsyncToGenerator = function () { | ||
_helperRemapAsyncToGenerator = function _helperRemapAsyncToGenerator() { | ||
return data; | ||
@@ -31,5 +31,5 @@ }; | ||
function _pluginSyntaxAsyncGenerators() { | ||
const data = _interopRequireDefault(require("@babel/plugin-syntax-async-generators")); | ||
var data = _interopRequireDefault(require("@babel/plugin-syntax-async-generators")); | ||
_pluginSyntaxAsyncGenerators = function () { | ||
_pluginSyntaxAsyncGenerators = function _pluginSyntaxAsyncGenerators() { | ||
return data; | ||
@@ -42,5 +42,5 @@ }; | ||
function _core() { | ||
const data = require("@babel/core"); | ||
var data = require("@babel/core"); | ||
_core = function () { | ||
_core = function _core() { | ||
return data; | ||
@@ -56,38 +56,29 @@ }; | ||
var _default = (0, _helperPluginUtils().declare)(api => { | ||
var _default = (0, _helperPluginUtils().declare)(function (api) { | ||
api.assertVersion(7); | ||
const yieldStarVisitor = { | ||
Function(path) { | ||
var yieldStarVisitor = { | ||
Function: function Function(path) { | ||
path.skip(); | ||
}, | ||
YieldExpression({ | ||
node | ||
}, state) { | ||
YieldExpression: function YieldExpression(_ref, state) { | ||
var node = _ref.node; | ||
if (!node.delegate) return; | ||
const callee = state.addHelper("asyncGeneratorDelegate"); | ||
var callee = state.addHelper("asyncGeneratorDelegate"); | ||
node.argument = _core().types.callExpression(callee, [_core().types.callExpression(state.addHelper("asyncIterator"), [node.argument]), state.addHelper("awaitAsyncGenerator")]); | ||
} | ||
}; | ||
const forAwaitVisitor = { | ||
Function(path) { | ||
var forAwaitVisitor = { | ||
Function: function Function(path) { | ||
path.skip(); | ||
}, | ||
ForOfStatement(path, { | ||
file | ||
}) { | ||
const { | ||
node | ||
} = path; | ||
ForOfStatement: function ForOfStatement(path, _ref2) { | ||
var file = _ref2.file; | ||
var node = path.node; | ||
if (!node.await) return; | ||
const build = (0, _forAwait.default)(path, { | ||
var build = (0, _forAwait.default)(path, { | ||
getAsyncIterator: file.addHelper("asyncIterator") | ||
}); | ||
const { | ||
declar, | ||
loop | ||
} = build; | ||
const block = loop.body; | ||
var declar = build.declar, | ||
loop = build.loop; | ||
var block = loop.body; | ||
path.ensureBlock(); | ||
@@ -111,6 +102,5 @@ | ||
} | ||
}; | ||
const visitor = { | ||
Function(path, state) { | ||
var visitor = { | ||
Function: function Function(path, state) { | ||
if (!path.node.async) return; | ||
@@ -125,3 +115,2 @@ path.traverse(forAwaitVisitor, state); | ||
} | ||
}; | ||
@@ -131,6 +120,5 @@ return { | ||
visitor: { | ||
Program(path, state) { | ||
Program: function Program(path, state) { | ||
path.traverse(visitor, state); | ||
} | ||
} | ||
@@ -137,0 +125,0 @@ }; |
{ | ||
"name": "@babel/plugin-proposal-async-generator-functions", | ||
"version": "7.0.0-beta.43", | ||
"version": "7.0.0-beta.44", | ||
"description": "Turn async generator functions into ES2015 generators", | ||
@@ -12,13 +12,13 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-async-generator-functions", | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "7.0.0-beta.43", | ||
"@babel/helper-remap-async-to-generator": "7.0.0-beta.43", | ||
"@babel/plugin-syntax-async-generators": "7.0.0-beta.43" | ||
"@babel/helper-plugin-utils": "7.0.0-beta.44", | ||
"@babel/helper-remap-async-to-generator": "7.0.0-beta.44", | ||
"@babel/plugin-syntax-async-generators": "7.0.0-beta.44" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "7.0.0-beta.43" | ||
"@babel/core": "7.0.0-beta.44" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-beta.43", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.43" | ||
"@babel/core": "7.0.0-beta.44", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.44" | ||
} | ||
} |
9208
149
+ Added@babel/code-frame@7.0.0-beta.44(transitive)
+ Added@babel/core@7.0.0-beta.44(transitive)
+ Added@babel/generator@7.0.0-beta.44(transitive)
+ Added@babel/helper-annotate-as-pure@7.0.0-beta.44(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.44(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.44(transitive)
+ Added@babel/helper-plugin-utils@7.0.0-beta.44(transitive)
+ Added@babel/helper-remap-async-to-generator@7.0.0-beta.44(transitive)
+ Added@babel/helper-split-export-declaration@7.0.0-beta.44(transitive)
+ Added@babel/helper-wrap-function@7.0.0-beta.44(transitive)
+ Added@babel/helpers@7.0.0-beta.44(transitive)
+ Added@babel/highlight@7.0.0-beta.44(transitive)
+ Added@babel/plugin-syntax-async-generators@7.0.0-beta.44(transitive)
+ Added@babel/template@7.0.0-beta.44(transitive)
+ Added@babel/traverse@7.0.0-beta.44(transitive)
+ Added@babel/types@7.0.0-beta.44(transitive)
+ Addedbabylon@7.0.0-beta.44(transitive)
- Removed@babel/code-frame@7.0.0-beta.43(transitive)
- Removed@babel/core@7.0.0-beta.43(transitive)
- Removed@babel/generator@7.0.0-beta.43(transitive)
- Removed@babel/helper-annotate-as-pure@7.0.0-beta.43(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.43(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.43(transitive)
- Removed@babel/helper-plugin-utils@7.0.0-beta.43(transitive)
- Removed@babel/helper-remap-async-to-generator@7.0.0-beta.43(transitive)
- Removed@babel/helper-split-export-declaration@7.0.0-beta.43(transitive)
- Removed@babel/helper-wrap-function@7.0.0-beta.43(transitive)
- Removed@babel/helpers@7.0.0-beta.43(transitive)
- Removed@babel/highlight@7.0.0-beta.43(transitive)
- Removed@babel/plugin-syntax-async-generators@7.0.0-beta.43(transitive)
- Removed@babel/template@7.0.0-beta.43(transitive)
- Removed@babel/traverse@7.0.0-beta.43(transitive)
- Removed@babel/types@7.0.0-beta.43(transitive)
- Removedbabylon@7.0.0-beta.43(transitive)