
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
typhonjs-ast-walker
Advanced tools
Provides a simple Javascript AST traversal utility that traverses all nodes / children regardless of type.
Provides a simple Javascript AST traversal utility that traverses all nodes / children regardless of type.
A single method traverse
takes an AST object or array of nodes and a callback object which may contain two methods enterNode
and exitNode
which are invoked with the current node and the parent node respectively when entering and exiting a given node during traversal.
enterNode
may return a array of strings which provide a set of children keys to ignore or null
to skip traversing children keys entirely.
To install typhonjs-ast-walker
provide this entry in package.json
:
{
...
"dependencies": {
"typhonjs-ast-walker": "^0.2.0"
}
}
A simple example follows:
import walker from 'typhonjs-ast-walker';
const ast = .... // An AST tree.
walker.traverse(ast,
{
enterNode: (node, parent) =>
{
console.log(`walker - enterNode: ${node.type}`);
// Optional return statement to ignore specific children keys.
// return node.type === 'ClassBody' ? ['body'] : undefined;
// Optional return statement to ignore specific children keys or skip traversal entirely.
// return node.type === 'ClassBody' ? null : undefined;
},
exitNode: (node, parent) =>
{
console.log(`walker - exitNode: ${node.type}`);
}
});
Support for typhonjs-plugin-manager is also available and
when loading typhonjs-ast-walker
as a plugin it will automatically register event bindings on the plugin eventbus
with these event categories:
ast:walker:traverse
- invokes traverse
of the default walker.
Example typhonjs-plugin-manager
usage:
import PluginManager from 'typhonjs-plugin-manager';
import eventbus from 'backbone-esnext-eventbus';
const pluginManager = new PluginManager({ eventbus });
pluginManager.add({ name: typhonjs-ast-walker });
// This will automatically wire up typhonjs-ast-walker to the eventbus.
eventbus.trigger('ast:walker:traverse, ast,
{
enterNode: (node, parent) =>
{
console.log(`walker - enterNode: ${node.type}`);
},
exitNode: (node, parent) =>
{
console.log(`walker - exitNode: ${node.type}`);
}
});
0.2.1 (2017-03-10)
typhonjs:ast:walker:traverse
.FAQs
Provides a simple Javascript AST traversal utility that traverses all nodes / children regardless of type.
The npm package typhonjs-ast-walker receives a total of 17,918 weekly downloads. As such, typhonjs-ast-walker popularity was classified as popular.
We found that typhonjs-ast-walker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.