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. var _getIterator2 = require("babel-runtime/core-js/get-iterator");
  6.  
  7. var _getIterator3 = _interopRequireDefault(_getIterator2);
  8.  
  9. var _create = require("babel-runtime/core-js/object/create");
  10.  
  11. var _create2 = _interopRequireDefault(_create);
  12.  
  13. exports.default = function () {
  14.   return {
  15.     visitor: {
  16.       ObjectExpression: function ObjectExpression(path) {
  17.         var node = path.node;
  18.  
  19.         var plainProps = node.properties.filter(function (prop) {
  20.           return !t.isSpreadProperty(prop) && !prop.computed;
  21.         });
  22.  
  23.         var alreadySeenData = (0, _create2.default)(null);
  24.         var alreadySeenGetters = (0, _create2.default)(null);
  25.         var alreadySeenSetters = (0, _create2.default)(null);
  26.  
  27.         for (var _iterator = plainProps, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
  28.           var _ref;
  29.  
  30.           if (_isArray) {
  31.             if (_i >= _iterator.length) break;
  32.             _ref = _iterator[_i++];
  33.           } else {
  34.             _i = _iterator.next();
  35.             if (_i.done) break;
  36.             _ref = _i.value;
  37.           }
  38.  
  39.           var prop = _ref;
  40.  
  41.           var name = getName(prop.key);
  42.           var isDuplicate = false;
  43.           switch (prop.kind) {
  44.             case "get":
  45.               if (alreadySeenData[name] || alreadySeenGetters[name]) {
  46.                 isDuplicate = true;
  47.               }
  48.               alreadySeenGetters[name] = true;
  49.               break;
  50.             case "set":
  51.               if (alreadySeenData[name] || alreadySeenSetters[name]) {
  52.                 isDuplicate = true;
  53.               }
  54.               alreadySeenSetters[name] = true;
  55.               break;
  56.             default:
  57.               if (alreadySeenData[name] || alreadySeenGetters[name] || alreadySeenSetters[name]) {
  58.                 isDuplicate = true;
  59.               }
  60.               alreadySeenData[name] = true;
  61.           }
  62.  
  63.           if (isDuplicate) {
  64.             prop.computed = true;
  65.             prop.key = t.stringLiteral(name);
  66.           }
  67.         }
  68.       }
  69.     }
  70.   };
  71. };
  72.  
  73. var _babelTypes = require("babel-types");
  74.  
  75. var t = _interopRequireWildcard(_babelTypes);
  76.  
  77. 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; } }
  78.  
  79. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  80.  
  81. function getName(key) {
  82.   if (t.isIdentifier(key)) {
  83.     return key.name;
  84.   }
  85.   return key.value.toString();
  86. }
  87.  
  88. 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