beforeBlockString.cjs 848 B

12345678910111213141516171819202122232425262728293031323334
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const typeGuards = require('./typeGuards.cjs');
  5. /**
  6. * @param {import('postcss').Container} statement
  7. * @param {{ noRawBefore: boolean }} options
  8. * @returns {string}
  9. */
  10. function beforeBlockString(statement, { noRawBefore } = { noRawBefore: false }) {
  11. let result = '';
  12. const before = statement.raws.before || '';
  13. if (!noRawBefore) {
  14. result += before;
  15. }
  16. if (typeGuards.isRule(statement)) {
  17. result += statement.selector;
  18. } else if (typeGuards.isAtRule(statement)) {
  19. result += `@${statement.name}${statement.raws.afterName || ''}${statement.params}`;
  20. } else {
  21. return '';
  22. }
  23. result += statement.raws.between || '';
  24. return result;
  25. }
  26. module.exports = beforeBlockString;