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.

getPreviousNonSharedLineCommentNode.js 864B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. const _ = require('lodash');
  3. /** @typedef {import('postcss').Node} Node */
  4. /**
  5. * @param {Node} node
  6. */
  7. function getNodeLine(node) {
  8. return _.get(node, 'source.start.line');
  9. }
  10. /**
  11. * @param {import('postcss').Node | void} node
  12. * @returns {Node | void}
  13. */
  14. module.exports = function getPreviousNonSharedLineCommentNode(node) {
  15. if (node === undefined) {
  16. return undefined;
  17. }
  18. const previousNode = node.prev();
  19. if (!previousNode || _.get(previousNode, 'type') !== 'comment') {
  20. return previousNode;
  21. }
  22. if (getNodeLine(node) === getNodeLine(previousNode)) {
  23. return getPreviousNonSharedLineCommentNode(previousNode);
  24. }
  25. const previousNode2 = previousNode.prev();
  26. if (previousNode2 && getNodeLine(previousNode) === getNodeLine(previousNode2)) {
  27. return getPreviousNonSharedLineCommentNode(previousNode);
  28. }
  29. return previousNode;
  30. };