Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 17, 2024 via pnpm

acorn-walk 8.3.2

ECMAScript (ESTree) AST walker
Package summary
Share
0
issues
1
license
1
MIT
Package created
14 Sep 2018
Version published
11 Jan 2024
Maintainers
3
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
acorn-walk@8.3.2
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of acorn-walk 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does acorn-walk do?

Acorn-walk is an abstract syntax tree (AST) walker designed for the ESTree format. This package facilitates the recursion through a syntax tree by storing an algorithm as an object with respective properties for each tree node type. These properties, holding functions that persist through the node, allow Acorn-walk to walk over a tree and navigate through all statements and expressions. Acorn-walk provides varied ways with which you can run these walker operations.

How do you use acorn-walk?

To use Acorn-walk you will first need to install it, which can be easily done through npm by running the command npm install acorn-walk. After installation, you can require the package along with the acorn in your JavaScript file. Acorn-walk provides different methods for tree walking, for example:

Simple walk:

const acorn = require("acorn");
const walk = require("acorn-walk");

walk.simple(acorn.parse("let x = 10"), {
  Literal(node) {
    console.log(`Found a literal: ${node.value}`)
  }
});

Ancestor walk:

const acorn = require("acorn")
const walk = require("acorn-walk")

walk.ancestor(acorn.parse("foo('hi')"), {
  Literal(_, ancestors) {
    console.log("This literal's ancestors are:", ancestors.map(n => n.type))
  }
})

Full walk:


const acorn = require("acorn")
const walk = require("acorn-walk")

walk.full(acorn.parse("1 + 1"), node => {
  console.log(`There's a ${node.type} node at ${node.ch}`)
})

Each method functions differently according to the node and returning state as specified in the examples above.

Where are the acorn-walk docs?

For the detailed documentation on Acorn-walk, you can refer to the Acorn GitHub repository. Here you will find the comprehensive interface of the package along with guides and examples on how to interact with Acorn-walk. Further discussions, questions and bug reports are welcomed on Acorn's GitHub repository issues page or on the Tern discussion forum.