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.

interpolation.js 852B

12345678910111213141516171819202122232425262728293031323334
  1. /* eslint no-param-reassign: off */
  2. module.exports = {
  3. interpolation(token) {
  4. let first = token;
  5. const tokens = [token];
  6. const validTypes = ['word', '{', '}'];
  7. token = this.tokenizer.nextToken();
  8. // look for @{ but not @[word]{
  9. if (first[1].length > 1 || token[0] !== '{') {
  10. this.tokenizer.back(token);
  11. return false;
  12. }
  13. while (token && validTypes.includes(token[0])) {
  14. tokens.push(token);
  15. token = this.tokenizer.nextToken();
  16. }
  17. const words = tokens.map((tokn) => tokn[1]);
  18. [first] = tokens;
  19. const last = tokens.pop();
  20. const start = [first[2], first[3]];
  21. const end = [last[4] || last[2], last[5] || last[3]];
  22. const newToken = ['word', words.join('')].concat(start, end);
  23. this.tokenizer.back(token);
  24. this.tokenizer.back(newToken);
  25. return true;
  26. }
  27. };