ast-monkey-traverse-with-lookahead 3.0.2 → 3.0.6

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,12 +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.1 (2021-09-13)
7
-
8
- ### Bug Fixes
9
-
10
- - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
11
-
12
6
  ## 3.0.0 (2021-09-09)
13
7
 
14
8
  ### Features
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-%YEAR% Roy Revelt and other contributors
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
@@ -1,7 +1,7 @@
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.2
4
+ * @version 3.0.6
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-monkey-traverse-with-lookahead/}
@@ -10,87 +10,78 @@
10
10
  import clone from 'lodash.clonedeep';
11
11
  import isObj from 'lodash.isplainobject';
12
12
 
13
- var version$1 = "3.0.2";
13
+ var version$1 = "3.0.6";
14
14
 
15
15
  const version = version$1;
16
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;
17
+ function trimFirstDot(str) {
18
+ if (typeof str === "string" && str[0] === ".") {
19
+ return str.slice(1);
35
20
  }
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;
21
+ return str;
22
+ }
23
+ const stop1 = { now: false };
24
+ const stash = [];
25
+ function traverseInner(tree, callback, innerObj, stop) {
26
+ innerObj = { ...innerObj };
27
+ innerObj.depth += 1;
28
+ if (Array.isArray(tree)) {
29
+ for (let i = 0, len = tree.length; i < len; i++) {
30
+ if (stop.now) {
31
+ break;
32
+ }
33
+ const path = `${innerObj.path}.${i}`;
34
+ innerObj.parent = clone(tree);
35
+ innerObj.parentType = "array";
36
+ callback(tree[i], undefined, { ...innerObj, path: trimFirstDot(path) }, stop);
37
+ traverseInner(tree[i], callback, { ...innerObj, path: trimFirstDot(path) }, stop);
38
+ }
50
39
  }
51
- const path = `${innerObj.path}.${key}`;
52
- if (innerObj.depth === 0 && key != null) {
53
- innerObj.topmostKey = key;
40
+ else if (isObj(tree)) {
41
+ for (const key in tree) {
42
+ if (stop.now && key != null) {
43
+ break;
44
+ }
45
+ const path = `${innerObj.path}.${key}`;
46
+ if (innerObj.depth === 0 && key != null) {
47
+ innerObj.topmostKey = key;
48
+ }
49
+ innerObj.parent = clone(tree);
50
+ innerObj.parentType = "object";
51
+ callback(key, tree[key], { ...innerObj, path: trimFirstDot(path) }, stop);
52
+ traverseInner(tree[key], callback, { ...innerObj, path: trimFirstDot(path) }, stop);
53
+ }
54
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
- }
55
+ return tree;
64
56
  }
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
- }
57
+ function reportFirstFromStash() {
58
+ const currentElem = stash.shift();
59
+ currentElem[2].next = [];
60
+ for (let i = 0; i < lookahead; i++) {
61
+ if (stash[i]) {
62
+ currentElem[2].next.push(clone([stash[i][0], stash[i][1], stash[i][2]]));
63
+ }
64
+ else {
65
+ break;
66
+ }
67
+ }
68
+ cb1(...currentElem);
76
69
  }
77
- cb1(...currentElem);
78
- }
79
- function intermediary(...incoming) {
80
- stash.push([...incoming]);
81
- if (stash.length > lookahead) {
82
- reportFirstFromStash();
70
+ function intermediary(...incoming) {
71
+ stash.push([...incoming]);
72
+ if (stash.length > lookahead) {
73
+ reportFirstFromStash();
74
+ }
83
75
  }
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();
76
+ traverseInner(tree1, intermediary, {
77
+ depth: -1,
78
+ path: "",
79
+ }, stop1);
80
+ if (stash.length) {
81
+ for (let i = 0, len = stash.length; i < len; i++) {
82
+ reportFirstFromStash();
83
+ }
92
84
  }
93
- }
94
85
  }
95
86
 
