yuku-parser 0.5.37 → 0.5.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/package.json +13 -13
  3. package/walk.js +1 -8
package/README.md CHANGED
@@ -73,7 +73,7 @@ Lines are 1-based and columns are 0-based, matching ESTree's `loc` convention. T
73
73
 
74
74
  ## Walking the AST
75
75
 
76
- A typed, mutating walker is built in. Handlers are keyed by node type and receive the exact node type, as a bare enter function or an enter/leave pair:
76
+ A typed, mutating walker is built in:
77
77
 
78
78
  ```ts
79
79
  import { parse, walk } from "yuku-parser";
@@ -108,7 +108,7 @@ walk(program, {
108
108
  });
109
109
  ```
110
110
 
111
- `ctx.replace(node)` continues the walk into the replacement, `ctx.remove()` skips the removed subtree, `ctx.insertBefore(node)` inserts a sibling without visiting it, and `ctx.insertAfter(node)` inserts one the walk will visit. A replacement created with `start: 0, end: 0` inherits the original span, which keeps source maps meaningful through [`yuku-codegen`](https://www.npmjs.com/package/yuku-codegen). An optional third argument threads state to every handler as `ctx.state`.
111
+ `ctx.replace(node)` continues the walk into the replacement, `ctx.remove()` skips the removed subtree, `ctx.insertBefore(node)` inserts a sibling without visiting it, and `ctx.insertAfter(node)` inserts one the walk will visit. An optional third argument threads state to every handler as `ctx.state`.
112
112
 
113
113
  The AST is also standard ESTree, so any ESTree-compatible walker works as well.
114
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuku-parser",
3
- "version": "0.5.37",
3
+ "version": "0.5.39",
4
4
  "description": "High-performance JavaScript/TypeScript parser",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,20 +18,20 @@
18
18
  "walk.js"
19
19
  ],
20
20
  "optionalDependencies": {
21
- "@yuku-parser/binding-linux-x64-gnu": "0.5.37",
22
- "@yuku-parser/binding-linux-arm64-gnu": "0.5.37",
23
- "@yuku-parser/binding-linux-arm-gnu": "0.5.37",
24
- "@yuku-parser/binding-linux-x64-musl": "0.5.37",
25
- "@yuku-parser/binding-linux-arm64-musl": "0.5.37",
26
- "@yuku-parser/binding-linux-arm-musl": "0.5.37",
27
- "@yuku-parser/binding-darwin-x64": "0.5.37",
28
- "@yuku-parser/binding-darwin-arm64": "0.5.37",
29
- "@yuku-parser/binding-win32-x64": "0.5.37",
30
- "@yuku-parser/binding-win32-arm64": "0.5.37",
31
- "@yuku-parser/binding-freebsd-x64": "0.5.37"
21
+ "@yuku-parser/binding-linux-x64-gnu": "0.5.39",
22
+ "@yuku-parser/binding-linux-arm64-gnu": "0.5.39",
23
+ "@yuku-parser/binding-linux-arm-gnu": "0.5.39",
24
+ "@yuku-parser/binding-linux-x64-musl": "0.5.39",
25
+ "@yuku-parser/binding-linux-arm64-musl": "0.5.39",
26
+ "@yuku-parser/binding-linux-arm-musl": "0.5.39",
27
+ "@yuku-parser/binding-darwin-x64": "0.5.39",
28
+ "@yuku-parser/binding-darwin-arm64": "0.5.39",
29
+ "@yuku-parser/binding-win32-x64": "0.5.39",
30
+ "@yuku-parser/binding-win32-arm64": "0.5.39",
31
+ "@yuku-parser/binding-freebsd-x64": "0.5.39"
32
32
  },
33
33
  "dependencies": {
34
- "@yuku-toolchain/types": "0.5.32"
34
+ "@yuku-toolchain/types": "0.5.37"
35
35
  },
36
36
  "keywords": [
37
37
  "acorn",
package/walk.js CHANGED
@@ -55,8 +55,7 @@ export class WalkContext {
55
55
  this._removed = true;
56
56
  }
57
57
  insertBefore(node) {
58
- // advance past the insert so the current node keeps its turn and the
59
- // new sibling is not visited
58
+ // advance past the insert so the current node keeps its turn
60
59
  this.#insert(node, 0);
61
60
  this._frame.i++;
62
61
  }
@@ -86,10 +85,6 @@ function createDispatch(visitors) {
86
85
  return { enter, leave, typed: (type) => concrete.get(type) };
87
86
  }
88
87
 
89
- /**
90
- * Walk an AST depth-first, dispatching to typed visitors and mutating
91
- * in place. Returns the root.
92
- */
93
88
  export function walk(root, visitors, state) {
94
89
  _walk(root, visitors, state, new WalkContext());
95
90
  return root;
@@ -107,8 +102,6 @@ export function _walk(root, visitors, state, ctx) {
107
102
  ctx._frame = frame;
108
103
  }
109
104
 
110
- // swaps the current node in its parent slot and continues the walk on
111
- // the replacement
112
105
  function applyReplace(parent, key, list, frame) {
113
106
  const next = ctx._replacement;
114
107
  ctx._replacement = null;