estree-walker

WebJar for estree-walker

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

estree-walker
Последняя версия

Последняя версия

2.0.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

estree-walker
WebJar for estree-walker
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/Rich-Harris/estree-walker

Скачать estree-walker

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/estree-walker/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>estree-walker</artifactId>
    <version>2.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/estree-walker/
implementation 'org.webjars.npm:estree-walker:2.0.2'
// https://jarcasting.com/artifacts/org.webjars.npm/estree-walker/
implementation ("org.webjars.npm:estree-walker:2.0.2")
'org.webjars.npm:estree-walker:jar:2.0.2'
<dependency org="org.webjars.npm" name="estree-walker" rev="2.0.2">
  <artifact name="estree-walker" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='estree-walker', version='2.0.2')
)
libraryDependencies += "org.webjars.npm" % "estree-walker" % "2.0.2"
[org.webjars.npm/estree-walker "2.0.2"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

estree-walker

Simple utility for walking an ESTree-compliant AST, such as one generated by acorn.

Installation

npm i estree-walker

Usage

var walk = require('estree-walker').walk;
var acorn = require('acorn');

ast = acorn.parse(sourceCode, options); // https://github.com/acornjs/acorn

walk(ast, {
  enter(node, parent, prop, index) {
    // some code happens
  },
  leave(node, parent, prop, index) {
    // some code happens
  }
});

Inside the enter function, calling this.skip() will prevent the node's children being walked, or the leave function (which is optional) being called.

Call this.replace(new_node) in either enter or leave to replace the current node with a new one.

Call this.remove() in either enter or leave to remove the current node.

Why not use estraverse?

The ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where estraverse was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys.

estree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.)

None of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful.

License

MIT

Версии библиотеки

Версия
2.0.2
2.0.1
0.8.1
0.6.1
0.6.0
0.5.2
0.5.1
0.3.1