BVB Source Codes

reactide Show index.js Source code

Return Download reactide: download index.js Source code - Download reactide Source code - Type:.js
  1. "use strict";
  2.  
  3. exports.__esModule = true;
  4.  
  5. exports.default = function (path) {
  6.   var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : path.scope;
  7.   var node = path.node;
  8.  
  9.   var container = t.functionExpression(null, [], node.body, node.generator, node.async);
  10.  
  11.   var callee = container;
  12.   var args = [];
  13.  
  14.   (0, _babelHelperHoistVariables2.default)(path, function (id) {
  15.     return scope.push({ id: id });
  16.   });
  17.  
  18.   var state = {
  19.     foundThis: false,
  20.     foundArguments: false
  21.   };
  22.  
  23.   path.traverse(visitor, state);
  24.  
  25.   if (state.foundArguments) {
  26.     callee = t.memberExpression(container, t.identifier("apply"));
  27.     args = [];
  28.  
  29.     if (state.foundThis) {
  30.       args.push(t.thisExpression());
  31.     }
  32.  
  33.     if (state.foundArguments) {
  34.       if (!state.foundThis) args.push(t.nullLiteral());
  35.       args.push(t.identifier("arguments"));
  36.     }
  37.   }
  38.  
  39.   var call = t.callExpression(callee, args);
  40.   if (node.generator) call = t.yieldExpression(call, true);
  41.  
  42.   return t.returnStatement(call);
  43. };
  44.  
  45. var _babelHelperHoistVariables = require("babel-helper-hoist-variables");
  46.  
  47. var _babelHelperHoistVariables2 = _interopRequireDefault(_babelHelperHoistVariables);
  48.  
  49. var _babelTypes = require("babel-types");
  50.  
  51. var t = _interopRequireWildcard(_babelTypes);
  52.  
  53. 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; } }
  54.  
  55. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  56.  
  57. var visitor = {
  58.   enter: function enter(path, state) {
  59.     if (path.isThisExpression()) {
  60.       state.foundThis = true;
  61.     }
  62.  
  63.     if (path.isReferencedIdentifier({ name: "arguments" })) {
  64.       state.foundArguments = true;
  65.     }
  66.   },
  67.   Function: function Function(path) {
  68.     path.skip();
  69.   }
  70. };
  71.  
  72. module.exports = exports["default"];
downloadindex.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