@nodesecure/estree-ast-utils

Utilities for AST (ESTree compliant)


Keywords
estree, ast, utils
License
MIT
Install
npm install @nodesecure/estree-ast-utils@1.4.1

Documentation

estree-ast-utils

Utilities for AST (ESTree compliant)

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @nodesecure/estree-ast-utils
# or
$ yarn add @nodesecure/estree-ast-utils

Usage example

import { VariableTracer } from "@nodesecure/estree-ast-utils";

const tracer = new VariableTracer()
  .enableDefaultTracing();

const data = tracer.getDataFromIdentifier("identifier...here");
console.log(data);

API

arrayExpressionToString(node): IterableIterator< string >

Translate an ESTree ArrayExpression into an iterable of Literal value.

["foo", "bar"]

will return "foo" then "bar".

concatBinaryExpression(node): IterableIterator< string >

Return all Literal part of a given Binary Expression.

"foo" + "bar"

will return "foo" then "bar".

getCallExpressionIdentifier(node): string | null

Return the identifier name of the CallExpression (or null if there is none).

foobar()

will return "foobar".

getMemberExpressionIdentifier(node): IterableIterator< string >

Return the identifier name of the CallExpression (or null if there is none).

foo.bar()

will return "foo" then "bar".

getVariableDeclarationIdentifiers(node): IterableIterator< string >

Get all variables identifier name.

const [foo, bar] = [1, 2];

will return "foo" then "bar".

Contributors

All Contributors

Thanks goes to these wonderful people (emoji key):


Gentilhomme

💻 🛡️ ⚠️ 🐛

License

MIT