source: frontend/node_modules/postcss-ordered-values/src/lib/getValue.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 876 bytes
RevLine 
[9af201e]1'use strict';
2const { stringify } = require('postcss-value-parser');
3
4/**
5 * @param {import('postcss-value-parser').Node[][]} values
6 * @return {string}
7 */
8module.exports = function getValue(values) {
9 return stringify(flatten(values));
10};
11/**
12 * @param {import('postcss-value-parser').Node[][]} values
13 * @return {import('postcss-value-parser').Node[]}
14 */
15function flatten(values) {
16 /** @type {import('postcss-value-parser').Node[]} */
17 const nodes = [];
18 for (const [index, arg] of values.entries()) {
19 arg.forEach((val, idx) => {
20 if (
21 idx === arg.length - 1 &&
22 index === values.length - 1 &&
23 val.type === 'space'
24 ) {
25 return;
26 }
27 nodes.push(val);
28 });
29
30 if (index !== values.length - 1) {
31 nodes[nodes.length - 1].type = 'div';
32 nodes[nodes.length - 1].value = ',';
33 }
34 }
35 return nodes;
36}
Note: See TracBrowser for help on using the repository browser.