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.

indent.js 1.3KB

1234567891011121314151617181920212223242526272829303132
  1. var __rest = (this && this.__rest) || function (s, e) {
  2. var t = {};
  3. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4. t[p] = s[p];
  5. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  6. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  7. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  8. t[p[i]] = s[p[i]];
  9. }
  10. return t;
  11. };
  12. import { rewireSource } from '../util.js';
  13. const pull = (offset) => (str) => str.slice(offset);
  14. const push = (offset) => {
  15. const space = ''.padStart(offset, ' ');
  16. return (str) => str + space;
  17. };
  18. export default function indent(pos) {
  19. let shift;
  20. const pad = (start) => {
  21. if (shift === undefined) {
  22. const offset = pos - start.length;
  23. shift = offset > 0 ? push(offset) : pull(-offset);
  24. }
  25. return shift(start);
  26. };
  27. const update = (line) => (Object.assign(Object.assign({}, line), { tokens: Object.assign(Object.assign({}, line.tokens), { start: pad(line.tokens.start) }) }));
  28. return (_a) => {
  29. var { source } = _a, fields = __rest(_a, ["source"]);
  30. return rewireSource(Object.assign(Object.assign({}, fields), { source: source.map(update) }));
  31. };
  32. }