zhouyang.xie d67a673a03 2.17.0 前端 Vue 化(P11 起步): app_frontEnd/web (Vue3+Vite6+TS, npm 从 npmmirror 装) 构建产物 release/web + serve.json web=28110 + cli web 组件 + 网关 /web 同源; 契约侧 Python 门与 Node 冒烟各 42/42 一致; 契约支持异步构建态 json_keys_any; 设计说明 §3.6; 文档/版本表同步 1 Minggu lalu
..
src d67a673a03 2.17.0 前端 Vue 化(P11 起步): app_frontEnd/web (Vue3+Vite6+TS, npm 从 npmmirror 装) 构建产物 release/web + serve.json web=28110 + cli web 组件 + 网关 /web 同源; 契约侧 Python 门与 Node 冒烟各 42/42 一致; 契约支持异步构建态 json_keys_any; 设计说明 §3.6; 文档/版本表同步 1 Minggu lalu
types d67a673a03 2.17.0 前端 Vue 化(P11 起步): app_frontEnd/web (Vue3+Vite6+TS, npm 从 npmmirror 装) 构建产物 release/web + serve.json web=28110 + cli web 组件 + 网关 /web 同源; 契约侧 Python 门与 Node 冒烟各 42/42 一致; 契约支持异步构建态 json_keys_any; 设计说明 §3.6; 文档/版本表同步 1 Minggu lalu
CHANGELOG.md d67a673a03 2.17.0 前端 Vue 化(P11 起步): app_frontEnd/web (Vue3+Vite6+TS, npm 从 npmmirror 装) 构建产物 release/web + serve.json web=28110 + cli web 组件 + 网关 /web 同源; 契约侧 Python 门与 Node 冒烟各 42/42 一致; 契约支持异步构建态 json_keys_any; 设计说明 §3.6; 文档/版本表同步 1 Minggu lalu
LICENSE d67a673a03 2.17.0 前端 Vue 化(P11 起步): app_frontEnd/web (Vue3+Vite6+TS, npm 从 npmmirror 装) 构建产物 release/web + serve.json web=28110 + cli web 组件 + 网关 /web 同源; 契约侧 Python 门与 Node 冒烟各 42/42 一致; 契约支持异步构建态 json_keys_any; 设计说明 §3.6; 文档/版本表同步 1 Minggu lalu
README.md d67a673a03 2.17.0 前端 Vue 化(P11 起步): app_frontEnd/web (Vue3+Vite6+TS, npm 从 npmmirror 装) 构建产物 release/web + serve.json web=28110 + cli web 组件 + 网关 /web 同源; 契约侧 Python 门与 Node 冒烟各 42/42 一致; 契约支持异步构建态 json_keys_any; 设计说明 §3.6; 文档/版本表同步 1 Minggu lalu
package.json d67a673a03 2.17.0 前端 Vue 化(P11 起步): app_frontEnd/web (Vue3+Vite6+TS, npm 从 npmmirror 装) 构建产物 release/web + serve.json web=28110 + cli web 组件 + 网关 /web 同源; 契约侧 Python 门与 Node 冒烟各 42/42 一致; 契约支持异步构建态 json_keys_any; 设计说明 §3.6; 文档/版本表同步 1 Minggu lalu

README.md

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: function ( node, parent, prop, index ) {
    // some code happens
  },
  leave: function ( 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