96
87
  export { traverse, 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.2
4
+ * @version 3.0.6
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.2",Object.defineProperty(t,"__esModule",{value:!0})}));
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.6",Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ast-monkey-traverse-with-lookahead",
3
- "version": "3.0.2",
3
+ "version": "3.0.6",
4
4
  "description": "Utility library to traverse AST, reports upcoming values",
5
5
  "keywords": [
6
6
  "ast",
@@ -46,9 +46,10 @@
46
46
  "types": "types/index.d.ts",
47
47
  "scripts": {
48
48
  "build": "rollup -c",
49
- "esbuild": "node '../../scripts/esbuild.js'",
50
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
51
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
49
+ "build:esbuild": "node '../../scripts/esbuild.js'",
50
+ "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
51
+ "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
52
+ "clean_types": "../../scripts/cleanTypes.js",
52
53
  "dev": "rollup -c --dev",
53
54
  "devunittest": "npm run dev && tap --only -R 'base'",
54
55
  "format": "npm run lect && npm run prettier && npm run lint",
@@ -58,20 +59,15 @@
58
59
  "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
59
60
  "republish": "npm publish || :",
60
61
  "tap": "tap",
61
- "tsc": "tsc",
62
62
  "pretest": "npm run build",
63
- "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
63
+ "test": "npm run test:ci && npm run perf",
64
+ "test:ci": "npm run unittest && npm run test:examples && npm run format",
64
65
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
65
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
66
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
67
- "clean_types": "../../scripts/cleanTypes.js"
66
+ "tsc": "tsc",
67
+ "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
68
68
  },
69
69
  "tap": {
70
70
  "check-coverage": false,
71
- "coverage-report": [
72
- "json-summary",
73
- "text"
74
- ],
75
71
  "node-arg": [
76
72
  "--no-warnings",
77
73
  "--experimental-loader",
@@ -94,52 +90,52 @@
94
90
  }
95
91
  },
96
92
  "dependencies": {
97
- "@babel/runtime": "^7.15.4",
93
+ "@babel/runtime": "^7.16.3",
98
94
  "lodash.clonedeep": "^4.5.0",
99
95
  "lodash.isplainobject": "^4.0.6"
100
96
  },
101
97
  "devDependencies": {
102
- "@babel/cli": "^7.15.4",
103
- "@babel/core": "^7.15.5",
104
- "@babel/node": "^7.15.4",
105
- "@babel/plugin-external-helpers": "^7.14.5",
106
- "@babel/plugin-proposal-class-properties": "^7.14.5",
107
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
108
- "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
109
- "@babel/plugin-proposal-optional-chaining": "^7.14.5",
110
- "@babel/plugin-transform-runtime": "^7.15.0",
111
- "@babel/preset-env": "^7.15.6",
112
- "@babel/preset-typescript": "^7.15.0",
113
- "@babel/register": "^7.15.3",
98
+ "@babel/cli": "^7.16.0",
99
+ "@babel/core": "^7.16.0",
100
+ "@babel/node": "^7.16.0",
101
+ "@babel/plugin-external-helpers": "^7.16.0",
102
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
103
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
104
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
105
+ "@babel/plugin-proposal-optional-chaining": "^7.16.0",
106
+ "@babel/plugin-transform-runtime": "^7.16.4",
107
+ "@babel/preset-env": "^7.16.4",
108
+ "@babel/preset-typescript": "^7.16.0",
109
+ "@babel/register": "^7.16.0",
114
110
  "@istanbuljs/esm-loader-hook": "^0.1.2",
115
111
  "@rollup/plugin-babel": "^5.3.0",
116
- "@rollup/plugin-commonjs": "^20.0.0",
112
+ "@rollup/plugin-commonjs": "^21.0.1",
117
113
  "@rollup/plugin-json": "^4.1.0",
118
- "@rollup/plugin-node-resolve": "^13.0.4",
114
+ "@rollup/plugin-node-resolve": "^13.0.6",
119
115
  "@rollup/plugin-strip": "^2.1.0",
120
- "@rollup/plugin-typescript": "^8.2.5",
116
+ "@rollup/plugin-typescript": "^8.3.0",
121
117
  "@types/lodash.clonedeep": "^4.5.6",
122
118
  "@types/lodash.isplainobject": "^4.0.6",
123
- "@types/node": "^16.9.1",
119
+ "@types/node": "^16.11.9",
124
120
  "@types/tap": "^15.0.5",
125
- "@typescript-eslint/eslint-plugin": "^4.31.0",
126
- "@typescript-eslint/parser": "^4.31.0",
127
- "core-js": "^3.17.3",
121
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
122
+ "@typescript-eslint/parser": "^5.4.0",
123
+ "core-js": "^3.19.1",
128
124
  "cross-env": "^7.0.3",
129
- "eslint": "^7.32.0",
130
- "lect": "^0.18.2",
125
+ "eslint": "^8.3.0",
126
+ "lect": "^0.18.6",
131
127
  "lodash.isequal": "^4.5.0",
132
- "rollup": "^2.56.3",
128
+ "rollup": "^2.60.0",
133
129
  "rollup-plugin-ascii": "^0.0.3",
134
130
  "rollup-plugin-banner": "^0.2.1",
135
131
  "rollup-plugin-cleanup": "^3.2.1",
136
- "rollup-plugin-dts": "^4.0.0",
132
+ "rollup-plugin-dts": "^4.0.1",
137
133
  "rollup-plugin-terser": "^7.0.2",
138
- "tap": "^15.0.9",
134
+ "tap": "^15.1.2",
139
135
  "tslib": "^2.3.1",
140
- "typescript": "^4.4.3"
136
+ "typescript": "^4.5.2"
141
137
  },
142
138
  "engines": {
143
- "node": ">=12"
139
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
144
140
  }
145
141
  }