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.

inspect.cjs 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. const util_1 = require("../util.cjs");
  6. const zeroWidth = {
  7. line: 0,
  8. start: 0,
  9. delimiter: 0,
  10. postDelimiter: 0,
  11. tag: 0,
  12. postTag: 0,
  13. name: 0,
  14. postName: 0,
  15. type: 0,
  16. postType: 0,
  17. description: 0,
  18. end: 0,
  19. lineEnd: 0
  20. };
  21. const headers = {
  22. lineEnd: 'CR'
  23. };
  24. const fields = Object.keys(zeroWidth);
  25. const repr = x => util_1.isSpace(x) ? `{${x.length}}` : x;
  26. const frame = line => '|' + line.join('|') + '|';
  27. const align = (width, tokens) => Object.keys(tokens).map(k => repr(tokens[k]).padEnd(width[k]));
  28. function inspect({
  29. source
  30. }) {
  31. var _a, _b;
  32. if (source.length === 0) return '';
  33. const width = Object.assign({}, zeroWidth);
  34. for (const f of fields) width[f] = ((_a = headers[f]) !== null && _a !== void 0 ? _a : f).length;
  35. for (const {
  36. number,
  37. tokens
  38. } of source) {
  39. width.line = Math.max(width.line, number.toString().length);
  40. for (const k in tokens) width[k] = Math.max(width[k], repr(tokens[k]).length);
  41. }
  42. const lines = [[], []];
  43. for (const f of fields) lines[0].push(((_b = headers[f]) !== null && _b !== void 0 ? _b : f).padEnd(width[f]));
  44. for (const f of fields) lines[1].push('-'.padEnd(width[f], '-'));
  45. for (const {
  46. number,
  47. tokens
  48. } of source) {
  49. const line = number.toString().padStart(width.line);
  50. lines.push([line, ...align(width, tokens)]);
  51. }
  52. return lines.map(frame).join('\n');
  53. }
  54. exports.default = inspect;
  55. //# sourceMappingURL=inspect.cjs.map