BVB Source Codes

reactide Show destructuring.js Source code

Return Download reactide: download destructuring.js Source code - Download reactide Source code - Type:.js
  1. "use strict";
  2.  
  3. exports.__esModule = true;
  4. exports.visitor = undefined;
  5.  
  6. var _babelTypes = require("babel-types");
  7.  
  8. var t = _interopRequireWildcard(_babelTypes);
  9.  
  10. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  11.  
  12. var visitor = exports.visitor = {
  13.   Function: function Function(path) {
  14.     var params = path.get("params");
  15.  
  16.     var hoistTweak = t.isRestElement(params[params.length - 1]) ? 1 : 0;
  17.     var outputParamsLength = params.length - hoistTweak;
  18.  
  19.     for (var i = 0; i < outputParamsLength; i++) {
  20.       var param = params[i];
  21.       if (param.isArrayPattern() || param.isObjectPattern()) {
  22.         var uid = path.scope.generateUidIdentifier("ref");
  23.  
  24.         var declar = t.variableDeclaration("let", [t.variableDeclarator(param.node, uid)]);
  25.         declar._blockHoist = outputParamsLength - i;
  26.  
  27.         path.ensureBlock();
  28.         path.get("body").unshiftContainer("body", declar);
  29.  
  30.         param.replaceWith(uid);
  31.       }
  32.     }
  33.   }
  34. };
downloaddestructuring.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top