source: trip-planner-front/node_modules/postcss-value-parser/lib/stringify.js@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[6a3a178]1function stringifyNode(node, custom) {
2 var type = node.type;
3 var value = node.value;
4 var buf;
5 var customResult;
6
7 if (custom && (customResult = custom(node)) !== undefined) {
8 return customResult;
9 } else if (type === "word" || type === "space") {
10 return value;
11 } else if (type === "string") {
12 buf = node.quote || "";
13 return buf + value + (node.unclosed ? "" : buf);
14 } else if (type === "comment") {
15 return "/*" + value + (node.unclosed ? "" : "*/");
16 } else if (type === "div") {
17 return (node.before || "") + value + (node.after || "");
18 } else if (Array.isArray(node.nodes)) {
19 buf = stringify(node.nodes, custom);
20 if (type !== "function") {
21 return buf;
22 }
23 return (
24 value +
25 "(" +
26 (node.before || "") +
27 buf +
28 (node.after || "") +
29 (node.unclosed ? "" : ")")
30 );
31 }
32 return value;
33}
34
35function stringify(nodes, custom) {
36 var result, i;
37
38 if (Array.isArray(nodes)) {
39 result = "";
40 for (i = nodes.length - 1; ~i; i -= 1) {
41 result = stringifyNode(nodes[i], custom) + result;
42 }
43 return result;
44 }
45 return stringifyNode(nodes, custom);
46}
47
48module.exports = stringify;
Note: See TracBrowser for help on using the repository browser.