BVB Source Codes

reactide Show types.js Source code

Return Download reactide: download types.js Source code - Download reactide Source code - Type:.js
  1. "use strict";
  2.  
  3. exports.__esModule = true;
  4. exports.ArrayPattern = exports.ObjectPattern = exports.RestProperty = exports.SpreadProperty = exports.SpreadElement = undefined;
  5. exports.Identifier = Identifier;
  6. exports.RestElement = RestElement;
  7. exports.ObjectExpression = ObjectExpression;
  8. exports.ObjectMethod = ObjectMethod;
  9. exports.ObjectProperty = ObjectProperty;
  10. exports.ArrayExpression = ArrayExpression;
  11. exports.RegExpLiteral = RegExpLiteral;
  12. exports.BooleanLiteral = BooleanLiteral;
  13. exports.NullLiteral = NullLiteral;
  14. exports.NumericLiteral = NumericLiteral;
  15. exports.StringLiteral = StringLiteral;
  16.  
  17. var _babelTypes = require("babel-types");
  18.  
  19. var t = _interopRequireWildcard(_babelTypes);
  20.  
  21. var _jsesc = require("jsesc");
  22.  
  23. var _jsesc2 = _interopRequireDefault(_jsesc);
  24.  
  25. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26.  
  27. 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; } }
  28.  
  29. function Identifier(node) {
  30.   if (node.variance) {
  31.     if (node.variance === "plus") {
  32.       this.token("+");
  33.     } else if (node.variance === "minus") {
  34.       this.token("-");
  35.     }
  36.   }
  37.  
  38.   this.word(node.name);
  39. }
  40.  
  41. function RestElement(node) {
  42.   this.token("...");
  43.   this.print(node.argument, node);
  44. }
  45.  
  46. exports.SpreadElement = RestElement;
  47. exports.SpreadProperty = RestElement;
  48. exports.RestProperty = RestElement;
  49. function ObjectExpression(node) {
  50.   var props = node.properties;
  51.  
  52.   this.token("{");
  53.   this.printInnerComments(node);
  54.  
  55.   if (props.length) {
  56.     this.space();
  57.     this.printList(props, node, { indent: true, statement: true });
  58.     this.space();
  59.   }
  60.  
  61.   this.token("}");
  62. }
  63.  
  64. exports.ObjectPattern = ObjectExpression;
  65. function ObjectMethod(node) {
  66.   this.printJoin(node.decorators, node);
  67.   this._method(node);
  68. }
  69.  
  70. function ObjectProperty(node) {
  71.   this.printJoin(node.decorators, node);
  72.  
  73.   if (node.computed) {
  74.     this.token("[");
  75.     this.print(node.key, node);
  76.     this.token("]");
  77.   } else {
  78.     if (t.isAssignmentPattern(node.value) && t.isIdentifier(node.key) && node.key.name === node.value.left.name) {
  79.       this.print(node.value, node);
  80.       return;
  81.     }
  82.  
  83.     this.print(node.key, node);
  84.  
  85.     if (node.shorthand && t.isIdentifier(node.key) && t.isIdentifier(node.value) && node.key.name === node.value.name) {
  86.       return;
  87.     }
  88.   }
  89.  
  90.   this.token(":");
  91.   this.space();
  92.   this.print(node.value, node);
  93. }
  94.  
  95. function ArrayExpression(node) {
  96.   var elems = node.elements;
  97.   var len = elems.length;
  98.  
  99.   this.token("[");
  100.   this.printInnerComments(node);
  101.  
  102.   for (var i = 0; i < elems.length; i++) {
  103.     var elem = elems[i];
  104.     if (elem) {
  105.       if (i > 0) this.space();
  106.       this.print(elem, node);
  107.       if (i < len - 1) this.token(",");
  108.     } else {
  109.       this.token(",");
  110.     }
  111.   }
  112.  
  113.   this.token("]");
  114. }
  115.  
  116. exports.ArrayPattern = ArrayExpression;
  117. function RegExpLiteral(node) {
  118.   this.word("/" + node.pattern + "/" + node.flags);
  119. }
  120.  
  121. function BooleanLiteral(node) {
  122.   this.word(node.value ? "true" : "false");
  123. }
  124.  
  125. function NullLiteral() {
  126.   this.word("null");
  127. }
  128.  
  129. function NumericLiteral(node) {
  130.   var raw = this.getPossibleRaw(node);
  131.   var value = node.value + "";
  132.   if (raw == null) {
  133.     this.number(value);
  134.   } else if (this.format.minified) {
  135.     this.number(raw.length < value.length ? raw : value);
  136.   } else {
  137.     this.number(raw);
  138.   }
  139. }
  140.  
  141. function StringLiteral(node, parent) {
  142.   var raw = this.getPossibleRaw(node);
  143.   if (!this.format.minified && raw != null) {
  144.     this.token(raw);
  145.     return;
  146.   }
  147.  
  148.   var opts = {
  149.     quotes: t.isJSX(parent) ? "double" : this.format.quotes,
  150.     wrap: true
  151.   };
  152.   if (this.format.jsonCompatibleStrings) {
  153.     opts.json = true;
  154.   }
  155.   var val = (0, _jsesc2.default)(node.value, opts);
  156.  
  157.   return this.token(val);
  158. }
downloadtypes.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