1 | function getValue(a) {
|
2 | let value;
|
3 | let i;
|
4 | switch (a.constructor.name) {
|
5 | case 'SassList':
|
6 | value = [];
|
7 | for (i = 0; i < a.getLength(); i++) {
|
8 | value.push(getValue(a.getValue(i)));
|
9 | }
|
10 | break;
|
11 | case 'SassMap':
|
12 | value = {};
|
13 | for (i = 0; i < a.getLength(); i++) {
|
14 | value[a.getKey(i).getValue()] = getValue(a.getValue(i));
|
15 | }
|
16 | break;
|
17 | case 'SassColor':
|
18 | if (a.getA() === 1) {
|
19 | value = `rgb(${Math.round(a.getR())}, ${Math.round(
|
20 | a.getG(),
|
21 | )}, ${Math.round(a.getB())})`;
|
22 | } else {
|
23 | value = `rgba(${Math.round(a.getR())}, ${Math.round(
|
24 | a.getG(),
|
25 | )}, ${Math.round(a.getB())}, ${a.getA()})`;
|
26 | }
|
27 | break;
|
28 | case 'SassNumber':
|
29 | value = a.getValue();
|
30 | if (a.getUnit()) {
|
31 | value += a.getUnit();
|
32 | }
|
33 | break;
|
34 | default:
|
35 | value = a.getValue();
|
36 | }
|
37 | return value;
|
38 | }
|
39 |
|
40 | module.exports = getValue;
|