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.

description.cjs 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getJoiner = void 0;
  6. const primitives_1 = require("../../primitives.cjs");
  7. /**
  8. * Makes no changes to `spec.lines[].tokens` but joins them into `spec.description`
  9. * following given spacing srtategy
  10. * @param {Spacing} spacing tells how to handle the whitespace
  11. */
  12. function descriptionTokenizer(spacing = 'compact') {
  13. const join = getJoiner(spacing);
  14. return spec => {
  15. spec.description = join(spec.source);
  16. return spec;
  17. };
  18. }
  19. exports.default = descriptionTokenizer;
  20. function getJoiner(spacing) {
  21. if (spacing === 'compact') return compactJoiner;
  22. if (spacing === 'preserve') return preserveJoiner;
  23. return spacing;
  24. }
  25. exports.getJoiner = getJoiner;
  26. function compactJoiner(lines) {
  27. return lines.map(({
  28. tokens: {
  29. description
  30. }
  31. }) => description.trim()).filter(description => description !== '').join(' ');
  32. }
  33. const lineNo = (num, {
  34. tokens
  35. }, i) => tokens.type === '' ? num : i;
  36. const getDescription = ({
  37. tokens
  38. }) => (tokens.delimiter === '' ? tokens.start : tokens.postDelimiter.slice(1)) + tokens.description;
  39. function preserveJoiner(lines) {
  40. if (lines.length === 0) return ''; // skip the opening line with no description
  41. if (lines[0].tokens.description === '' && lines[0].tokens.delimiter === primitives_1.Markers.start) lines = lines.slice(1); // skip the closing line with no description
  42. const lastLine = lines[lines.length - 1];
  43. if (lastLine !== undefined && lastLine.tokens.description === '' && lastLine.tokens.end.endsWith(primitives_1.Markers.end)) lines = lines.slice(0, -1); // description starts at the last line of type definition
  44. lines = lines.slice(lines.reduce(lineNo, 0));
  45. return lines.map(getDescription).join('\n');
  46. }
  47. //# sourceMappingURL=description.cjs.map