source: imaps-frontend/node_modules/@babel/plugin-transform-async-generator-functions/lib/for-await.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.4 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = _default;
7var _core = require("@babel/core");
8const buildForAwait = (0, _core.template)(`
9 async function wrapper() {
10 var ITERATOR_ABRUPT_COMPLETION = false;
11 var ITERATOR_HAD_ERROR_KEY = false;
12 var ITERATOR_ERROR_KEY;
13 try {
14 for (
15 var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY;
16 ITERATOR_ABRUPT_COMPLETION = !(STEP_KEY = await ITERATOR_KEY.next()).done;
17 ITERATOR_ABRUPT_COMPLETION = false
18 ) {
19 }
20 } catch (err) {
21 ITERATOR_HAD_ERROR_KEY = true;
22 ITERATOR_ERROR_KEY = err;
23 } finally {
24 try {
25 if (ITERATOR_ABRUPT_COMPLETION && ITERATOR_KEY.return != null) {
26 await ITERATOR_KEY.return();
27 }
28 } finally {
29 if (ITERATOR_HAD_ERROR_KEY) {
30 throw ITERATOR_ERROR_KEY;
31 }
32 }
33 }
34 }
35`);
36function _default(path, {
37 getAsyncIterator
38}) {
39 const {
40 node,
41 scope,
42 parent
43 } = path;
44 const stepKey = scope.generateUidIdentifier("step");
45 const stepValue = _core.types.memberExpression(stepKey, _core.types.identifier("value"));
46 const left = node.left;
47 let declar;
48 if (_core.types.isIdentifier(left) || _core.types.isPattern(left) || _core.types.isMemberExpression(left)) {
49 declar = _core.types.expressionStatement(_core.types.assignmentExpression("=", left, stepValue));
50 } else if (_core.types.isVariableDeclaration(left)) {
51 declar = _core.types.variableDeclaration(left.kind, [_core.types.variableDeclarator(left.declarations[0].id, stepValue)]);
52 }
53 let template = buildForAwait({
54 ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"),
55 ITERATOR_ABRUPT_COMPLETION: scope.generateUidIdentifier("iteratorAbruptCompletion"),
56 ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"),
57 ITERATOR_KEY: scope.generateUidIdentifier("iterator"),
58 GET_ITERATOR: getAsyncIterator,
59 OBJECT: node.right,
60 STEP_KEY: _core.types.cloneNode(stepKey)
61 });
62 template = template.body.body;
63 const isLabeledParent = _core.types.isLabeledStatement(parent);
64 const tryBody = template[3].block.body;
65 const loop = tryBody[0];
66 if (isLabeledParent) {
67 tryBody[0] = _core.types.labeledStatement(parent.label, loop);
68 }
69 return {
70 replaceParent: isLabeledParent,
71 node: template,
72 declar,
73 loop
74 };
75}
76
77//# sourceMappingURL=for-await.js.map
Note: See TracBrowser for help on using the repository browser.