1.4.1 • Published 8 months ago

@nodesecure/estree-ast-utils v1.4.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

estree-ast-utils

version maintained OpenSSF
Scorecard mit build

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

Translate an ESTree ArrayExpression into an iterable of Literal value.

["foo", "bar"];

will return "foo" then "bar".

Return all Literal part of a given Binary Expression.

"foo" + "bar";

will return "foo" then "bar".

One of the options of the method is stopOnUnsupportedNode, if true it will throw an Error if the left or right side of the Expr is not a supported type.

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

foobar();

will return "foobar".

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

foo.bar();

will return "foo" then "bar".

Get all variables identifier name.

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

will return "foo" then "bar".

Return true if the given Node is a Literal Regex Node.

/^hello/g;

Contributors ✨

All Contributors

Thanks goes to these wonderful people (emoji key):

License

MIT

1.4.1

8 months ago

1.4.0

8 months ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.2.1

2 years ago

1.0.0

2 years ago