Socket
Socket
Sign inDemoInstall

babel-traverse

Package Overview
Dependencies
23
Maintainers
5
Versions
78
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-traverse

The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes


Version published
Weekly downloads
2.4M
decreased by-21.09%
Maintainers
5
Install size
4.34 MB
Created
Weekly downloads
 

Readme

Source

babel-traverse

babel-traverse maintains the overall tree state, and is responsible for replacing, removing, and adding nodes.

Install

$ npm install --save babel-traverse

Usage

We can use it alongside Babylon to traverse and update nodes:

import * as babylon from "babylon";
import traverse from "babel-traverse";

const code = `function square(n) {
  return n * n;
}`;

const ast = babylon.parse(code);

traverse(ast, {
  enter(path) {
    if (path.isIdentifier({ name: "n" })) {
      path.node.name = "x";
    }
  }
});

:book: Read the full docs here

FAQs

Last updated on 16 Aug 2017

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