ast-monkey-traverse-with-lookahead 3.0.4 → 3.0.10
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 +0 -20
- package/LICENSE +1 -1
- package/README.md +4 -1
- package/dist/ast-monkey-traverse-with-lookahead.esm.js +2 -88
- package/dist/ast-monkey-traverse-with-lookahead.umd.js +2 -2
- package/examples/_quickTake.js +1 -0
- package/package.json +23 -80
- package/types/index.d.ts +0 -0
- package/examples/api.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,26 +3,6 @@
|
|
|
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
|
-
## 3.0.3 (2021-11-02)
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
- bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
|
|
11
|
-
|
|
12
|
-
### Features
|
|
13
|
-
|
|
14
|
-
- migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
|
|
15
|
-
|
|
16
|
-
### BREAKING CHANGES
|
|
17
|
-
|
|
18
|
-
- programs now are in ES Modules and won't work with Common JS require()
|
|
19
|
-
|
|
20
|
-
## 3.0.1 (2021-09-13)
|
|
21
|
-
|
|
22
|
-
### Bug Fixes
|
|
23
|
-
|
|
24
|
-
- bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
|
|
25
|
-
|
|
26
6
|
## 3.0.0 (2021-09-09)
|
|
27
7
|
|
|
28
8
|
### Features
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010
|
|
3
|
+
Copyright (c) 2010-2021 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
|
@@ -38,6 +38,7 @@ If you need a legacy version which works with `require`, use version 2.1.0
|
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
40
|
import { strict as assert } from "assert";
|
|
41
|
+
|
|
41
42
|
import { traverse } from "ast-monkey-traverse-with-lookahead";
|
|
42
43
|
|
|
43
44
|
const input = [
|
|
@@ -268,7 +269,7 @@ assert.deepEqual(gathered, [
|
|
|
268
269
|
|
|
269
270
|
## Documentation
|
|
270
271
|
|
|
271
|
-
Please [visit codsen.com](https://codsen.com/os/ast-monkey-traverse-with-lookahead/) for a full description of the API
|
|
272
|
+
Please [visit codsen.com](https://codsen.com/os/ast-monkey-traverse-with-lookahead/) for a full description of the API.
|
|
272
273
|
|
|
273
274
|
## Contributing
|
|
274
275
|
|
|
@@ -280,4 +281,6 @@ MIT License
|
|
|
280
281
|
|
|
281
282
|
Copyright (c) 2010-2021 Roy Revelt and other contributors
|
|
282
283
|
|
|
284
|
+
|
|
283
285
|
<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">
|
|
286
|
+
|
|
@@ -1,96 +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 3.0.
|
|
4
|
+
* @version 3.0.10
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-monkey-traverse-with-lookahead/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
import isObj from 'lodash.isplainobject';
|
|
12
|
-
|
|
13
|
-
var version$1 = "3.0.4";
|
|
14
|
-
|
|
15
|
-
const version = version$1;
|
|
16
|
-
function traverse(tree1, cb1, lookahead = 0) {
|
|
17
|
-
function trimFirstDot(str) {
|
|
18
|
-
if (typeof str === "string" && str[0] === ".") {
|
|
19
|
-
return str.slice(1);
|
|
20
|
-
}
|
|
21
|
-
return str;
|
|
22
|
-
}
|
|
23
|
-
const stop1 = {
|
|
24
|
-
now: false
|
|
25
|
-
};
|
|
26
|
-
const stash = [];
|
|
27
|
-
function traverseInner(tree, callback, innerObj, stop) {
|
|
28
|
-
innerObj = { ...innerObj
|
|
29
|
-
};
|
|
30
|
-
innerObj.depth += 1;
|
|
31
|
-
if (Array.isArray(tree)) {
|
|
32
|
-
for (let i = 0, len = tree.length; i < len; i++) {
|
|
33
|
-
if (stop.now) {
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
const path = `${innerObj.path}.${i}`;
|
|
37
|
-
innerObj.parent = clone(tree);
|
|
38
|
-
innerObj.parentType = "array";
|
|
39
|
-
callback(tree[i], undefined, { ...innerObj,
|
|
40
|
-
path: trimFirstDot(path)
|
|
41
|
-
}, stop);
|
|
42
|
-
traverseInner(tree[i], callback, { ...innerObj,
|
|
43
|
-
path: trimFirstDot(path)
|
|
44
|
-
}, stop);
|
|
45
|
-
}
|
|
46
|
-
} else if (isObj(tree)) {
|
|
47
|
-
for (const key in tree) {
|
|
48
|
-
if (stop.now && key != null) {
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
const path = `${innerObj.path}.${key}`;
|
|
52
|
-
if (innerObj.depth === 0 && key != null) {
|
|
53
|
-
innerObj.topmostKey = key;
|
|
54
|
-
}
|
|
55
|
-
innerObj.parent = clone(tree);
|
|
56
|
-
innerObj.parentType = "object";
|
|
57
|
-
callback(key, tree[key], { ...innerObj,
|
|
58
|
-
path: trimFirstDot(path)
|
|
59
|
-
}, stop);
|
|
60
|
-
traverseInner(tree[key], callback, { ...innerObj,
|
|
61
|
-
path: trimFirstDot(path)
|
|
62
|
-
}, stop);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return tree;
|
|
66
|
-
}
|
|
67
|
-
function reportFirstFromStash() {
|
|
68
|
-
const currentElem = stash.shift();
|
|
69
|
-
currentElem[2].next = [];
|
|
70
|
-
for (let i = 0; i < lookahead; i++) {
|
|
71
|
-
if (stash[i]) {
|
|
72
|
-
currentElem[2].next.push(clone([stash[i][0], stash[i][1], stash[i][2]]));
|
|
73
|
-
} else {
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
cb1(...currentElem);
|
|
78
|
-
}
|
|
79
|
-
function intermediary(...incoming) {
|
|
80
|
-
stash.push([...incoming]);
|
|
81
|
-
if (stash.length > lookahead) {
|
|
82
|
-
reportFirstFromStash();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
traverseInner(tree1, intermediary, {
|
|
86
|
-
depth: -1,
|
|
87
|
-
path: ""
|
|
88
|
-
}, stop1);
|
|
89
|
-
if (stash.length) {
|
|
90
|
-
for (let i = 0, len = stash.length; i < len; i++) {
|
|
91
|
-
reportFirstFromStash();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export { traverse, version };
|
|
10
|
+
import $ from"lodash.clonedeep";import E from"lodash.isplainobject";var c="3.0.10";var S=c;function v(h,y,u=0){function r(e){return typeof e=="string"&&e[0]==="."?e.slice(1):e}let d={now:!1},s=[];function i(e,o,t,l){if(t={...t},t.depth+=1,Array.isArray(e))for(let n=0,a=e.length;n<a&&!l.now;n++){let p=`${t.path}.${n}`;t.parent=$(e),t.parentType="array",o(e[n],void 0,{...t,path:r(p)},l),i(e[n],o,{...t,path:r(p)},l)}else if(E(e))for(let n in e){if(l.now&&n!=null)break;let a=`${t.path}.${n}`;t.depth===0&&n!=null&&(t.topmostKey=n),t.parent=$(e),t.parentType="object",o(n,e[n],{...t,path:r(a)},l),i(e[n],o,{...t,path:r(a)},l)}return e}function m(){let e=s.shift();e[2].next=[];for(let o=0;o<u&&s[o];o++)e[2].next.push($([s[o][0],s[o][1],s[o][2]]));y(...e)}function b(...e){s.push([...e]),s.length>u&&m()}if(i(h,b,{depth:-1,path:""},d),s.length)for(let e=0,o=s.length;e<o;e++)m()}export{v as traverse,S as version};
|
|
@@ -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 3.0.
|
|
4
|
+
* @version 3.0.10
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-monkey-traverse-with-lookahead/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).astMonkeyTraverseWithLookahead={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",o=9007199254740991,c="[object Arguments]",u="[object Boolean]",a="[object Date]",i="[object Function]",f="[object GeneratorFunction]",s="[object Map]",l="[object Number]",p="[object Object]",h="[object Promise]",y="[object RegExp]",_="[object Set]",v="[object String]",d="[object Symbol]",b="[object WeakMap]",g="[object ArrayBuffer]",j="[object DataView]",w="[object Float32Array]",O="[object Float64Array]",A="[object Int8Array]",m="[object Int16Array]",x="[object Int32Array]",S="[object Uint8Array]",$="[object Uint8ClampedArray]",P="[object Uint16Array]",T="[object Uint32Array]",k=/\w*$/,E=/^\[object .+?Constructor\]$/,F=/^(?:0|[1-9]\d*)$/,I={};I[c]=I["[object Array]"]=I[g]=I[j]=I[u]=I[a]=I[w]=I[O]=I[A]=I[m]=I[x]=I[s]=I[l]=I[p]=I[y]=I[_]=I[v]=I[d]=I[S]=I[$]=I[P]=I[T]=!0,I["[object Error]"]=I[i]=I[b]=!1;var M="object"==typeof self&&self&&self.Object===Object&&self,B="object"==typeof e&&e&&e.Object===Object&&e||M||Function("return this")(),U=r&&!r.nodeType&&r,D=U&&t&&!t.nodeType&&t,L=D&&D.exports===U;function R(t,e){return t.set(e[0],e[1]),t}function W(t,e){return t.add(e),t}function z(t,e,r,n){var o=-1,c=t?t.length:0;for(n&&c&&(r=t[++o]);++o<c;)r=e(r,t[o],o,t);return r}function C(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function V(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function G(t,e){return function(r){return t(e(r))}}function K(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var N,q=Array.prototype,H=Function.prototype,J=Object.prototype,Q=B["__core-js_shared__"],X=(N=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"",Y=H.toString,Z=J.hasOwnProperty,tt=J.toString,et=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=L?B.Buffer:void 0,nt=B.Symbol,ot=B.Uint8Array,ct=G(Object.getPrototypeOf,Object),ut=Object.create,at=J.propertyIsEnumerable,it=q.splice,ft=Object.getOwnPropertySymbols,st=rt?rt.isBuffer:void 0,lt=G(Object.keys,Object),pt=Dt(B,"DataView"),ht=Dt(B,"Map"),yt=Dt(B,"Promise"),_t=Dt(B,"Set"),vt=Dt(B,"WeakMap"),dt=Dt(Object,"create"),bt=Ct(pt),gt=Ct(ht),jt=Ct(yt),wt=Ct(_t),Ot=Ct(vt),At=nt?nt.prototype:void 0,mt=At?At.valueOf:void 0;function xt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function St(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function $t(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Pt(t){this.__data__=new St(t)}function Tt(t,e){var r=Gt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Kt(t)}(t)&&Z.call(t,"callee")&&(!at.call(t,"callee")||tt.call(t)==c)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var u in t)!e&&!Z.call(t,u)||o&&("length"==u||Wt(u,n))||r.push(u);return r}function kt(t,e,r){var n=t[e];Z.call(t,e)&&Vt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function Et(t,e){for(var r=t.length;r--;)if(Vt(t[r][0],e))return r;return-1}function Ft(t,e,r,n,o,h,b){var E;if(n&&(E=h?n(t,o,h,b):n(t)),void 0!==E)return E;if(!Ht(t))return t;var F=Gt(t);if(F){if(E=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Z.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!e)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(t,E)}else{var M=Rt(t),B=M==i||M==f;if(Nt(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if(M==p||M==c||B&&!h){if(C(t))return h?t:{};if(E=function(t){return"function"!=typeof t.constructor||zt(t)?{}:(e=ct(t),Ht(e)?ut(e):{});var e}(B?{}:t),!e)return function(t,e){return Bt(t,Lt(t),e)}(t,function(t,e){return t&&Bt(e,Jt(e),t)}(E,t))}else{if(!I[M])return h?t:{};E=function(t,e,r,n){var o=t.constructor;switch(e){case g:return Mt(t);case u:case a:return new o(+t);case j:return function(t,e){var r=e?Mt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case w:case O:case A:case m:case x:case S:case $:case P:case T:return function(t,e){var r=e?Mt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case s:return function(t,e,r){return z(e?r(V(t),!0):V(t),R,new t.constructor)}(t,n,r);case l:case v:return new o(t);case y:return function(t){var e=new t.constructor(t.source,k.exec(t));return e.lastIndex=t.lastIndex,e}(t);case _:return function(t,e,r){return z(e?r(K(t),!0):K(t),W,new t.constructor)}(t,n,r);case d:return c=t,mt?Object(mt.call(c)):{}}var c}(t,M,Ft,e)}}b||(b=new Pt);var U=b.get(t);if(U)return U;if(b.set(t,E),!F)var D=r?function(t){return function(t,e,r){var n=e(t);return Gt(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,Jt,Lt)}(t):Jt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(D||t,(function(o,c){D&&(o=t[c=o]),kt(E,c,Ft(o,e,r,n,c,t,b))})),E}function It(t){return!(!Ht(t)||(e=t,X&&X in e))&&(qt(t)||C(t)?et:E).test(Ct(t));var e}function Mt(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Bt(t,e,r,n){r||(r={});for(var o=-1,c=e.length;++o<c;){var u=e[o],a=n?n(r[u],t[u],u,r,t):void 0;kt(r,u,void 0===a?t[u]:a)}return r}function Ut(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Dt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return It(r)?r:void 0}xt.prototype.clear=function(){this.__data__=dt?dt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(dt){var r=e[t];return r===n?void 0:r}return Z.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return dt?void 0!==e[t]:Z.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=dt&&void 0===e?n:e,this},St.prototype.clear=function(){this.__data__=[]},St.prototype.delete=function(t){var e=this.__data__,r=Et(e,t);return!(r<0)&&(r==e.length-1?e.pop():it.call(e,r,1),!0)},St.prototype.get=function(t){var e=this.__data__,r=Et(e,t);return r<0?void 0:e[r][1]},St.prototype.has=function(t){return Et(this.__data__,t)>-1},St.prototype.set=function(t,e){var r=this.__data__,n=Et(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},$t.prototype.clear=function(){this.__data__={hash:new xt,map:new(ht||St),string:new xt}},$t.prototype.delete=function(t){return Ut(this,t).delete(t)},$t.prototype.get=function(t){return Ut(this,t).get(t)},$t.prototype.has=function(t){return Ut(this,t).has(t)},$t.prototype.set=function(t,e){return Ut(this,t).set(t,e),this},Pt.prototype.clear=function(){this.__data__=new St},Pt.prototype.delete=function(t){return this.__data__.delete(t)},Pt.prototype.get=function(t){return this.__data__.get(t)},Pt.prototype.has=function(t){return this.__data__.has(t)},Pt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof St){var n=r.__data__;if(!ht||n.length<199)return n.push([t,e]),this;r=this.__data__=new $t(n)}return r.set(t,e),this};var Lt=ft?G(ft,Object):function(){return[]},Rt=function(t){return tt.call(t)};function Wt(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||F.test(t))&&t>-1&&t%1==0&&t<e}function zt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||J)}function Ct(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Vt(t,e){return t===e||t!=t&&e!=e}(pt&&Rt(new pt(new ArrayBuffer(1)))!=j||ht&&Rt(new ht)!=s||yt&&Rt(yt.resolve())!=h||_t&&Rt(new _t)!=_||vt&&Rt(new vt)!=b)&&(Rt=function(t){var e=tt.call(t),r=e==p?t.constructor:void 0,n=r?Ct(r):void 0;if(n)switch(n){case bt:return j;case gt:return s;case jt:return h;case wt:return _;case Ot:return b}return e});var Gt=Array.isArray;function Kt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!qt(t)}var Nt=st||function(){return!1};function qt(t){var e=Ht(t)?tt.call(t):"";return e==i||e==f}function Ht(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Jt(t){return Kt(t)?Tt(t):function(t){if(!zt(t))return lt(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Ft(t,!0,!0)}}(r,r.exports);var n=r.exports;var o,c,u=Object.prototype,a=Function.prototype.toString,i=u.hasOwnProperty,f=a.call(Object),s=u.toString,l=(o=Object.getPrototypeOf,c=Object,function(t){return o(c(t))});var p=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=s.call(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=l(t);if(null===e)return!0;var r=i.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&a.call(r)==f};t.traverse=function(t,e,r=0){function o(t){return"string"==typeof t&&"."===t[0]?t.slice(1):t}const c=[];function u(){const t=c.shift();t[2].next=[];for(let e=0;e<r&&c[e];e++)t[2].next.push(n([c[e][0],c[e][1],c[e][2]]));e(...t)}if(function t(e,r,c,u){if((c={...c}).depth+=1,Array.isArray(e))for(let a=0,i=e.length;a<i&&!u.now;a++){const i=`${c.path}.${a}`;c.parent=n(e),c.parentType="array",r(e[a],void 0,{...c,path:o(i)},u),t(e[a],r,{...c,path:o(i)},u)}else if(p(e))for(const a in e){if(u.now&&null!=a)break;const i=`${c.path}.${a}`;0===c.depth&&null!=a&&(c.topmostKey=a),c.parent=n(e),c.parentType="object",r(a,e[a],{...c,path:o(i)},u),t(e[a],r,{...c,path:o(i)},u)}return e}(t,(function(...t){c.push([...t]),c.length>r&&u()}),{depth:-1,path:""},{now:!1}),c.length)for(let t=0,e=c.length;t<e;t++)u()},t.version="3.0.4",Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
10
|
+
var astMonkeyTraverseWithLookahead=(()=>{var ne=Object.create;var w=Object.defineProperty,oe=Object.defineProperties,ae=Object.getOwnPropertyDescriptor,ie=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertyNames,rt=Object.getOwnPropertySymbols,ce=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var ot=(t,e,r)=>e in t?w(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,S=(t,e)=>{for(var r in e||(e={}))nt.call(e,r)&&ot(t,r,e[r]);if(rt)for(var r of rt(e))ue.call(e,r)&&ot(t,r,e[r]);return t},A=(t,e)=>oe(t,ie(e)),at=t=>w(t,"__esModule",{value:!0});var it=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),le=(t,e)=>{for(var r in e)w(t,r,{get:e[r],enumerable:!0})},st=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of se(e))!nt.call(t,a)&&(r||a!=="default")&&w(t,a,{get:()=>e[a],enumerable:!(n=ae(e,a))||n.enumerable});return t},ct=(t,e)=>st(at(w(t!=null?ne(ce(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),fe=(t=>(e,r)=>t&&t.get(e)||(r=st(at({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var Yt=it((C,T)=>{var he=200,ut="__lodash_hash_undefined__",lt=9007199254740991,R="[object Arguments]",pe="[object Array]",ft="[object Boolean]",ht="[object Date]",ge="[object Error]",L="[object Function]",pt="[object GeneratorFunction]",V="[object Map]",gt="[object Number]",U="[object Object]",dt="[object Promise]",yt="[object RegExp]",I="[object Set]",bt="[object String]",mt="[object Symbol]",B="[object WeakMap]",$t="[object ArrayBuffer]",N="[object DataView]",_t="[object Float32Array]",St="[object Float64Array]",vt="[object Int8Array]",Et="[object Int16Array]",Ot="[object Int32Array]",Tt="[object Uint8Array]",wt="[object Uint8ClampedArray]",At="[object Uint16Array]",jt="[object Uint32Array]",de=/[\\^$.*+?()[\]{}|]/g,ye=/\w*$/,be=/^\[object .+?Constructor\]$/,me=/^(?:0|[1-9]\d*)$/,i={};i[R]=i[pe]=i[$t]=i[N]=i[ft]=i[ht]=i[_t]=i[St]=i[vt]=i[Et]=i[Ot]=i[V]=i[gt]=i[U]=i[yt]=i[I]=i[bt]=i[mt]=i[Tt]=i[wt]=i[At]=i[jt]=!0;i[ge]=i[L]=i[B]=!1;var $e=typeof global=="object"&&global&&global.Object===Object&&global,_e=typeof self=="object"&&self&&self.Object===Object&&self,d=$e||_e||Function("return this")(),xt=typeof C=="object"&&C&&!C.nodeType&&C,Ct=xt&&typeof T=="object"&&T&&!T.nodeType&&T,Se=Ct&&Ct.exports===xt;function ve(t,e){return t.set(e[0],e[1]),t}function Ee(t,e){return t.add(e),t}function Oe(t,e){for(var r=-1,n=t?t.length:0;++r<n&&e(t[r],r,t)!==!1;);return t}function Te(t,e){for(var r=-1,n=e.length,a=t.length;++r<n;)t[a+r]=e[r];return t}function Dt(t,e,r,n){var a=-1,s=t?t.length:0;for(n&&s&&(r=t[++a]);++a<s;)r=e(r,t[a],a,t);return r}function we(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function Ae(t,e){return t==null?void 0:t[e]}function Vt(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function It(t){var e=-1,r=Array(t.size);return t.forEach(function(n,a){r[++e]=[a,n]}),r}function J(t,e){return function(r){return t(e(r))}}function Nt(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var je=Array.prototype,xe=Function.prototype,k=Object.prototype,K=d["__core-js_shared__"],kt=function(){var t=/[^.]+$/.exec(K&&K.keys&&K.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Pt=xe.toString,b=k.hasOwnProperty,P=k.toString,Ce=RegExp("^"+Pt.call(b).replace(de,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ft=Se?d.Buffer:void 0,Mt=d.Symbol,Gt=d.Uint8Array,De=J(Object.getPrototypeOf,Object),Ve=Object.create,Ie=k.propertyIsEnumerable,Ne=je.splice,Ht=Object.getOwnPropertySymbols,ke=Ft?Ft.isBuffer:void 0,Pe=J(Object.keys,Object),W=O(d,"DataView"),j=O(d,"Map"),q=O(d,"Promise"),X=O(d,"Set"),Y=O(d,"WeakMap"),x=O(Object,"create"),Fe=_(W),Me=_(j),Ge=_(q),He=_(X),Re=_(Y),Rt=Mt?Mt.prototype:void 0,Lt=Rt?Rt.valueOf:void 0;function m(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Le(){this.__data__=x?x(null):{}}function Ue(t){return this.has(t)&&delete this.__data__[t]}function Be(t){var e=this.__data__;if(x){var r=e[t];return r===ut?void 0:r}return b.call(e,t)?e[t]:void 0}function Je(t){var e=this.__data__;return x?e[t]!==void 0:b.call(e,t)}function Ke(t,e){var r=this.__data__;return r[t]=x&&e===void 0?ut:e,this}m.prototype.clear=Le;m.prototype.delete=Ue;m.prototype.get=Be;m.prototype.has=Je;m.prototype.set=Ke;function y(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function We(){this.__data__=[]}function qe(t){var e=this.__data__,r=F(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Ne.call(e,r,1),!0}function Xe(t){var e=this.__data__,r=F(e,t);return r<0?void 0:e[r][1]}function Ye(t){return F(this.__data__,t)>-1}function Ze(t,e){var r=this.__data__,n=F(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}y.prototype.clear=We;y.prototype.delete=qe;y.prototype.get=Xe;y.prototype.has=Ye;y.prototype.set=Ze;function v(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Qe(){this.__data__={hash:new m,map:new(j||y),string:new m}}function ze(t){return M(this,t).delete(t)}function tr(t){return M(this,t).get(t)}function er(t){return M(this,t).has(t)}function rr(t,e){return M(this,t).set(t,e),this}v.prototype.clear=Qe;v.prototype.delete=ze;v.prototype.get=tr;v.prototype.has=er;v.prototype.set=rr;function E(t){this.__data__=new y(t)}function nr(){this.__data__=new y}function or(t){return this.__data__.delete(t)}function ar(t){return this.__data__.get(t)}function ir(t){return this.__data__.has(t)}function sr(t,e){var r=this.__data__;if(r instanceof y){var n=r.__data__;if(!j||n.length<he-1)return n.push([t,e]),this;r=this.__data__=new v(n)}return r.set(t,e),this}E.prototype.clear=nr;E.prototype.delete=or;E.prototype.get=ar;E.prototype.has=ir;E.prototype.set=sr;function cr(t,e){var r=z(t)||Vr(t)?we(t.length,String):[],n=r.length,a=!!n;for(var s in t)(e||b.call(t,s))&&!(a&&(s=="length"||jr(s,n)))&&r.push(s);return r}function Ut(t,e,r){var n=t[e];(!(b.call(t,e)&&Wt(n,r))||r===void 0&&!(e in t))&&(t[e]=r)}function F(t,e){for(var r=t.length;r--;)if(Wt(t[r][0],e))return r;return-1}function ur(t,e){return t&&Bt(e,tt(e),t)}function Z(t,e,r,n,a,s,f){var u;if(n&&(u=s?n(t,a,s,f):n(t)),u!==void 0)return u;if(!G(t))return t;var D=z(t);if(D){if(u=Tr(t),!e)return vr(t,u)}else{var o=$(t),h=o==L||o==pt;if(Nr(t))return dr(t,e);if(o==U||o==R||h&&!s){if(Vt(t))return s?t:{};if(u=wr(h?{}:t),!e)return Er(t,ur(u,t))}else{if(!i[o])return s?t:{};u=Ar(t,o,Z,e)}}f||(f=new E);var c=f.get(t);if(c)return c;if(f.set(t,u),!D)var p=r?Or(t):tt(t);return Oe(p||t,function(l,g){p&&(g=l,l=t[g]),Ut(u,g,Z(l,e,r,n,g,t,f))}),u}function lr(t){return G(t)?Ve(t):{}}function fr(t,e,r){var n=e(t);return z(t)?n:Te(n,r(t))}function hr(t){return P.call(t)}function pr(t){if(!G(t)||Cr(t))return!1;var e=Xt(t)||Vt(t)?Ce:be;return e.test(_(t))}function gr(t){if(!Kt(t))return Pe(t);var e=[];for(var r in Object(t))b.call(t,r)&&r!="constructor"&&e.push(r);return e}function dr(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}function Q(t){var e=new t.constructor(t.byteLength);return new Gt(e).set(new Gt(t)),e}function yr(t,e){var r=e?Q(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}function br(t,e,r){var n=e?r(It(t),!0):It(t);return Dt(n,ve,new t.constructor)}function mr(t){var e=new t.constructor(t.source,ye.exec(t));return e.lastIndex=t.lastIndex,e}function $r(t,e,r){var n=e?r(Nt(t),!0):Nt(t);return Dt(n,Ee,new t.constructor)}function _r(t){return Lt?Object(Lt.call(t)):{}}function Sr(t,e){var r=e?Q(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function vr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}function Bt(t,e,r,n){r||(r={});for(var a=-1,s=e.length;++a<s;){var f=e[a],u=n?n(r[f],t[f],f,r,t):void 0;Ut(r,f,u===void 0?t[f]:u)}return r}function Er(t,e){return Bt(t,Jt(t),e)}function Or(t){return fr(t,tt,Jt)}function M(t,e){var r=t.__data__;return xr(e)?r[typeof e=="string"?"string":"hash"]:r.map}function O(t,e){var r=Ae(t,e);return pr(r)?r:void 0}var Jt=Ht?J(Ht,Object):Fr,$=hr;(W&&$(new W(new ArrayBuffer(1)))!=N||j&&$(new j)!=V||q&&$(q.resolve())!=dt||X&&$(new X)!=I||Y&&$(new Y)!=B)&&($=function(t){var e=P.call(t),r=e==U?t.constructor:void 0,n=r?_(r):void 0;if(n)switch(n){case Fe:return N;case Me:return V;case Ge:return dt;case He:return I;case Re:return B}return e});function Tr(t){var e=t.length,r=t.constructor(e);return e&&typeof t[0]=="string"&&b.call(t,"index")&&(r.index=t.index,r.input=t.input),r}function wr(t){return typeof t.constructor=="function"&&!Kt(t)?lr(De(t)):{}}function Ar(t,e,r,n){var a=t.constructor;switch(e){case $t:return Q(t);case ft:case ht:return new a(+t);case N:return yr(t,n);case _t:case St:case vt:case Et:case Ot:case Tt:case wt:case At:case jt:return Sr(t,n);case V:return br(t,n,r);case gt:case bt:return new a(t);case yt:return mr(t);case I:return $r(t,n,r);case mt:return _r(t)}}function jr(t,e){return e=e==null?lt:e,!!e&&(typeof t=="number"||me.test(t))&&t>-1&&t%1==0&&t<e}function xr(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Cr(t){return!!kt&&kt in t}function Kt(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||k;return t===r}function _(t){if(t!=null){try{return Pt.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function Dr(t){return Z(t,!0,!0)}function Wt(t,e){return t===e||t!==t&&e!==e}function Vr(t){return Ir(t)&&b.call(t,"callee")&&(!Ie.call(t,"callee")||P.call(t)==R)}var z=Array.isArray;function qt(t){return t!=null&&kr(t.length)&&!Xt(t)}function Ir(t){return Pr(t)&&qt(t)}var Nr=ke||Mr;function Xt(t){var e=G(t)?P.call(t):"";return e==L||e==pt}function kr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=lt}function G(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Pr(t){return!!t&&typeof t=="object"}function tt(t){return qt(t)?cr(t):gr(t)}function Fr(){return[]}function Mr(){return!1}T.exports=Dr});var te=it((tn,zt)=>{var Gr="[object Object]";function Hr(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function Rr(t,e){return function(r){return t(e(r))}}var Lr=Function.prototype,Zt=Object.prototype,Qt=Lr.toString,Ur=Zt.hasOwnProperty,Br=Qt.call(Object),Jr=Zt.toString,Kr=Rr(Object.getPrototypeOf,Object);function Wr(t){return!!t&&typeof t=="object"}function qr(t){if(!Wr(t)||Jr.call(t)!=Gr||Hr(t))return!1;var e=Kr(t);if(e===null)return!0;var r=Ur.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Qt.call(r)==Br}zt.exports=qr});var Qr={};le(Qr,{traverse:()=>Zr,version:()=>Yr});var H=ct(Yt(),1),re=ct(te(),1);var ee="3.0.10";var Yr=ee;function Zr(t,e,r=0){function n(o){return typeof o=="string"&&o[0]==="."?o.slice(1):o}let a={now:!1},s=[];function f(o,h,c,p){if(c=S({},c),c.depth+=1,Array.isArray(o))for(let l=0,g=o.length;l<g&&!p.now;l++){let et=`${c.path}.${l}`;c.parent=(0,H.default)(o),c.parentType="array",h(o[l],void 0,A(S({},c),{path:n(et)}),p),f(o[l],h,A(S({},c),{path:n(et)}),p)}else if((0,re.default)(o))for(let l in o){if(p.now&&l!=null)break;let g=`${c.path}.${l}`;c.depth===0&&l!=null&&(c.topmostKey=l),c.parent=(0,H.default)(o),c.parentType="object",h(l,o[l],A(S({},c),{path:n(g)}),p),f(o[l],h,A(S({},c),{path:n(g)}),p)}return o}function u(){let o=s.shift();o[2].next=[];for(let h=0;h<r&&s[h];h++)o[2].next.push((0,H.default)([s[h][0],s[h][1],s[h][2]]));e(...o)}function D(...o){s.push([...o]),s.length>r&&u()}if(f(t,D,{depth:-1,path:""},a),s.length)for(let o=0,h=s.length;o<h;o++)u()}return fe(Qr);})();
|
package/examples/_quickTake.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ast-monkey-traverse-with-lookahead",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.10",
|
|
4
4
|
"description": "Utility library to traverse AST, reports upcoming values",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -45,39 +45,28 @@
|
|
|
45
45
|
},
|
|
46
46
|
"types": "types/index.d.ts",
|
|
47
47
|
"scripts": {
|
|
48
|
-
"build": "
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
|
|
61
|
-
"republish": "npm publish || :",
|
|
62
|
-
"tap": "tap",
|
|
63
|
-
"pretest": "npm run build",
|
|
64
|
-
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
65
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
66
|
-
"tsc": "tsc",
|
|
67
|
-
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
48
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
49
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
50
|
+
"dts": "rollup -c",
|
|
51
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
52
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
53
|
+
"letspublish": "yarn publish || :",
|
|
54
|
+
"lint": "eslint . --fix",
|
|
55
|
+
"perf": "node perf/check.js",
|
|
56
|
+
"prepare": "echo 'ready'",
|
|
57
|
+
"pretest": "yarn run lect && yarn run build",
|
|
58
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
59
|
+
"unit": "uvu test"
|
|
68
60
|
},
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"--no-warnings",
|
|
77
|
-
"--experimental-loader",
|
|
78
|
-
"@istanbuljs/esm-loader-hook"
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
63
|
+
},
|
|
64
|
+
"c8": {
|
|
65
|
+
"check-coverage": true,
|
|
66
|
+
"exclude": [
|
|
67
|
+
"**/test/**/*.*"
|
|
79
68
|
],
|
|
80
|
-
"
|
|
69
|
+
"lines": 100
|
|
81
70
|
},
|
|
82
71
|
"lect": {
|
|
83
72
|
"licence": {
|
|
@@ -85,61 +74,15 @@
|
|
|
85
74
|
""
|
|
86
75
|
]
|
|
87
76
|
},
|
|
88
|
-
"
|
|
89
|
-
"various": {
|
|
90
|
-
"devDependencies": [
|
|
91
|
-
"@types/lodash.clonedeep",
|
|
92
|
-
"@types/lodash.isplainobject"
|
|
93
|
-
]
|
|
94
|
-
}
|
|
77
|
+
"various": {}
|
|
95
78
|
},
|
|
96
79
|
"dependencies": {
|
|
97
|
-
"@babel/runtime": "^7.16.0",
|
|
98
80
|
"lodash.clonedeep": "^4.5.0",
|
|
99
81
|
"lodash.isplainobject": "^4.0.6"
|
|
100
82
|
},
|
|
101
83
|
"devDependencies": {
|
|
102
|
-
"@babel/cli": "^7.16.0",
|
|
103
|
-
"@babel/core": "^7.16.0",
|
|
104
|
-
"@babel/node": "^7.16.0",
|
|
105
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
106
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
107
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
108
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
109
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
110
|
-
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
111
|
-
"@babel/preset-env": "^7.16.0",
|
|
112
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
113
|
-
"@babel/register": "^7.16.0",
|
|
114
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
115
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
116
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
117
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
118
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
119
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
120
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
121
84
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
122
85
|
"@types/lodash.isplainobject": "^4.0.6",
|
|
123
|
-
"
|
|
124
|
-
"@types/tap": "^15.0.5",
|
|
125
|
-
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
126
|
-
"@typescript-eslint/parser": "^5.3.0",
|
|
127
|
-
"core-js": "^3.19.1",
|
|
128
|
-
"cross-env": "^7.0.3",
|
|
129
|
-
"eslint": "^8.1.0",
|
|
130
|
-
"lect": "^0.18.4",
|
|
131
|
-
"lodash.isequal": "^4.5.0",
|
|
132
|
-
"rollup": "^2.59.0",
|
|
133
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
134
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
135
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
136
|
-
"rollup-plugin-dts": "^4.0.0",
|
|
137
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
138
|
-
"tap": "^15.0.10",
|
|
139
|
-
"tslib": "^2.3.1",
|
|
140
|
-
"typescript": "^4.4.4"
|
|
141
|
-
},
|
|
142
|
-
"engines": {
|
|
143
|
-
"node": ">=12"
|
|
86
|
+
"lodash.isequal": "^4.5.0"
|
|
144
87
|
}
|
|
145
88
|
}
|
package/types/index.d.ts
CHANGED
|
File without changes
|
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport { traverse } from \"ast-monkey-traverse-with-lookahead\";\n\nconst input = [\n {\n a: \"b\",\n },\n {\n c: \"d\",\n },\n {\n e: \"f\",\n },\n];\nconst gathered = [];\n\n// callback interface:\ntraverse(\n input,\n (key1, val1, innerObj) => {\n gathered.push([key1, val1, innerObj]);\n },\n 1 // <---------------- report one upcoming value\n);\n\nassert.deepEqual(gathered, [\n // ===================\n [\n {\n a: \"b\",\n },\n undefined,\n {\n depth: 0,\n path: \"0\",\n parent: [\n {\n a: \"b\",\n },\n {\n c: \"d\",\n },\n {\n e: \"f\",\n },\n ],\n parentType: \"array\",\n next: [\n [\n \"a\",\n \"b\",\n {\n depth: 1,\n path: \"0.a\",\n parent: {\n a: \"b\",\n },\n parentType: \"object\",\n },\n ],\n ],\n },\n ],\n // ===================\n [\n \"a\",\n \"b\",\n {\n depth: 1,\n path: \"0.a\",\n parent: {\n a: \"b\",\n },\n parentType: \"object\",\n next: [\n [\n {\n c: \"d\",\n },\n undefined,\n {\n depth: 0,\n path: \"1\",\n parent: [\n {\n a: \"b\",\n },\n {\n c: \"d\",\n },\n {\n e: \"f\",\n },\n ],\n parentType: \"array\",\n },\n ],\n ],\n },\n ],\n // ===================\n [\n {\n c: \"d\",\n },\n undefined,\n {\n depth: 0,\n path: \"1\",\n parent: [\n {\n a: \"b\",\n },\n {\n c: \"d\",\n },\n {\n e: \"f\",\n },\n ],\n parentType: \"array\",\n next: [\n [\n \"c\",\n \"d\",\n {\n depth: 1,\n path: \"1.c\",\n parent: {\n c: \"d\",\n },\n parentType: \"object\",\n },\n ],\n ],\n },\n ],\n // ===================\n [\n \"c\",\n \"d\",\n {\n depth: 1,\n path: \"1.c\",\n parent: {\n c: \"d\",\n },\n parentType: \"object\",\n next: [\n [\n {\n e: \"f\",\n },\n undefined,\n {\n depth: 0,\n path: \"2\",\n parent: [\n {\n a: \"b\",\n },\n {\n c: \"d\",\n },\n {\n e: \"f\",\n },\n ],\n parentType: \"array\",\n },\n ],\n ],\n },\n ],\n // ===================\n [\n {\n e: \"f\",\n },\n undefined,\n {\n depth: 0,\n path: \"2\",\n parent: [\n {\n a: \"b\",\n },\n {\n c: \"d\",\n },\n {\n e: \"f\",\n },\n ],\n parentType: \"array\",\n next: [\n [\n \"e\",\n \"f\",\n {\n depth: 1,\n path: \"2.e\",\n parent: {\n e: \"f\",\n },\n parentType: \"object\",\n },\n ],\n ],\n },\n ],\n // ===================\n [\n \"e\",\n \"f\",\n {\n depth: 1,\n path: \"2.e\",\n parent: {\n e: \"f\",\n },\n parentType: \"object\",\n next: [],\n },\n ],\n // ===================\n]);"}}
|