代码拉取完成,页面将自动刷新
'use strict';
const walk = require('acorn/dist/walk');
// inspect traverses the AST starting at node, calling found with each Identifier AST node it encounters.
const inspect = (ast, found) => {
walk.simple(ast, {
Identifier: (node) => {
found(node);
},
VariableDeclarator: (node) => {
if(node.id.type === 'Identifier') found(node.id);
},
Function: (node) => {
if(node.id && node.id.type === 'Identifier') found(node.id);
for (let param of node.params) {
if(param.type === 'Identifier') found(param);
}
},
AssignmentExpression: (node) => {
if(node.left.type === 'Identifier') found(node.left);
},
ObjectPattern: (node) => {
for (let property of node.properties) {
if (property.value.type === 'Identifier') found(property.value);
}
},
ArrayPattern: (node) => {
for (let element of node.elements) {
if (element.type === 'Identifier') found(element);
}
},
});
};
// all traverses the AST starting at node and returns an array of all Identifier AST nodes it encounters.
const all = (node) => {
const idents = [];
inspect(node, (ident) => {
idents.push(ident);
});
return idents;
};
module.exports = {inspect, all}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。