update
This commit is contained in:
+11
-14
@@ -9,26 +9,22 @@ var _core = require("@babel/core");
|
||||
|
||||
const buildForAwait = (0, _core.template)(`
|
||||
async function wrapper() {
|
||||
var ITERATOR_COMPLETION = true;
|
||||
var ITERATOR_ABRUPT_COMPLETION = false;
|
||||
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) {
|
||||
var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY;
|
||||
ITERATOR_ABRUPT_COMPLETION = !(STEP_KEY = await ITERATOR_KEY.next()).done;
|
||||
ITERATOR_ABRUPT_COMPLETION = false
|
||||
) {
|
||||
}
|
||||
} catch (err) {
|
||||
ITERATOR_HAD_ERROR_KEY = true;
|
||||
ITERATOR_ERROR_KEY = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!ITERATOR_COMPLETION && ITERATOR_KEY.return != null) {
|
||||
if (ITERATOR_ABRUPT_COMPLETION && ITERATOR_KEY.return != null) {
|
||||
await ITERATOR_KEY.return();
|
||||
}
|
||||
} finally {
|
||||
@@ -49,7 +45,9 @@ function _default(path, {
|
||||
parent
|
||||
} = path;
|
||||
const stepKey = scope.generateUidIdentifier("step");
|
||||
const stepValue = scope.generateUidIdentifier("value");
|
||||
|
||||
const stepValue = _core.types.memberExpression(stepKey, _core.types.identifier("value"));
|
||||
|
||||
const left = node.left;
|
||||
let declar;
|
||||
|
||||
@@ -61,13 +59,12 @@ function _default(path, {
|
||||
|
||||
let template = buildForAwait({
|
||||
ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"),
|
||||
ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"),
|
||||
ITERATOR_ABRUPT_COMPLETION: scope.generateUidIdentifier("iteratorAbruptCompletion"),
|
||||
ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"),
|
||||
ITERATOR_KEY: scope.generateUidIdentifier("iterator"),
|
||||
GET_ITERATOR: getAsyncIterator,
|
||||
OBJECT: node.right,
|
||||
STEP_VALUE: stepValue,
|
||||
STEP_KEY: stepKey
|
||||
STEP_KEY: _core.types.cloneNode(stepKey)
|
||||
});
|
||||
template = template.body.body;
|
||||
|
||||
|
||||
+14
-11
@@ -7,20 +7,21 @@ exports.default = void 0;
|
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils");
|
||||
|
||||
var _helperRemapAsyncToGenerator = _interopRequireDefault(require("@babel/helper-remap-async-to-generator"));
|
||||
var _helperRemapAsyncToGenerator = require("@babel/helper-remap-async-to-generator");
|
||||
|
||||
var _pluginSyntaxAsyncGenerators = _interopRequireDefault(require("@babel/plugin-syntax-async-generators"));
|
||||
var _pluginSyntaxAsyncGenerators = require("@babel/plugin-syntax-async-generators");
|
||||
|
||||
var _core = require("@babel/core");
|
||||
|
||||
var _forAwait = _interopRequireDefault(require("./for-await"));
|
||||
var _forAwait = require("./for-await");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor");
|
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => {
|
||||
api.assertVersion(7);
|
||||
const yieldStarVisitor = {
|
||||
Function(path) {
|
||||
|
||||
const yieldStarVisitor = _core.traverse.visitors.merge([{
|
||||
ArrowFunctionExpression(path) {
|
||||
path.skip();
|
||||
},
|
||||
|
||||
@@ -32,9 +33,10 @@ var _default = (0, _helperPluginUtils.declare)(api => {
|
||||
node.argument = _core.types.callExpression(callee, [_core.types.callExpression(state.addHelper("asyncIterator"), [node.argument]), state.addHelper("awaitAsyncGenerator")]);
|
||||
}
|
||||
|
||||
};
|
||||
const forAwaitVisitor = {
|
||||
Function(path) {
|
||||
}, _helperEnvironmentVisitor.default]);
|
||||
|
||||
const forAwaitVisitor = _core.traverse.visitors.merge([{
|
||||
ArrowFunctionExpression(path) {
|
||||
path.skip();
|
||||
},
|
||||
|
||||
@@ -59,7 +61,7 @@ var _default = (0, _helperPluginUtils.declare)(api => {
|
||||
block.body.push(declar);
|
||||
}
|
||||
|
||||
block.body = block.body.concat(node.body.body);
|
||||
block.body.push(...path.node.body.body);
|
||||
|
||||
_core.types.inherits(loop, node);
|
||||
|
||||
@@ -72,7 +74,8 @@ var _default = (0, _helperPluginUtils.declare)(api => {
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}, _helperEnvironmentVisitor.default]);
|
||||
|
||||
const visitor = {
|
||||
Function(path, state) {
|
||||
if (!path.node.async) return;
|
||||
|
||||
Reference in New Issue
Block a user