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.

isFirstNested.js 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. 'use strict';
  2. const { isComment, hasSource } = require('./typeGuards');
  3. /**
  4. * @param {import('postcss').Node} statement
  5. * @returns {boolean}
  6. */
  7. module.exports = function (statement) {
  8. const parentNode = statement.parent;
  9. if (parentNode === undefined || parentNode.type === 'root') {
  10. return false;
  11. }
  12. if (statement === parentNode.first) {
  13. return true;
  14. }
  15. /*
  16. * Search for the statement in the parent's nodes, ignoring comment
  17. * nodes on the same line as the parent's opening brace.
  18. */
  19. const parentNodes = parentNode.nodes;
  20. if (!parentNodes) {
  21. return false;
  22. }
  23. const firstNode = parentNodes[0];
  24. if (
  25. !isComment(firstNode) ||
  26. (typeof firstNode.raws.before === 'string' && firstNode.raws.before.includes('\n'))
  27. ) {
  28. return false;
  29. }
  30. if (!hasSource(firstNode) || !firstNode.source.start) {
  31. return false;
  32. }
  33. const openingBraceLine = firstNode.source.start.line;
  34. if (!firstNode.source.end || openingBraceLine !== firstNode.source.end.line) {
  35. return false;
  36. }
  37. for (let i = 1; i < parentNodes.length; i++) {
  38. const node = parentNodes[i];
  39. if (node === statement) {
  40. return true;
  41. }
  42. if (
  43. !isComment(node) ||
  44. (hasSource(node) && node.source.end && node.source.end.line !== openingBraceLine)
  45. ) {
  46. return false;
  47. }
  48. }
  49. /* istanbul ignore next: Should always return in the loop */
  50. return false;
  51. };