mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-02 13:29:30 +08:00
36 lines
876 B
Text
36 lines
876 B
Text
'use strict';
|
|
const { stringify } = require('postcss-value-parser');
|
|
|
|
/**
|
|
* @param {import('postcss-value-parser').Node[][]} values
|
|
* @return {string}
|
|
*/
|
|
module.exports = function getValue(values) {
|
|
return stringify(flatten(values));
|
|
};
|
|
/**
|
|
* @param {import('postcss-value-parser').Node[][]} values
|
|
* @return {import('postcss-value-parser').Node[]}
|
|
*/
|
|
function flatten(values) {
|
|
/** @type {import('postcss-value-parser').Node[]} */
|
|
const nodes = [];
|
|
for (const [index, arg] of values.entries()) {
|
|
arg.forEach((val, idx) => {
|
|
if (
|
|
idx === arg.length - 1 &&
|
|
index === values.length - 1 &&
|
|
val.type === 'space'
|
|
) {
|
|
return;
|
|
}
|
|
nodes.push(val);
|
|
});
|
|
|
|
if (index !== values.length - 1) {
|
|
nodes[nodes.length - 1].type = 'div';
|
|
nodes[nodes.length - 1].value = ',';
|
|
}
|
|
}
|
|
return nodes;
|
|
}
|