
Security News
Official Go SDK for MCP in Development, Stable Release Expected in August
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
estraverse
Advanced tools
The estraverse npm package is a utility for traversing and updating ECMAScript (JavaScript) abstract syntax trees (ASTs). It is commonly used in the development of JavaScript code analysis and transformation tools.
Traversing an AST
This feature allows you to traverse an AST, visiting all nodes in a depth-first order. You can perform actions when entering or leaving each node.
const estraverse = require('estraverse');
const ast = { /* some AST object */ };
estraverse.traverse(ast, {
enter: function (node) {
console.log('Entering node:', node.type);
},
leave: function (node) {
console.log('Leaving node:', node.type);
}
});
Updating an AST
This feature allows you to update nodes in an AST during traversal. In this example, it renames identifiers from 'oldName' to 'newName'.
const estraverse = require('estraverse');
const ast = { /* some AST object */ };
estraverse.replace(ast, {
enter: function (node) {
if (node.type === 'Identifier' && node.name === 'oldName') {
node.name = 'newName';
return node;
}
}
});
Acorn is a tiny, fast JavaScript parser that produces an AST which can be used by tools like estraverse. While Acorn focuses on parsing, estraverse focuses on traversal and modification.
Babel-traverse is part of the Babel compiler ecosystem. It allows for traversing the Babel-generated AST and has more features specific to Babel's AST format, compared to estraverse which is more generic.
Esquery is a package for querying an AST using a CSS-like query syntax. It is different from estraverse in that it focuses on selecting nodes based on complex patterns rather than traversing every node.
Recast provides AST traversal and transformation capabilities, similar to estraverse, but also includes pretty-printing and source map support, which estraverse does not.
FAQs
ECMAScript JS AST traversal functions
The npm package estraverse receives a total of 116,184,920 weekly downloads. As such, estraverse popularity was classified as popular.
We found that estraverse demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.
Security News
New research reveals that LLMs often fake understanding, passing benchmarks but failing to apply concepts or stay internally consistent.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.