Sha256: a75754021cfe75366e71231f7e4716c2ee8c110e76fb6e15489fe21c51f8e6eb
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
"use strict"; var _interopRequireWildcard = require("babel-runtime/helpers/interop-require-wildcard")["default"]; exports.__esModule = true; var _babelTypes = require("babel-types"); var t = _interopRequireWildcard(_babelTypes); var visitor = { Function: function Function(path) { var params = path.get("params"); // If there's a rest param, no need to loop through it. Also, we need to // hoist one more level to get `declar` at the right spot. var hoistTweak = t.isRestElement(params[params.length - 1]) ? 1 : 0; var outputParamsLength = params.length - hoistTweak; for (var i = 0; i < outputParamsLength; i++) { var param = params[i]; if (param.isArrayPattern() || param.isObjectPattern()) { var uid = path.scope.generateUidIdentifier("ref"); var declar = t.variableDeclaration("let", [t.variableDeclarator(param.node, uid)]); declar._blockHoist = outputParamsLength - i; path.ensureBlock(); path.get("body").unshiftContainer("body", declar); param.replaceWith(uid); } } } }; exports.visitor = visitor;
Version data entries
3 entries across 3 versions & 1 rubygems