/usr/lib/nodejs/less/visitor.js is in node-less 1.4.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | (function (tree) {
tree.visitor = function(implementation) {
this._implementation = implementation;
};
tree.visitor.prototype = {
visit: function(node) {
if (node instanceof Array) {
return this.visitArray(node);
}
if (!node || !node.type) {
return node;
}
var funcName = "visit" + node.type,
func = this._implementation[funcName],
visitArgs, newNode;
if (func) {
visitArgs = {visitDeeper: true};
newNode = func.call(this._implementation, node, visitArgs);
if (this._implementation.isReplacing) {
node = newNode;
}
}
if ((!visitArgs || visitArgs.visitDeeper) && node && node.accept) {
node.accept(this);
}
funcName = funcName + "Out";
if (this._implementation[funcName]) {
this._implementation[funcName](node);
}
return node;
},
visitArray: function(nodes) {
var i, newNodes = [];
for(i = 0; i < nodes.length; i++) {
var evald = this.visit(nodes[i]);
if (evald instanceof Array) {
newNodes = newNodes.concat(evald);
} else {
newNodes.push(evald);
}
}
if (this._implementation.isReplacing) {
return newNodes;
}
return nodes;
}
};
})(require('./tree'));
|