ast-monkey-traverse-with-lookahead 4.1.3 → 4.2.0

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.
package/CHANGELOG.md CHANGED
@@ -3,11 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## 4.1.0 (2025-10-15)
6
+ ## 4.2.0 (2026-08-19)
7
+
8
+ ### Bug Fixes
9
+
10
+ - rebase to correspond with declared types ([8105a8d](https://github.com/codsen/codsen/commit/8105a8da2ae4372278b3406a6d958fe797846ae3))
11
+ - resolve review findings REV-004 through REV-007 ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
12
+ - retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
13
+ - validate traversal callbacks ([0e08fd4](https://github.com/codsen/codsen/commit/0e08fd4ecd3c25503801dd74218a5c0df8c1dd40))
7
14
 
8
15
  ### Features
9
16
 
10
- - if value to be added is a number, keep it as is, don't stringify ([ce3e1a5](https://github.com/codsen/codsen/commit/ce3e1a525998ca3c0abf0142affef95b14cd1990))
17
+ - add codsen-glob and migrate glob consumers ([5595a2b](https://github.com/codsen/codsen/commit/5595a2b267eaa6cb60072d037aef00b7a28edd42))
18
+ - refresh the tooling and generate with the latest dependencies ([781f802](https://github.com/codsen/codsen/commit/781f802911066a82a4533b0e5a3fcbd742d0dd83))
19
+
20
+ ### Reverts
21
+
22
+ - Revert "Merge pull request #128 from codsen/release/npm-32198404552-1" ([5baeeaa](https://github.com/codsen/codsen/commit/5baeeaaa677b86f1eaa6396cadf3aea32b06416e)), closes [#128](https://github.com/codsen/codsen/issues/128)
23
+ - Revert "Merge pull request #127 from codsen/release/npm-32194020886-1" ([5f1e94d](https://github.com/codsen/codsen/commit/5f1e94deef910ce735266b16aeee08a76de7a862)), closes [#127](https://github.com/codsen/codsen/issues/127)
11
24
 
12
25
  ## 4.0.0 (2022-12-01)
13
26
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright © 2010-2025 Roy Revelt and other contributors
3
+ Copyright © 2010-2026 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -32,236 +32,30 @@ npm i ast-monkey-traverse-with-lookahead
32
32
  ## Quick Take
33
33
 
34
34
  ```js
35
- import { strict as assert } from "assert";
35
+ import { strict as assert } from "node:assert";
36
36
 
37
37
  import { traverse } from "ast-monkey-traverse-with-lookahead";
38
38
 
39
- const input = [
40
- {
41
- a: "b",
42
- },
43
- {
44
- c: "d",
45
- },
46
- {
47
- e: "f",
48
- },
49
- ];
50
- const gathered = [];
39
+ const input = [{ a: "b" }, { c: "d" }];
40
+ const currentAndNextPaths = [];
51
41
 
52
- // callback interface:
53
42
  traverse(
54
43
  input,
55
- (key1, val1, innerObj) => {
56
- gathered.push([key1, val1, innerObj]);
44
+ (_key, _value, inner) => {
45
+ currentAndNextPaths.push([inner.path, inner.next[0]?.[2].path ?? null]);
57
46
  },
58
- 1, // <---------------- report one upcoming value
47
+ 1,
59
48
  );
60
49
 
61
- assert.deepEqual(gathered, [
62
- // ===================
63
- [
64
- {
65
- a: "b",
66
- },
67
- undefined,
68
- {
69
- depth: 0,
70
- path: "0",
71
- parent: [
72
- {
73
- a: "b",
74
- },
75
- {
76
- c: "d",
77
- },
78
- {
79
- e: "f",
80
- },
81
- ],
82
- parentType: "array",
83
- next: [
84
- [
85
- "a",
86
- "b",
87
- {
88
- depth: 1,
89
- path: "0.a",
90
- parent: {
91
- a: "b",
92
- },
93
- parentType: "object",
94
- },
95
- ],
96
- ],
97
- },
98
- ],
99
- // ===================
100
- [
101
- "a",
102
- "b",
103
- {
104
- depth: 1,
105
- path: "0.a",
106
- parent: {
107
- a: "b",
108
- },
109
- parentType: "object",
110
- next: [
111
- [
112
- {
113
- c: "d",
114
- },
115
- undefined,
116
- {
117
- depth: 0,
118
- path: "1",
119
- parent: [
120
- {
121
- a: "b",
122
- },
123
- {
124
- c: "d",
125
- },
126
- {
127
- e: "f",
128
- },
129
- ],
130
- parentType: "array",
131
- },
132
- ],
133
- ],
134
- },
135
- ],
136
- // ===================
137
- [
138
- {
139
- c: "d",
140
- },
141
- undefined,
142
- {
143
- depth: 0,
144
- path: "1",
145
- parent: [
146
- {
147
- a: "b",
148
- },
149
- {
150
- c: "d",
151
- },
152
- {
153
- e: "f",
154
- },
155
- ],
156
- parentType: "array",
157
- next: [
158
- [
159
- "c",
160
- "d",
161
- {
162
- depth: 1,
163
- path: "1.c",
164
- parent: {
165
- c: "d",
166
- },
167
- parentType: "object",
168
- },
169
- ],
170
- ],
171
- },
172
- ],
173
- // ===================
174
- [
175
- "c",
176
- "d",
177
- {
178
- depth: 1,
179
- path: "1.c",
180
- parent: {
181
- c: "d",
182
- },
183
- parentType: "object",
184
- next: [
185
- [
186
- {
187
- e: "f",
188
- },
189
- undefined,
190
- {
191
- depth: 0,
192
- path: "2",
193
- parent: [
194
- {
195
- a: "b",
196
- },
197
- {
198
- c: "d",
199
- },
200
- {
201
- e: "f",
202
- },
203
- ],
204
- parentType: "array",
205
- },
206
- ],
207
- ],
208
- },
209
- ],
210
- // ===================
211
- [
212
- {
213
- e: "f",
214
- },
215
- undefined,
216
- {
217
- depth: 0,
218
- path: "2",
219
- parent: [
220
- {
221
- a: "b",
222
- },
223
- {
224
- c: "d",
225
- },
226
- {
227
- e: "f",
228
- },
229
- ],
230
- parentType: "array",
231
- next: [
232
- [
233
- "e",
234
- "f",
235
- {
236
- depth: 1,
237
- path: "2.e",
238
- parent: {
239
- e: "f",
240
- },
241
- parentType: "object",
242
- },
243
- ],
244
- ],
245
- },
246
- ],
247
- // ===================
248
- [
249
- "e",
250
- "f",
251
- {
252
- depth: 1,
253
- path: "2.e",
254
- parent: {
255
- e: "f",
256
- },
257
- parentType: "object",
258
- next: [],
259
- },
260
- ],
261
- // ===================
50
+ assert.deepEqual(currentAndNextPaths, [
51
+ ["0", "0.a"],
52
+ ["0.a", "1"],
53
+ ["1", "1.c"],
54
+ ["1.c", null],
262
55
  ]);
263
56
  ```
264
57
 
58
+
265
59
  ## Documentation
266
60
 
267
61
  Please [visit codsen.com](https://codsen.com/os/ast-monkey-traverse-with-lookahead/) for a full description of the API. If you’re looking for the **Changelog**, it’s [here](https://github.com/codsen/codsen/blob/main/packages/ast-monkey-traverse-with-lookahead/CHANGELOG.md).
@@ -274,6 +68,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
274
68
 
275
69
  MIT License
276
70
 
277
- Copyright © 2010-2025 Roy Revelt and other contributors
71
+ Copyright © 2010-2026 Roy Revelt and other contributors
278
72
 
279
73
  <p align="center"><img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center"></p>
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name ast-monkey-traverse-with-lookahead
3
3
  * @fileoverview Utility library to traverse AST, reports upcoming values
4
- * @version 4.1.3
4
+ * @version 4.2.0
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-monkey-traverse-with-lookahead/}
8
8
  */
9
9
 
10
- import f from"rfdc";import{isPlainObject as E}from"codsen-utils";var c="4.1.3";var u=f(),S=c;function N(h,g,$=0){function l(e){return typeof e=="string"&&e[0]==="."?e.slice(1):e}let d={now:!1},r=[];function a(e,o,t,s){if(t={...t},t.depth+=1,Array.isArray(e))for(let n=0,i=e.length;n<i&&!s.now;n++){let p=`${t.path}.${n}`;t.parent=u(e),t.parentType="array",o(e[n],void 0,{...t,path:l(p)},s),a(e[n],o,{...t,path:l(p)},s)}else if(E(e))for(let n in e){if(s.now&&n!=null)break;let i=`${t.path}.${n}`;t.depth===0&&n!=null&&(t.topmostKey=n),t.parent=u(e),t.parentType="object",o(n,e[n],{...t,path:l(i)},s),a(e[n],o,{...t,path:l(i)},s)}return e}function m(){let e=r.shift();e[2].next=[];for(let o=0;o<$&&r[o];o++)e[2].next.push(u([r[o][0],r[o][1],r[o][2]]));g(...e)}function y(...e){r.push([...e]),r.length>$&&m()}if(a(h,y,{depth:-1,path:""},d),r.length)for(let e=0,o=r.length;e<o;e++)m()}export{N as traverse,S as version};
10
+ import{deepClone as u,isPlainObject as f}from"codsen-utils";var h="4.2.0";var V=h;function D(y,a,$=0){if(typeof a!="function")throw new TypeError(`ast-monkey-traverse-with-lookahead/traverse(): [THROW_ID_01] The second argument must be a callback function. It was ${typeof a}.`);function l(e){return typeof e=="string"&&e[0]==="."?e.slice(1):e}let g={now:!1},s=[];function m(e,o,t,r){if(t={...t},t.depth+=1,Array.isArray(e))for(let n=0,i=e.length;n<i&&!r.now;n++){let c=`${t.path}.${n}`;t.parent=u(e),t.parentType="array",o(e[n],void 0,{...t,path:l(c)},r),m(e[n],o,{...t,path:l(c)},r)}else if(f(e))for(let n in e){if(r.now&&n!=null)break;let i=`${t.path}.${n}`;t.depth===0&&n!=null&&(t.topmostKey=n),t.parent=u(e),t.parentType="object",o(n,e[n],{...t,path:l(i)},r),m(e[n],o,{...t,path:l(i)},r)}}function p(){let e=s.shift();e[2].next=[];for(let o=0;o<$&&s[o];o++)e[2].next.push(u([s[o][0],s[o][1],s[o][2]]));a(...e)}function d(...e){s.push([...e]),s.length>$&&p()}if(m(y,d,{depth:-1,path:""},g),s.length)for(let e=0,o=s.length;e<o;e++)p()}export{D as traverse,V as version};
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * @name ast-monkey-traverse-with-lookahead
3
3
  * @fileoverview Utility library to traverse AST, reports upcoming values
4
- * @version 4.1.3
4
+ * @version 4.2.0
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-monkey-traverse-with-lookahead/}
8
8
  */
9
9
 
10
- "use strict";var astMonkeyTraverseWithLookahead=(()=>{var C=Object.create;var g=Object.defineProperty,B=Object.defineProperties,F=Object.getOwnPropertyDescriptor,T=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols,M=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var S=(r,n,i)=>n in r?g(r,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[n]=i,y=(r,n)=>{for(var i in n||(n={}))k.call(n,i)&&S(r,i,n[i]);if(w)for(var i of w(n))L.call(n,i)&&S(r,i,n[i]);return r},d=(r,n)=>B(r,T(n));var R=(r,n)=>()=>(n||r((n={exports:{}}).exports,n),n.exports),J=(r,n)=>{for(var i in n)g(r,i,{get:n[i],enumerable:!0})},D=(r,n,i,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of I(n))!k.call(r,c)&&c!==i&&g(r,c,{get:()=>n[c],enumerable:!(f=F(n,c))||f.enumerable});return r};var v=(r,n,i)=>(i=r!=null?C(M(r)):{},D(n||!r||!r.__esModule?g(i,"default",{value:r,enumerable:!0}):i,r)),P=r=>D(g({},"__esModule",{value:!0}),r);var A=R((Z,O)=>{"use strict";O.exports=H;function b(r){return r instanceof Buffer?Buffer.from(r):new r.constructor(r.buffer.slice(),r.byteOffset,r.length)}function H(r){if(r=r||{},r.circles)return U(r);let n=new Map;if(n.set(Date,o=>new Date(o)),n.set(Map,(o,l)=>new Map(f(Array.from(o),l))),n.set(Set,(o,l)=>new Set(f(Array.from(o),l))),r.constructorHandlers)for(let o of r.constructorHandlers)n.set(o[0],o[1]);let i=null;return r.proto?p:c;function f(o,l){let t=Object.keys(o),e=new Array(t.length);for(let u=0;u<t.length;u++){let s=t[u],a=o[s];typeof a!="object"||a===null?e[s]=a:a.constructor!==Object&&(i=n.get(a.constructor))?e[s]=i(a,l):ArrayBuffer.isView(a)?e[s]=b(a):e[s]=l(a)}return e}function c(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return f(o,c);if(o.constructor!==Object&&(i=n.get(o.constructor)))return i(o,c);let l={};for(let t in o){if(Object.hasOwnProperty.call(o,t)===!1)continue;let e=o[t];typeof e!="object"||e===null?l[t]=e:e.constructor!==Object&&(i=n.get(e.constructor))?l[t]=i(e,c):ArrayBuffer.isView(e)?l[t]=b(e):l[t]=c(e)}return l}function p(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return f(o,p);if(o.constructor!==Object&&(i=n.get(o.constructor)))return i(o,p);let l={};for(let t in o){let e=o[t];typeof e!="object"||e===null?l[t]=e:e.constructor!==Object&&(i=n.get(e.constructor))?l[t]=i(e,p):ArrayBuffer.isView(e)?l[t]=b(e):l[t]=p(e)}return l}}function U(r){let n=[],i=[],f=new Map;if(f.set(Date,t=>new Date(t)),f.set(Map,(t,e)=>new Map(p(Array.from(t),e))),f.set(Set,(t,e)=>new Set(p(Array.from(t),e))),r.constructorHandlers)for(let t of r.constructorHandlers)f.set(t[0],t[1]);let c=null;return r.proto?l:o;function p(t,e){let u=Object.keys(t),s=new Array(u.length);for(let a=0;a<u.length;a++){let m=u[a],$=t[m];if(typeof $!="object"||$===null)s[m]=$;else if($.constructor!==Object&&(c=f.get($.constructor)))s[m]=c($,e);else if(ArrayBuffer.isView($))s[m]=b($);else{let h=n.indexOf($);h!==-1?s[m]=i[h]:s[m]=e($)}}return s}function o(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return p(t,o);if(t.constructor!==Object&&(c=f.get(t.constructor)))return c(t,o);let e={};n.push(t),i.push(e);for(let u in t){if(Object.hasOwnProperty.call(t,u)===!1)continue;let s=t[u];if(typeof s!="object"||s===null)e[u]=s;else if(s.constructor!==Object&&(c=f.get(s.constructor)))e[u]=c(s,o);else if(ArrayBuffer.isView(s))e[u]=b(s);else{let a=n.indexOf(s);a!==-1?e[u]=i[a]:e[u]=o(s)}}return n.pop(),i.pop(),e}function l(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return p(t,l);if(t.constructor!==Object&&(c=f.get(t.constructor)))return c(t,l);let e={};n.push(t),i.push(e);for(let u in t){let s=t[u];if(typeof s!="object"||s===null)e[u]=s;else if(s.constructor!==Object&&(c=f.get(s.constructor)))e[u]=c(s,l);else if(ArrayBuffer.isView(s))e[u]=b(s);else{let a=n.indexOf(s);a!==-1?e[u]=i[a]:e[u]=l(s)}}return n.pop(),i.pop(),e}}});var W={};J(W,{traverse:()=>Q,version:()=>K});var N=v(A(),1);var x=v(A(),1);var _=(0,x.default)();function j(r){if(r==null||typeof r!="object")return!1;let n=Object.getPrototypeOf(r);return n!==null&&n!==Object.prototype&&Object.getPrototypeOf(n)!==null?!1:!(Symbol.iterator in r)&&!(Symbol.toStringTag in r)}var V="4.1.3";var E=(0,N.default)(),K=V;function Q(r,n,i=0){function f(e){return typeof e=="string"&&e[0]==="."?e.slice(1):e}let c={now:!1},p=[];function o(e,u,s,a){if(s=y({},s),s.depth+=1,Array.isArray(e))for(let m=0,$=e.length;m<$&&!a.now;m++){let h="".concat(s.path,".").concat(m);s.parent=E(e),s.parentType="array",u(e[m],void 0,d(y({},s),{path:f(h)}),a),o(e[m],u,d(y({},s),{path:f(h)}),a)}else if(j(e))for(let m in e){if(a.now&&m!=null)break;let $="".concat(s.path,".").concat(m);s.depth===0&&m!=null&&(s.topmostKey=m),s.parent=E(e),s.parentType="object",u(m,e[m],d(y({},s),{path:f($)}),a),o(e[m],u,d(y({},s),{path:f($)}),a)}return e}function l(){let e=p.shift();e[2].next=[];for(let u=0;u<i&&p[u];u++)e[2].next.push(E([p[u][0],p[u][1],p[u][2]]));n(...e)}function t(...e){p.push([...e]),p.length>i&&l()}if(o(r,t,{depth:-1,path:""},c),p.length)for(let e=0,u=p.length;e<u;e++)l()}return P(W);})();
10
+ "use strict";var astMonkeyTraverseWithLookahead=(()=>{var $=Object.defineProperty,O=Object.defineProperties,N=Object.getOwnPropertyDescriptor,V=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertyNames,S=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var A=(e,t,n)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,h=(e,t)=>{for(var n in t||(t={}))x.call(t,n)&&A(e,n,t[n]);if(S)for(var n of S(t))j.call(t,n)&&A(e,n,t[n]);return e},m=(e,t)=>O(e,V(t));var M=(e,t)=>{for(var n in t)$(e,n,{get:t[n],enumerable:!0})},T=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of I(t))!x.call(e,s)&&s!==n&&$(e,s,{get:()=>t[s],enumerable:!(l=N(t,s))||l.enumerable});return e};var W=e=>T($({},"__esModule",{value:!0}),e);var y=(e,t,n)=>A(e,typeof t!="symbol"?t+"":t,n);var P={};M(P,{traverse:()=>U,version:()=>L});var H=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);var R=class{constructor(){y(this,"hasRepeatedReferences",!1);y(this,"clones",[]);y(this,"index");y(this,"sources",[])}get(e){if(this.index){let n=this.index.get(e);return n!==void 0&&(this.hasRepeatedReferences=!0),n}let t=this.sources.indexOf(e);if(t!==-1)return this.hasRepeatedReferences=!0,this.clones[t]}set(e,t){if(this.index){this.index.set(e,t);return}if(this.sources.push(e),this.clones.push(t),this.sources.length===32){this.index=new WeakMap;for(let n=0;n<this.sources.length;n++)this.index.set(this.sources[n],this.clones[n]);this.sources=[],this.clones=[]}}};function D(e,t){let n=t.get(e);if(n!==void 0)return n;let l=e.slice(0);return t.set(e,l),l}function F(e,t){if(typeof Buffer<"u"&&Buffer.isBuffer(e)){let r=Buffer.from(e);return t.set(e,r),r}let n=D(e.buffer,t);if(e instanceof DataView){let r=new DataView(n,e.byteOffset,e.byteLength);return t.set(e,r),r}let l=e.constructor,s=new l(n,e.byteOffset,e.length);return t.set(e,s),s}function k(e,t,n,l){for(let s of n){let r=t[s];e[s]=typeof r!="object"||r===null?r:g(r,l)}}function g(e,t){if(typeof e!="object"||e===null)return e;let n=t.get(e);if(n!==void 0)return n;if(Array.isArray(e)){let r=e.length,f=new Array(r);t.set(e,f);let c=e,d=Object.keys(e);if(d.length===r&&(r===0||d[r-1]==="".concat(r-1)))for(let i=0;i<r;i++){let o=c[i];f[i]=typeof o!="object"||o===null?o:g(o,t)}else k(f,c,d,t);return f}let l=Object.getPrototypeOf(e);if(l===Object.prototype||l===null){let r={};return t.set(e,r),k(r,e,Object.keys(e),t),r}if(e instanceof Date){let r=new Date(e.getTime());return t.set(e,r),r}if(ArrayBuffer.isView(e))return F(e,t);if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return D(e,t);if(e instanceof Map){let r=new Map;t.set(e,r);for(let[f,c]of e)r.set(g(f,t),g(c,t));return r}if(e instanceof Set){let r=new Set;t.set(e,r);for(let f of e)r.add(g(f,t));return r}let s={};return t.set(e,s),k(s,e,Object.keys(e),t),s}function v(e){return g(e,new R)}function E(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}var C="4.2.0";var L=C;function U(e,t,n=0){if(typeof t!="function")throw new TypeError("ast-monkey-traverse-with-lookahead/traverse(): [THROW_ID_01] The second argument must be a callback function. It was ".concat(typeof t,"."));function l(i){return typeof i=="string"&&i[0]==="."?i.slice(1):i}let s={now:!1},r=[];function f(i,o,u,p){if(u=h({},u),u.depth+=1,Array.isArray(i))for(let a=0,b=i.length;a<b&&!p.now;a++){let w="".concat(u.path,".").concat(a);u.parent=v(i),u.parentType="array",o(i[a],void 0,m(h({},u),{path:l(w)}),p),f(i[a],o,m(h({},u),{path:l(w)}),p)}else if(E(i))for(let a in i){if(p.now&&a!=null)break;let b="".concat(u.path,".").concat(a);u.depth===0&&a!=null&&(u.topmostKey=a),u.parent=v(i),u.parentType="object",o(a,i[a],m(h({},u),{path:l(b)}),p),f(i[a],o,m(h({},u),{path:l(b)}),p)}}function c(){let i=r.shift();i[2].next=[];for(let o=0;o<n&&r[o];o++)i[2].next.push(v([r[o][0],r[o][1],r[o][2]]));t(...i)}function d(...i){r.push([...i]),r.length>n&&c()}if(f(e,d,{depth:-1,path:""},s),r.length)for(let i=0,o=r.length;i<o;i++)c()}return W(P);})();
11
11
  /**
12
12
  * @name codsen-utils
13
13
  * @fileoverview Various utility functions
14
- * @version 1.7.3
14
+ * @version 1.8.0
15
15
  * @author Roy Revelt
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/codsen-utils/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ast-monkey-traverse-with-lookahead",
3
- "version": "4.1.3",
3
+ "version": "4.2.0",
4
4
  "description": "Utility library to traverse AST, reports upcoming values",
5
5
  "keywords": [
6
6
  "ast",
@@ -46,45 +46,43 @@
46
46
  },
47
47
  "types": "types/index.d.ts",
48
48
  "scripts": {
49
- "build": "node '../../ops/scripts/esbuild.js' && npm run dts",
50
- "cjs-off": "exit 0",
51
- "cjs-on": "exit 0",
52
- "dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
49
+ "build": "node ../../ops/scripts/esbuild.js && npm run dts",
50
+ "coverage": "c8 uvu test",
51
+ "dev": "node ../../ops/scripts/esbuild.js --dev && npm run dts",
53
52
  "devtest": "c8 npm run unit && npm run examples && npm run lint",
54
- "dts": "rollup -c && npm run prettier -- 'types/index.d.ts' --write --log-level 'silent'",
53
+ "dts": "rollup -c && biome format --write --config-path=../../biome.json --vcs-enabled=false --use-editorconfig=false types/index.d.ts",
55
54
  "examples": "node '../../ops/scripts/run-examples.js'",
56
- "lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
57
- "letspublish": "npm publish --provenance || :",
58
- "lint": "eslint . --fix --concurrency=auto --cache",
55
+ "lect": "node '../../ops/lect/lect.js'",
56
+ "lect:check": "node '../../ops/lect/lect.js' --check",
57
+ "lint": "biome lint --error-on-warnings . && npm run typecheck",
58
+ "lint:fix": "biome lint --write --error-on-warnings . && npm run typecheck",
59
59
  "perf": "node perf/check.js",
60
60
  "prep": "echo 'ready'",
61
- "prettier": "prettier",
62
- "prettier:format": "npm run prettier -- --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern --log-level 'silent'",
63
- "pretest": "npm run lect && npm run build",
61
+ "prettier": "biome format",
62
+ "prettier:format": "biome format --write .",
63
+ "pretest": "npm run lect:check && npm run build",
64
64
  "test": "npm run devtest",
65
+ "typecheck": "tsc --noEmit --pretty false --project tsconfig.json",
65
66
  "unit": "uvu test"
66
67
  },
67
- "engines": {
68
- "node": ">=14.18.0"
69
- },
70
68
  "c8": {
69
+ "all": true,
71
70
  "check-coverage": true,
72
- "exclude": [
73
- "**/test/**/*.*"
74
- ],
71
+ "exclude": ["**/test/**/*.*"],
72
+ "include": ["dist/*.esm.js"],
75
73
  "lines": 100
76
74
  },
77
75
  "lect": {
78
76
  "licence": {
79
- "extras": [
80
- ""
81
- ]
77
+ "extras": [""]
82
78
  },
83
79
  "various": {}
84
80
  },
85
81
  "dependencies": {
86
- "codsen-utils": "^1.7.3",
87
- "rfdc": "^1.4.1"
82
+ "codsen-utils": "^1.8.0"
83
+ },
84
+ "engines": {
85
+ "node": ">=18.20.8"
88
86
  },
89
87
  "publishConfig": {
90
88
  "registry": "https://registry.npmjs.org/"
package/types/index.d.ts CHANGED
@@ -3,7 +3,7 @@ interface Obj {
3
3
  [key: string]: any;
4
4
  }
5
5
  type NextToken = [
6
- key: "string",
6
+ key: any,
7
7
  value: any,
8
8
  innerObj: {
9
9
  depth: number;
@@ -21,7 +21,7 @@ interface InnerObj {
21
21
  next?: NextToken[];
22
22
  }
23
23
  type Callback = (
24
- key: string | Obj,
24
+ key: any,
25
25
  val: any,
26
26
  innerObj: InnerObj,
27
27
  stop: {