Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

estraverse

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

estraverse

ECMAScript JS AST traversal functions

  • 5.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
105M
increased by23.49%
Maintainers
3
Weekly downloads
 
Created

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

Package last updated on 25 Oct 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc