BVB Source Codes

reactide Show block-hoist.js Source code

Return Download reactide: download block-hoist.js Source code - Download reactide Source code - Type:.js
  1. "use strict";
  2.  
  3. exports.__esModule = true;
  4.  
  5. var _plugin = require("../plugin");
  6.  
  7. var _plugin2 = _interopRequireDefault(_plugin);
  8.  
  9. var _sortBy = require("lodash/sortBy");
  10.  
  11. var _sortBy2 = _interopRequireDefault(_sortBy);
  12.  
  13. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14.  
  15. exports.default = new _plugin2.default({
  16.   /**
  17.    * [Please add a description.]
  18.    *
  19.    * Priority:
  20.    *
  21.    *  - 0 We want this to be at the **very** bottom
  22.    *  - 1 Default node position
  23.    *  - 2 Priority over normal nodes
  24.    *  - 3 We want this to be at the **very** top
  25.    */
  26.  
  27.   visitor: {
  28.     Block: {
  29.       exit: function exit(_ref) {
  30.         var node = _ref.node;
  31.  
  32.         var hasChange = false;
  33.         for (var i = 0; i < node.body.length; i++) {
  34.           var bodyNode = node.body[i];
  35.           if (bodyNode && bodyNode._blockHoist != null) {
  36.             hasChange = true;
  37.             break;
  38.           }
  39.         }
  40.         if (!hasChange) return;
  41.  
  42.         node.body = (0, _sortBy2.default)(node.body, function (bodyNode) {
  43.           var priority = bodyNode && bodyNode._blockHoist;
  44.           if (priority == null) priority = 1;
  45.           if (priority === true) priority = 2;
  46.  
  47.           // Higher priorities should move toward the top.
  48.           return -1 * priority;
  49.         });
  50.       }
  51.     }
  52.   }
  53. });
  54. module.exports = exports["default"];
downloadblock-hoist.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