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.

methods.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports._params = _params;
  6. exports._parameters = _parameters;
  7. exports._param = _param;
  8. exports._methodHead = _methodHead;
  9. exports._predicate = _predicate;
  10. exports._functionHead = _functionHead;
  11. exports.FunctionDeclaration = exports.FunctionExpression = FunctionExpression;
  12. exports.ArrowFunctionExpression = ArrowFunctionExpression;
  13. var t = require("@babel/types");
  14. function _params(node) {
  15. this.print(node.typeParameters, node);
  16. this.token("(");
  17. this._parameters(node.params, node);
  18. this.token(")");
  19. this.print(node.returnType, node);
  20. }
  21. function _parameters(parameters, parent) {
  22. for (let i = 0; i < parameters.length; i++) {
  23. this._param(parameters[i], parent);
  24. if (i < parameters.length - 1) {
  25. this.token(",");
  26. this.space();
  27. }
  28. }
  29. }
  30. function _param(parameter, parent) {
  31. this.printJoin(parameter.decorators, parameter);
  32. this.print(parameter, parent);
  33. if (parameter.optional) this.token("?");
  34. this.print(parameter.typeAnnotation, parameter);
  35. }
  36. function _methodHead(node) {
  37. const kind = node.kind;
  38. const key = node.key;
  39. if (kind === "get" || kind === "set") {
  40. this.word(kind);
  41. this.space();
  42. }
  43. if (node.async) {
  44. this._catchUp("start", key.loc);
  45. this.word("async");
  46. this.space();
  47. }
  48. if (kind === "method" || kind === "init") {
  49. if (node.generator) {
  50. this.token("*");
  51. }
  52. }
  53. if (node.computed) {
  54. this.token("[");
  55. this.print(key, node);
  56. this.token("]");
  57. } else {
  58. this.print(key, node);
  59. }
  60. if (node.optional) {
  61. this.token("?");
  62. }
  63. this._params(node);
  64. }
  65. function _predicate(node) {
  66. if (node.predicate) {
  67. if (!node.returnType) {
  68. this.token(":");
  69. }
  70. this.space();
  71. this.print(node.predicate, node);
  72. }
  73. }
  74. function _functionHead(node) {
  75. if (node.async) {
  76. this.word("async");
  77. this.space();
  78. }
  79. this.word("function");
  80. if (node.generator) this.token("*");
  81. this.space();
  82. if (node.id) {
  83. this.print(node.id, node);
  84. }
  85. this._params(node);
  86. this._predicate(node);
  87. }
  88. function FunctionExpression(node) {
  89. this._functionHead(node);
  90. this.space();
  91. this.print(node.body, node);
  92. }
  93. function ArrowFunctionExpression(node) {
  94. if (node.async) {
  95. this.word("async");
  96. this.space();
  97. }
  98. const firstParam = node.params[0];
  99. if (!this.format.retainLines && !this.format.auxiliaryCommentBefore && !this.format.auxiliaryCommentAfter && node.params.length === 1 && t.isIdentifier(firstParam) && !hasTypesOrComments(node, firstParam)) {
  100. this.print(firstParam, node);
  101. } else {
  102. this._params(node);
  103. }
  104. this._predicate(node);
  105. this.space();
  106. this.token("=>");
  107. this.space();
  108. this.print(node.body, node);
  109. }
  110. function hasTypesOrComments(node, param) {
  111. var _param$leadingComment, _param$trailingCommen;
  112. return !!(node.typeParameters || node.returnType || node.predicate || param.typeAnnotation || param.optional || (_param$leadingComment = param.leadingComments) != null && _param$leadingComment.length || (_param$trailingCommen = param.trailingComments) != null && _param$trailingCommen.length);
  113. }