Socket
Socket
Sign inDemoInstall

estraverse

Package Overview
Dependencies
0
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    estraverse

ECMAScript JS AST traversal functions


Version published
Weekly downloads
86M
decreased by-0.97%
Maintainers
3
Install size
33.0 kB
Created
Weekly downloads
 

Package description

What is estraverse?

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.

What are estraverse's main functionalities?

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;
    }
  }
});

Other packages similar to estraverse

FAQs

Last updated on 10 Mar 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc