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.

isMap.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. 'use strict';
  2. /** @typedef {import('postcss-value-parser').Node} ValueNode */
  3. /**
  4. * @param {ValueNode | undefined} valueNode
  5. * @returns {boolean}
  6. */
  7. module.exports = function (valueNode) {
  8. if (!valueNode) {
  9. return false;
  10. }
  11. if (valueNode.type !== 'function' || !valueNode.nodes || valueNode.value) {
  12. return false;
  13. }
  14. // It's necessary to remove comments and spaces if they are present
  15. const cleanNodes = valueNode.nodes.filter(
  16. (node) => node.type !== 'comment' && node.type !== 'space',
  17. );
  18. // Map without comments and spaces will have the structure like $map (prop: value, prop2: value)
  19. // ↑ ↑ ↑ ↑
  20. // 0 1 2 3
  21. if (cleanNodes[0] && cleanNodes[0].type !== 'word' && cleanNodes[0].type !== 'string') {
  22. return false;
  23. }
  24. if (cleanNodes[1] && cleanNodes[1].value !== ':') {
  25. return false;
  26. }
  27. // There is no need to check type or value of this node since it could be anything
  28. if (!cleanNodes[2]) {
  29. return false;
  30. }
  31. if (cleanNodes[3] && cleanNodes[3].value !== ',') {
  32. return false;
  33. }
  34. return true;
  35. };