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

estree-util-visit

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

estree-util-visit

esast (and estree) utility to visit nodes

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is estree-util-visit?

The estree-util-visit package is a utility for visiting nodes in an ESTree-compliant AST (Abstract Syntax Tree). It provides a simple way to traverse and manipulate JavaScript code structures programmatically, which is useful in tasks such as code analysis, transformation, and optimization.

What are estree-util-visit's main functionalities?

Node Traversal

This feature allows you to traverse the AST nodes. The 'enter' method is called for each node in the tree, where you can perform actions like logging node types or modifying nodes.

import {visit} from 'estree-util-visit';

visit(tree, {
  enter(node) {
    console.log(node.type);
  }
});

Selective Traversal

This feature enables traversal of specific types of nodes. In this example, it logs the names of all function declarations, allowing targeted analysis or transformations.

import {visit} from 'estree-util-visit';

visit(tree, {
  enter(node) {
    if (node.type === 'FunctionDeclaration') {
      console.log('Function name:', node.id.name);
    }
  }
});

Skip Subtree

This feature allows you to skip the traversal of a subtree. If a function declaration is encountered, its body is skipped, optimizing traversal by avoiding unnecessary nodes.

import {visit} from 'estree-util-visit';

visit(tree, {
  enter(node, ancestors) {
    if (node.type === 'FunctionDeclaration') {
      return visit.SKIP;
    }
  }
});

Other packages similar to estree-util-visit

Keywords

FAQs

Package last updated on 19 Jul 2023

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