๐Ÿ“ฆ EdwonLim / node-less

๐Ÿ“„ value.js ยท 31 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31(function (module) {

    var Value = function (value) {
        this.value = value;
    };

    Value.prototype = {
        type: "Value",
        accept: function (visitor) {
            this.value = visitor.visit(this.value);
        },
        eval: function (env) {
            if (this.value.length === 1) {
                return this.value[0].eval(env);
            } else {
                return new Value(this.value.map(function (v) {
                    return v.eval(env);
                }));
            }
        },
        toCSS: function (env) {
            return this.value.map(function (e) {
                return e.toCSS(env);
            }).join(env.compress ? ',' : ', ');
        }
    };

    module.exports = Value;

})(module);