aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-transform-block-scoped-functions/lib
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@babel/plugin-transform-block-scoped-functions/lib')
-rw-r--r--node_modules/@babel/plugin-transform-block-scoped-functions/lib/index.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-transform-block-scoped-functions/lib/index.js b/node_modules/@babel/plugin-transform-block-scoped-functions/lib/index.js
new file mode 100644
index 00000000..970590bb
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-block-scoped-functions/lib/index.js
@@ -0,0 +1,81 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+
+function _helperPluginUtils() {
+ const data = require("@babel/helper-plugin-utils");
+
+ _helperPluginUtils = function _helperPluginUtils() {
+ return data;
+ };
+
+ return data;
+}
+
+function _core() {
+ const data = require("@babel/core");
+
+ _core = function _core() {
+ return data;
+ };
+
+ return data;
+}
+
+var _default = (0, _helperPluginUtils().declare)(api => {
+ api.assertVersion(7);
+
+ function statementList(key, path) {
+ const paths = path.get(key);
+
+ for (var _iterator = paths, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
+ var _ref;
+
+ if (_isArray) {
+ if (_i >= _iterator.length) break;
+ _ref = _iterator[_i++];
+ } else {
+ _i = _iterator.next();
+ if (_i.done) break;
+ _ref = _i.value;
+ }
+
+ const path = _ref;
+ const func = path.node;
+ if (!path.isFunctionDeclaration()) continue;
+
+ const declar = _core().types.variableDeclaration("let", [_core().types.variableDeclarator(func.id, _core().types.toExpression(func))]);
+
+ declar._blockHoist = 2;
+ func.id = null;
+ path.replaceWith(declar);
+ }
+ }
+
+ return {
+ visitor: {
+ BlockStatement(path) {
+ const node = path.node,
+ parent = path.parent;
+
+ if (_core().types.isFunction(parent, {
+ body: node
+ }) || _core().types.isExportDeclaration(parent)) {
+ return;
+ }
+
+ statementList("body", path);
+ },
+
+ SwitchCase(path) {
+ statementList("consequent", path);
+ }
+
+ }
+ };
+});
+
+exports.default = _default; \ No newline at end of file