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.

util.cjs 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.rewireSpecs = exports.rewireSource = exports.seedTokens = exports.seedSpec = exports.seedBlock = exports.splitLines = exports.splitSpace = exports.splitCR = exports.hasCR = exports.isSpace = void 0;
  6. function isSpace(source) {
  7. return /^\s+$/.test(source);
  8. }
  9. exports.isSpace = isSpace;
  10. function hasCR(source) {
  11. return /\r$/.test(source);
  12. }
  13. exports.hasCR = hasCR;
  14. function splitCR(source) {
  15. const matches = source.match(/\r+$/);
  16. return matches == null ? ['', source] : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)];
  17. }
  18. exports.splitCR = splitCR;
  19. function splitSpace(source) {
  20. const matches = source.match(/^\s+/);
  21. return matches == null ? ['', source] : [source.slice(0, matches[0].length), source.slice(matches[0].length)];
  22. }
  23. exports.splitSpace = splitSpace;
  24. function splitLines(source) {
  25. return source.split(/\n/);
  26. }
  27. exports.splitLines = splitLines;
  28. function seedBlock(block = {}) {
  29. return Object.assign({
  30. description: '',
  31. tags: [],
  32. source: [],
  33. problems: []
  34. }, block);
  35. }
  36. exports.seedBlock = seedBlock;
  37. function seedSpec(spec = {}) {
  38. return Object.assign({
  39. tag: '',
  40. name: '',
  41. type: '',
  42. optional: false,
  43. description: '',
  44. problems: [],
  45. source: []
  46. }, spec);
  47. }
  48. exports.seedSpec = seedSpec;
  49. function seedTokens(tokens = {}) {
  50. return Object.assign({
  51. start: '',
  52. delimiter: '',
  53. postDelimiter: '',
  54. tag: '',
  55. postTag: '',
  56. name: '',
  57. postName: '',
  58. type: '',
  59. postType: '',
  60. description: '',
  61. end: '',
  62. lineEnd: ''
  63. }, tokens);
  64. }
  65. exports.seedTokens = seedTokens;
  66. /**
  67. * Assures Block.tags[].source contains references to the Block.source items,
  68. * using Block.source as a source of truth. This is a counterpart of rewireSpecs
  69. * @param block parsed coments block
  70. */
  71. function rewireSource(block) {
  72. const source = block.source.reduce((acc, line) => acc.set(line.number, line), new Map());
  73. for (const spec of block.tags) {
  74. spec.source = spec.source.map(line => source.get(line.number));
  75. }
  76. return block;
  77. }
  78. exports.rewireSource = rewireSource;
  79. /**
  80. * Assures Block.source contains references to the Block.tags[].source items,
  81. * using Block.tags[].source as a source of truth. This is a counterpart of rewireSource
  82. * @param block parsed coments block
  83. */
  84. function rewireSpecs(block) {
  85. const source = block.tags.reduce((acc, spec) => spec.source.reduce((acc, line) => acc.set(line.number, line), acc), new Map());
  86. block.source = block.source.map(line => source.get(line.number) || line);
  87. return block;
  88. }
  89. exports.rewireSpecs = rewireSpecs;
  90. //# sourceMappingURL=util.cjs.map