Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

types.js 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.Identifier = Identifier;
  6. exports.ArgumentPlaceholder = ArgumentPlaceholder;
  7. exports.SpreadElement = exports.RestElement = RestElement;
  8. exports.ObjectPattern = exports.ObjectExpression = ObjectExpression;
  9. exports.ObjectMethod = ObjectMethod;
  10. exports.ObjectProperty = ObjectProperty;
  11. exports.ArrayPattern = exports.ArrayExpression = ArrayExpression;
  12. exports.RecordExpression = RecordExpression;
  13. exports.TupleExpression = TupleExpression;
  14. exports.RegExpLiteral = RegExpLiteral;
  15. exports.BooleanLiteral = BooleanLiteral;
  16. exports.NullLiteral = NullLiteral;
  17. exports.NumericLiteral = NumericLiteral;
  18. exports.StringLiteral = StringLiteral;
  19. exports.BigIntLiteral = BigIntLiteral;
  20. exports.DecimalLiteral = DecimalLiteral;
  21. exports.PipelineTopicExpression = PipelineTopicExpression;
  22. exports.PipelineBareFunction = PipelineBareFunction;
  23. exports.PipelinePrimaryTopicReference = PipelinePrimaryTopicReference;
  24. var t = require("@babel/types");
  25. var _jsesc = require("jsesc");
  26. function Identifier(node) {
  27. this.exactSource(node.loc, () => {
  28. this.word(node.name);
  29. });
  30. }
  31. function ArgumentPlaceholder() {
  32. this.token("?");
  33. }
  34. function RestElement(node) {
  35. this.token("...");
  36. this.print(node.argument, node);
  37. }
  38. function ObjectExpression(node) {
  39. const props = node.properties;
  40. this.token("{");
  41. this.printInnerComments(node);
  42. if (props.length) {
  43. this.space();
  44. this.printList(props, node, {
  45. indent: true,
  46. statement: true
  47. });
  48. this.space();
  49. }
  50. this.token("}");
  51. }
  52. function ObjectMethod(node) {
  53. this.printJoin(node.decorators, node);
  54. this._methodHead(node);
  55. this.space();
  56. this.print(node.body, node);
  57. }
  58. function ObjectProperty(node) {
  59. this.printJoin(node.decorators, node);
  60. if (node.computed) {
  61. this.token("[");
  62. this.print(node.key, node);
  63. this.token("]");
  64. } else {
  65. if (t.isAssignmentPattern(node.value) && t.isIdentifier(node.key) && node.key.name === node.value.left.name) {
  66. this.print(node.value, node);
  67. return;
  68. }
  69. this.print(node.key, node);
  70. if (node.shorthand && t.isIdentifier(node.key) && t.isIdentifier(node.value) && node.key.name === node.value.name) {
  71. return;
  72. }
  73. }
  74. this.token(":");
  75. this.space();
  76. this.print(node.value, node);
  77. }
  78. function ArrayExpression(node) {
  79. const elems = node.elements;
  80. const len = elems.length;
  81. this.token("[");
  82. this.printInnerComments(node);
  83. for (let i = 0; i < elems.length; i++) {
  84. const elem = elems[i];
  85. if (elem) {
  86. if (i > 0) this.space();
  87. this.print(elem, node);
  88. if (i < len - 1) this.token(",");
  89. } else {
  90. this.token(",");
  91. }
  92. }
  93. this.token("]");
  94. }
  95. function RecordExpression(node) {
  96. const props = node.properties;
  97. let startToken;
  98. let endToken;
  99. if (this.format.recordAndTupleSyntaxType === "bar") {
  100. startToken = "{|";
  101. endToken = "|}";
  102. } else if (this.format.recordAndTupleSyntaxType === "hash") {
  103. startToken = "#{";
  104. endToken = "}";
  105. } else {
  106. throw new Error(`The "recordAndTupleSyntaxType" generator option must be "bar" or "hash" (${JSON.stringify(this.format.recordAndTupleSyntaxType)} received).`);
  107. }
  108. this.token(startToken);
  109. this.printInnerComments(node);
  110. if (props.length) {
  111. this.space();
  112. this.printList(props, node, {
  113. indent: true,
  114. statement: true
  115. });
  116. this.space();
  117. }
  118. this.token(endToken);
  119. }
  120. function TupleExpression(node) {
  121. const elems = node.elements;
  122. const len = elems.length;
  123. let startToken;
  124. let endToken;
  125. if (this.format.recordAndTupleSyntaxType === "bar") {
  126. startToken = "[|";
  127. endToken = "|]";
  128. } else if (this.format.recordAndTupleSyntaxType === "hash") {
  129. startToken = "#[";
  130. endToken = "]";
  131. } else {
  132. throw new Error(`${this.format.recordAndTupleSyntaxType} is not a valid recordAndTuple syntax type`);
  133. }
  134. this.token(startToken);
  135. this.printInnerComments(node);
  136. for (let i = 0; i < elems.length; i++) {
  137. const elem = elems[i];
  138. if (elem) {
  139. if (i > 0) this.space();
  140. this.print(elem, node);
  141. if (i < len - 1) this.token(",");
  142. }
  143. }
  144. this.token(endToken);
  145. }
  146. function RegExpLiteral(node) {
  147. this.word(`/${node.pattern}/${node.flags}`);
  148. }
  149. function BooleanLiteral(node) {
  150. this.word(node.value ? "true" : "false");
  151. }
  152. function NullLiteral() {
  153. this.word("null");
  154. }
  155. function NumericLiteral(node) {
  156. const raw = this.getPossibleRaw(node);
  157. const opts = this.format.jsescOption;
  158. const value = node.value + "";
  159. if (opts.numbers) {
  160. this.number(_jsesc(node.value, opts));
  161. } else if (raw == null) {
  162. this.number(value);
  163. } else if (this.format.minified) {
  164. this.number(raw.length < value.length ? raw : value);
  165. } else {
  166. this.number(raw);
  167. }
  168. }
  169. function StringLiteral(node) {
  170. const raw = this.getPossibleRaw(node);
  171. if (!this.format.minified && raw != null) {
  172. this.token(raw);
  173. return;
  174. }
  175. const val = _jsesc(node.value, Object.assign(this.format.jsescOption, this.format.jsonCompatibleStrings && {
  176. json: true
  177. }));
  178. return this.token(val);
  179. }
  180. function BigIntLiteral(node) {
  181. const raw = this.getPossibleRaw(node);
  182. if (!this.format.minified && raw != null) {
  183. this.word(raw);
  184. return;
  185. }
  186. this.word(node.value + "n");
  187. }
  188. function DecimalLiteral(node) {
  189. const raw = this.getPossibleRaw(node);
  190. if (!this.format.minified && raw != null) {
  191. this.word(raw);
  192. return;
  193. }
  194. this.word(node.value + "m");
  195. }
  196. function PipelineTopicExpression(node) {
  197. this.print(node.expression, node);
  198. }
  199. function PipelineBareFunction(node) {
  200. this.print(node.callee, node);
  201. }
  202. function PipelinePrimaryTopicReference() {
  203. this.token("#");
  204. }