/usr/lib/nodejs/estree-walker/index.js is in node-estree-walker 0.5.1-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 55 56 57 58 59 60 61 62 63 | 'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
exports.walk = walk;
function walk(ast, _ref) {
var enter = _ref.enter,
leave = _ref.leave;
visit(ast, null, enter, leave);
}
var shouldSkip = false;
var context = { skip: function skip() {
return shouldSkip = true;
} };
var childKeys = exports.childKeys = {};
var toString = Object.prototype.toString;
function isArray(thing) {
return toString.call(thing) === '[object Array]';
}
function visit(node, parent, enter, leave, prop, index) {
if (!node) return;
if (enter) {
var _shouldSkip = shouldSkip;
shouldSkip = false;
enter.call(context, node, parent, prop, index);
var skipped = shouldSkip;
shouldSkip = _shouldSkip;
if (skipped) return;
}
var keys = childKeys[node.type] || (childKeys[node.type] = Object.keys(node).filter(function (key) {
return _typeof(node[key]) === 'object';
}));
for (var i = 0; i < keys.length; i += 1) {
var key = keys[i];
var value = node[key];
if (isArray(value)) {
for (var j = 0; j < value.length; j += 1) {
visit(value[j], node, enter, leave, key, j);
}
} else if (value && value.type) {
visit(value, node, enter, leave, key, null);
}
}
if (leave) {
leave(node, parent, prop, index);
}
}
|