/
lostSun
/
project-client-server-apps
Обзор
Документация
Войти
/
lostSun
/
project-client-server-apps
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
node_modules/postcss-ordered-values/src/rules/columns.js
39 строк
902 B
1lostsun
initial commit
05 май 2025, 11:35
05 май 2025, 11:35
fe8f535
Код
Авторство
О чём код?
'use strict'; const { unit } = require('postcss-value-parser'); /** * @param {string} value * @return {boolean} */ function hasUnit(value) { const parsedVal = unit(value); return parsedVal && parsedVal.unit !== ''; } /** * @param {import('postcss-value-parser').ParsedValue} columns * @return {import('postcss-value-parser').ParsedValue | string} */ module.exports = (columns) => { /** @type {string[]} */ const widths = []; /** @type {string[]} */ const other = []; columns.walk((node) => { const { type, value } = node; if (type === 'word') { if (hasUnit(value)) { widths.push(value); } else { other.push(value); } } }); // only transform if declaration is not invalid or a single value if (other.length === 1 && widths.length === 1) { return `${widths[0].trimStart()} ${other[0].trimStart()}`; } return columns; };