babel-helper-remap-async-to-generator
Advanced tools
Comparing version 7.0.0-alpha.12 to 7.0.0-alpha.14
@@ -22,5 +22,4 @@ "use strict"; | ||
var template = buildForAwait(); | ||
(0, _babelTraverse2.default)(template, forAwaitVisitor, null, { | ||
var build = helpers.wrapAwait ? buildForAwait : buildForAwaitWithoutWrapping; | ||
var template = build({ | ||
ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"), | ||
@@ -63,6 +62,2 @@ ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"), | ||
var _babelTraverse = require("babel-traverse"); | ||
var _babelTraverse2 = _interopRequireDefault(_babelTraverse); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -72,19 +67,4 @@ | ||
var buildForAwait = (0, _babelTemplate2.default)("\n function* wrapper() {\n var ITERATOR_COMPLETION = true;\n var ITERATOR_HAD_ERROR_KEY = false;\n var ITERATOR_ERROR_KEY = undefined;\n try {\n for (\n var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY, STEP_VALUE;\n (\n STEP_KEY = yield AWAIT(ITERATOR_KEY.next()),\n ITERATOR_COMPLETION = STEP_KEY.done,\n STEP_VALUE = yield 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) {\n yield AWAIT(ITERATOR_KEY.return());\n }\n } finally {\n if (ITERATOR_HAD_ERROR_KEY) {\n throw ITERATOR_ERROR_KEY;\n }\n }\n }\n }\n"); | ||
var forAwaitVisitor = { | ||
noScope: true, | ||
Identifier: function Identifier(path, replacements) { | ||
if (path.node.name in replacements) { | ||
path.replaceInline(replacements[path.node.name]); | ||
} | ||
}, | ||
CallExpression: function CallExpression(path, replacements) { | ||
var callee = path.node.callee; | ||
if (t.isIdentifier(callee) && callee.name === "AWAIT" && !replacements.AWAIT) { | ||
path.replaceWith(path.node.arguments[0]); | ||
} | ||
} | ||
}; | ||
var awaitTemplate = "\n function* wrapper() {\n var ITERATOR_COMPLETION = true;\n var ITERATOR_HAD_ERROR_KEY = false;\n var ITERATOR_ERROR_KEY = undefined;\n try {\n for (\n var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY, STEP_VALUE;\n (\n STEP_KEY = yield AWAIT(ITERATOR_KEY.next()),\n ITERATOR_COMPLETION = STEP_KEY.done,\n STEP_VALUE = yield 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) {\n yield AWAIT(ITERATOR_KEY.return());\n }\n } finally {\n if (ITERATOR_HAD_ERROR_KEY) {\n throw ITERATOR_ERROR_KEY;\n }\n }\n }\n }\n"; | ||
var buildForAwait = (0, _babelTemplate2.default)(awaitTemplate); | ||
var buildForAwaitWithoutWrapping = (0, _babelTemplate2.default)(awaitTemplate.replace(/\bAWAIT\b/g, "")); |
@@ -89,3 +89,2 @@ "use strict"; | ||
path.parentPath.replaceWithMultiple(build.node); | ||
path.remove(); | ||
} else { | ||
@@ -92,0 +91,0 @@ path.replaceWithMultiple(build.node); |
{ | ||
"name": "babel-helper-remap-async-to-generator", | ||
"version": "7.0.0-alpha.12", | ||
"version": "7.0.0-alpha.14", | ||
"description": "Helper function to remap async functions to generators", | ||
@@ -9,7 +9,7 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-remap-async-to-generator", | ||
"dependencies": { | ||
"babel-helper-function-name": "7.0.0-alpha.12", | ||
"babel-template": "7.0.0-alpha.12", | ||
"babel-traverse": "7.0.0-alpha.12", | ||
"babel-types": "7.0.0-alpha.12" | ||
"babel-helper-function-name": "7.0.0-alpha.14", | ||
"babel-template": "7.0.0-alpha.14", | ||
"babel-traverse": "7.0.0-alpha.14", | ||
"babel-types": "7.0.0-alpha.14" | ||
} | ||
} |
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
8768
183
+ Addedbabel-code-frame@7.0.0-alpha.14(transitive)
+ Addedbabel-helper-function-name@7.0.0-alpha.14(transitive)
+ Addedbabel-helper-get-function-arity@7.0.0-alpha.14(transitive)
+ Addedbabel-messages@7.0.0-alpha.14(transitive)
+ Addedbabel-template@7.0.0-alpha.14(transitive)
+ Addedbabel-traverse@7.0.0-alpha.14(transitive)
+ Addedbabel-types@7.0.0-alpha.14(transitive)
+ Addedbabylon@7.0.0-beta.13(transitive)
- Removedbabel-code-frame@7.0.0-alpha.12(transitive)
- Removedbabel-helper-function-name@7.0.0-alpha.12(transitive)
- Removedbabel-helper-get-function-arity@7.0.0-alpha.12(transitive)
- Removedbabel-messages@7.0.0-alpha.12(transitive)
- Removedbabel-template@7.0.0-alpha.12(transitive)
- Removedbabel-traverse@7.0.0-alpha.12(transitive)
- Removedbabel-types@7.0.0-alpha.12(transitive)
- Removedbabylon@7.0.0-beta.12(transitive)
Updatedbabel-types@7.0.0-alpha.14