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.

align.cjs 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. "use strict";
  2. var __rest = this && this.__rest || function (s, e) {
  3. var t = {};
  4. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  5. if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  6. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  7. }
  8. return t;
  9. };
  10. Object.defineProperty(exports, "__esModule", {
  11. value: true
  12. });
  13. const primitives_1 = require("../primitives.cjs");
  14. const util_1 = require("../util.cjs");
  15. const zeroWidth = {
  16. start: 0,
  17. tag: 0,
  18. type: 0,
  19. name: 0
  20. };
  21. const getWidth = (w, {
  22. tokens: t
  23. }) => ({
  24. start: t.delimiter === primitives_1.Markers.start ? t.start.length : w.start,
  25. tag: Math.max(w.tag, t.tag.length),
  26. type: Math.max(w.type, t.type.length),
  27. name: Math.max(w.name, t.name.length)
  28. });
  29. const space = len => ''.padStart(len, ' ');
  30. function align() {
  31. let intoTags = false;
  32. let w;
  33. function update(line) {
  34. const tokens = Object.assign({}, line.tokens);
  35. if (tokens.tag !== '') intoTags = true;
  36. const isEmpty = tokens.tag === '' && tokens.name === '' && tokens.type === '' && tokens.description === ''; // dangling '*/'
  37. if (tokens.end === primitives_1.Markers.end && isEmpty) {
  38. tokens.start = space(w.start + 1);
  39. return Object.assign(Object.assign({}, line), {
  40. tokens
  41. });
  42. }
  43. switch (tokens.delimiter) {
  44. case primitives_1.Markers.start:
  45. tokens.start = space(w.start);
  46. break;
  47. case primitives_1.Markers.delim:
  48. tokens.start = space(w.start + 1);
  49. break;
  50. default:
  51. tokens.delimiter = '';
  52. tokens.start = space(w.start + 2);
  53. // compensate delimiter
  54. }
  55. if (!intoTags) {
  56. tokens.postDelimiter = tokens.description === '' ? '' : ' ';
  57. return Object.assign(Object.assign({}, line), {
  58. tokens
  59. });
  60. }
  61. const nothingAfter = {
  62. delim: false,
  63. tag: false,
  64. type: false,
  65. name: false
  66. };
  67. if (tokens.description === '') {
  68. nothingAfter.name = true;
  69. tokens.postName = '';
  70. if (tokens.name === '') {
  71. nothingAfter.type = true;
  72. tokens.postType = '';
  73. if (tokens.type === '') {
  74. nothingAfter.tag = true;
  75. tokens.postTag = '';
  76. if (tokens.tag === '') {
  77. nothingAfter.delim = true;
  78. }
  79. }
  80. }
  81. }
  82. tokens.postDelimiter = nothingAfter.delim ? '' : ' ';
  83. if (!nothingAfter.tag) tokens.postTag = space(w.tag - tokens.tag.length + 1);
  84. if (!nothingAfter.type) tokens.postType = space(w.type - tokens.type.length + 1);
  85. if (!nothingAfter.name) tokens.postName = space(w.name - tokens.name.length + 1);
  86. return Object.assign(Object.assign({}, line), {
  87. tokens
  88. });
  89. }
  90. return _a => {
  91. var {
  92. source
  93. } = _a,
  94. fields = __rest(_a, ["source"]);
  95. w = source.reduce(getWidth, Object.assign({}, zeroWidth));
  96. return util_1.rewireSource(Object.assign(Object.assign({}, fields), {
  97. source: source.map(update)
  98. }));
  99. };
  100. }
  101. exports.default = align;
  102. //# sourceMappingURL=align.cjs.map