ast-monkey-traverse 3.1.2 → 3.1.4

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
@@ -17,7 +17,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
17
17
 
18
18
  ### BREAKING CHANGES
19
19
 
20
- - programs now are in ES Modules and won't work with Common JS require()
20
+ - programs now are in ES Modules and won't work with Common JS `require()`
21
21
 
22
22
  ## 2.1.0 (2021-05-24)
23
23
 
@@ -33,9 +33,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
33
33
 
34
34
  ## 2.0.1 (2021-01-28)
35
35
 
36
- ### Bug Fixes
36
+ ### Fixed
37
37
 
38
- - add testStats to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
38
+ - add `testStats` to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
39
39
 
40
40
  ## 2.0.0 (2021-01-23)
41
41
 
@@ -49,7 +49,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
49
49
 
50
50
  ## 1.13.0 (2020-11-28)
51
51
 
52
- Accidental version bump during migration to sourcehut. Sorry about that.
52
+ Accidental version bump during migration to SourceHut. Sorry about that.
53
53
 
54
54
  ## 1.12.0 (2019-11-27)
55
55
 
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name ast-monkey-traverse
3
3
  * @fileoverview Utility library to traverse AST
4
- * @version 3.1.2
4
+ * @version 3.1.4
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-monkey-traverse/}
8
8
  */
9
9
 
10
- import p from"lodash.clonedeep";import g from"lodash.isplainobject";import{parent as m}from"ast-monkey-util";var u="3.1.2";var D=u;function k(c,y){let d={now:!1};function i($,l,b,n){let r=p($),s,t={depth:-1,path:"",...b};if(t.depth+=1,Array.isArray(r))for(let e=0,o=r.length;e<o&&!n.now;e++){let a=t.path?`${t.path}.${e}`:`${e}`;r[e]!==void 0?(t.parent=p(r),t.parentType="array",t.parentKey=m(a),s=i(l(r[e],void 0,{...t,path:a},n),l,{...t,path:a},n),Number.isNaN(s)&&e<r.length?(r.splice(e,1),e-=1):r[e]=s):r.splice(e,1)}else if(g(r))for(let e in r){if(n.now&&e!=null)break;let o=t.path?`${t.path}.${e}`:e;t.depth===0&&e!=null&&(t.topmostKey=e),t.parent=p(r),t.parentType="object",t.parentKey=m(o),s=i(l(e,r[e],{...t,path:o},n),l,{...t,path:o},n),Number.isNaN(s)?delete r[e]:r[e]=s}return r}return i(c,y,{},d)}export{k as traverse,D as version};
10
+ import p from"lodash.clonedeep";import g from"lodash.isplainobject";import{parent as m}from"ast-monkey-util";var u="3.1.4";var D=u;function k(c,y){let d={now:!1};function i($,l,b,n){let r=p($),s,t={depth:-1,path:"",...b};if(t.depth+=1,Array.isArray(r))for(let e=0,o=r.length;e<o&&!n.now;e++){let a=t.path?`${t.path}.${e}`:`${e}`;r[e]!==void 0?(t.parent=p(r),t.parentType="array",t.parentKey=m(a),s=i(l(r[e],void 0,{...t,path:a},n),l,{...t,path:a},n),Number.isNaN(s)&&e<r.length?(r.splice(e,1),e-=1):r[e]=s):r.splice(e,1)}else if(g(r))for(let e in r){if(n.now&&e!=null)break;let o=t.path?`${t.path}.${e}`:e;t.depth===0&&e!=null&&(t.topmostKey=e),t.parent=p(r),t.parentType="object",t.parentKey=m(o),s=i(l(e,r[e],{...t,path:o},n),l,{...t,path:o},n),Number.isNaN(s)?delete r[e]:r[e]=s}return r}return i(c,y,{},d)}export{k as traverse,D as version};
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * @name ast-monkey-traverse
3
3
  * @fileoverview Utility library to traverse AST
4
- * @version 3.1.2
4
+ * @version 3.1.4
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-monkey-traverse/}
8
8
  */
9
9
 
10
- "use strict";var astMonkeyTraverse=(()=>{var re=Object.create;var T=Object.defineProperty,ne=Object.defineProperties,oe=Object.getOwnPropertyDescriptor,ie=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertyNames,rt=Object.getOwnPropertySymbols,se=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var nt=(t,e,r)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v=(t,e)=>{for(var r in e||(e={}))ot.call(e,r)&&nt(t,r,e[r]);if(rt)for(var r of rt(e))ce.call(e,r)&&nt(t,r,e[r]);return t},w=(t,e)=>ne(t,ie(e));var it=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ue=(t,e)=>{for(var r in e)T(t,r,{get:e[r],enumerable:!0})},at=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ae(e))!ot.call(t,o)&&o!==r&&T(t,o,{get:()=>e[o],enumerable:!(n=oe(e,o))||n.enumerable});return t};var st=(t,e,r)=>(r=t!=null?re(se(t)):{},at(e||!t||!t.__esModule?T(r,"default",{value:t,enumerable:!0}):r,t)),le=t=>at(T({},"__esModule",{value:!0}),t);var Yt=it((A,j)=>{var fe=200,mt="__lodash_hash_undefined__",$t=9007199254740991,q="[object Arguments]",pe="[object Array]",vt="[object Boolean]",jt="[object Date]",de="[object Error]",Y="[object Function]",Ot="[object GeneratorFunction]",P="[object Map]",St="[object Number]",X="[object Object]",ct="[object Promise]",xt="[object RegExp]",D="[object Set]",Tt="[object String]",wt="[object Symbol]",k="[object WeakMap]",At="[object ArrayBuffer]",N="[object DataView]",Et="[object Float32Array]",Ct="[object Float64Array]",It="[object Int8Array]",Pt="[object Int16Array]",Dt="[object Int32Array]",Nt="[object Uint8Array]",Kt="[object Uint8ClampedArray]",Vt="[object Uint16Array]",Mt="[object Uint32Array]",he=/[\\^$.*+?()[\]{}|]/g,ge=/\w*$/,be=/^\[object .+?Constructor\]$/,ye=/^(?:0|[1-9]\d*)$/,i={};i[q]=i[pe]=i[At]=i[N]=i[vt]=i[jt]=i[Et]=i[Ct]=i[It]=i[Pt]=i[Dt]=i[P]=i[St]=i[X]=i[xt]=i[D]=i[Tt]=i[wt]=i[Nt]=i[Kt]=i[Vt]=i[Mt]=!0;i[de]=i[Y]=i[k]=!1;var _e=typeof global=="object"&&global&&global.Object===Object&&global,me=typeof self=="object"&&self&&self.Object===Object&&self,d=_e||me||Function("return this")(),Rt=typeof A=="object"&&A&&!A.nodeType&&A,ut=Rt&&typeof j=="object"&&j&&!j.nodeType&&j,$e=ut&&ut.exports===Rt;function ve(t,e){return t.set(e[0],e[1]),t}function je(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 Se(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function Ut(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 xe(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function Te(t,e){return t==null?void 0:t[e]}function Bt(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function lt(t){var e=-1,r=Array(t.size);return t.forEach(function(n,o){r[++e]=[o,n]}),r}function Z(t,e){return function(r){return t(e(r))}}function ft(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var we=Array.prototype,Ae=Function.prototype,K=Object.prototype,G=d["__core-js_shared__"],pt=function(){var t=/[^.]+$/.exec(G&&G.keys&&G.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Gt=Ae.toString,b=K.hasOwnProperty,V=K.toString,Ee=RegExp("^"+Gt.call(b).replace(he,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),dt=$e?d.Buffer:void 0,ht=d.Symbol,gt=d.Uint8Array,Ce=Z(Object.getPrototypeOf,Object),Ie=Object.create,Pe=K.propertyIsEnumerable,De=we.splice,bt=Object.getOwnPropertySymbols,Ne=dt?dt.isBuffer:void 0,Ke=Z(Object.keys,Object),F=x(d,"DataView"),E=x(d,"Map"),H=x(d,"Promise"),L=x(d,"Set"),J=x(d,"WeakMap"),C=x(Object,"create"),Ve=$(F),Me=$(E),Re=$(H),Ue=$(L),Be=$(J),yt=ht?ht.prototype:void 0,_t=yt?yt.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 Ge(){this.__data__=C?C(null):{}}function ke(t){return this.has(t)&&delete this.__data__[t]}function Fe(t){var e=this.__data__;if(C){var r=e[t];return r===mt?void 0:r}return b.call(e,t)?e[t]:void 0}function He(t){var e=this.__data__;return C?e[t]!==void 0:b.call(e,t)}function Le(t,e){var r=this.__data__;return r[t]=C&&e===void 0?mt:e,this}m.prototype.clear=Ge;m.prototype.delete=ke;m.prototype.get=Fe;m.prototype.has=He;m.prototype.set=Le;function h(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 Je(){this.__data__=[]}function We(t){var e=this.__data__,r=M(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():De.call(e,r,1),!0}function qe(t){var e=this.__data__,r=M(e,t);return r<0?void 0:e[r][1]}function Ye(t){return M(this.__data__,t)>-1}function Xe(t,e){var r=this.__data__,n=M(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}h.prototype.clear=Je;h.prototype.delete=We;h.prototype.get=qe;h.prototype.has=Ye;h.prototype.set=Xe;function O(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 Ze(){this.__data__={hash:new m,map:new(E||h),string:new m}}function Qe(t){return R(this,t).delete(t)}function ze(t){return R(this,t).get(t)}function tr(t){return R(this,t).has(t)}function er(t,e){return R(this,t).set(t,e),this}O.prototype.clear=Ze;O.prototype.delete=Qe;O.prototype.get=ze;O.prototype.has=tr;O.prototype.set=er;function S(t){this.__data__=new h(t)}function rr(){this.__data__=new h}function nr(t){return this.__data__.delete(t)}function or(t){return this.__data__.get(t)}function ir(t){return this.__data__.has(t)}function ar(t,e){var r=this.__data__;if(r instanceof h){var n=r.__data__;if(!E||n.length<fe-1)return n.push([t,e]),this;r=this.__data__=new O(n)}return r.set(t,e),this}S.prototype.clear=rr;S.prototype.delete=nr;S.prototype.get=or;S.prototype.has=ir;S.prototype.set=ar;function sr(t,e){var r=z(t)||Ir(t)?xe(t.length,String):[],n=r.length,o=!!n;for(var c in t)(e||b.call(t,c))&&!(o&&(c=="length"||wr(c,n)))&&r.push(c);return r}function kt(t,e,r){var n=t[e];(!(b.call(t,e)&&Jt(n,r))||r===void 0&&!(e in t))&&(t[e]=r)}function M(t,e){for(var r=t.length;r--;)if(Jt(t[r][0],e))return r;return-1}function cr(t,e){return t&&Ft(e,tt(e),t)}function W(t,e,r,n,o,c,f){var s;if(n&&(s=c?n(t,o,c,f):n(t)),s!==void 0)return s;if(!U(t))return t;var l=z(t);if(l){if(s=Sr(t),!e)return vr(t,s)}else{var p=_(t),u=p==Y||p==Ot;if(Dr(t))return hr(t,e);if(p==X||p==q||u&&!c){if(Bt(t))return c?t:{};if(s=xr(u?{}:t),!e)return jr(t,cr(s,t))}else{if(!i[p])return c?t:{};s=Tr(t,p,W,e)}}f||(f=new S);var a=f.get(t);if(a)return a;if(f.set(t,s),!l)var g=r?Or(t):tt(t);return Oe(g||t,function(y,I){g&&(I=y,y=t[I]),kt(s,I,W(y,e,r,n,I,t,f))}),s}function ur(t){return U(t)?Ie(t):{}}function lr(t,e,r){var n=e(t);return z(t)?n:Se(n,r(t))}function fr(t){return V.call(t)}function pr(t){if(!U(t)||Er(t))return!1;var e=qt(t)||Bt(t)?Ee:be;return e.test($(t))}function dr(t){if(!Lt(t))return Ke(t);var e=[];for(var r in Object(t))b.call(t,r)&&r!="constructor"&&e.push(r);return e}function hr(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 gr(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(lt(t),!0):lt(t);return Ut(n,ve,new t.constructor)}function yr(t){var e=new t.constructor(t.source,ge.exec(t));return e.lastIndex=t.lastIndex,e}function _r(t,e,r){var n=e?r(ft(t),!0):ft(t);return Ut(n,je,new t.constructor)}function mr(t){return _t?Object(_t.call(t)):{}}function $r(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 Ft(t,e,r,n){r||(r={});for(var o=-1,c=e.length;++o<c;){var f=e[o],s=n?n(r[f],t[f],f,r,t):void 0;kt(r,f,s===void 0?t[f]:s)}return r}function jr(t,e){return Ft(t,Ht(t),e)}function Or(t){return lr(t,tt,Ht)}function R(t,e){var r=t.__data__;return Ar(e)?r[typeof e=="string"?"string":"hash"]:r.map}function x(t,e){var r=Te(t,e);return pr(r)?r:void 0}var Ht=bt?Z(bt,Object):Vr,_=fr;(F&&_(new F(new ArrayBuffer(1)))!=N||E&&_(new E)!=P||H&&_(H.resolve())!=ct||L&&_(new L)!=D||J&&_(new J)!=k)&&(_=function(t){var e=V.call(t),r=e==X?t.constructor:void 0,n=r?$(r):void 0;if(n)switch(n){case Ve:return N;case Me:return P;case Re:return ct;case Ue:return D;case Be:return k}return e});function Sr(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 xr(t){return typeof t.constructor=="function"&&!Lt(t)?ur(Ce(t)):{}}function Tr(t,e,r,n){var o=t.constructor;switch(e){case At:return Q(t);case vt:case jt:return new o(+t);case N:return gr(t,n);case Et:case Ct:case It:case Pt:case Dt:case Nt:case Kt:case Vt:case Mt:return $r(t,n);case P:return br(t,n,r);case St:case Tt:return new o(t);case xt:return yr(t);case D:return _r(t,n,r);case wt:return mr(t)}}function wr(t,e){return e=e==null?$t:e,!!e&&(typeof t=="number"||ye.test(t))&&t>-1&&t%1==0&&t<e}function Ar(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Er(t){return!!pt&&pt in t}function Lt(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||K;return t===r}function $(t){if(t!=null){try{return Gt.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function Cr(t){return W(t,!0,!0)}function Jt(t,e){return t===e||t!==t&&e!==e}function Ir(t){return Pr(t)&&b.call(t,"callee")&&(!Pe.call(t,"callee")||V.call(t)==q)}var z=Array.isArray;function Wt(t){return t!=null&&Nr(t.length)&&!qt(t)}function Pr(t){return Kr(t)&&Wt(t)}var Dr=Ne||Mr;function qt(t){var e=U(t)?V.call(t):"";return e==Y||e==Ot}function Nr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=$t}function U(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Kr(t){return!!t&&typeof t=="object"}function tt(t){return Wt(t)?sr(t):dr(t)}function Vr(){return[]}function Mr(){return!1}j.exports=Cr});var zt=it((tn,Qt)=>{var Rr="[object Object]";function Ur(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function Br(t,e){return function(r){return t(e(r))}}var Gr=Function.prototype,Xt=Object.prototype,Zt=Gr.toString,kr=Xt.hasOwnProperty,Fr=Zt.call(Object),Hr=Xt.toString,Lr=Br(Object.getPrototypeOf,Object);function Jr(t){return!!t&&typeof t=="object"}function Wr(t){if(!Jr(t)||Hr.call(t)!=Rr||Ur(t))return!1;var e=Lr(t);if(e===null)return!0;var r=kr.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Zt.call(r)==Fr}Qt.exports=Wr});var Qr={};ue(Qr,{traverse:()=>Zr,version:()=>Xr});var B=st(Yt(),1),ee=st(zt(),1);function qr(t){if(t.includes(".")){let e=t.lastIndexOf(".");if(!t.slice(0,e).includes("."))return t.slice(0,e);for(let r=e-1;r--;)if(t[r]===".")return t.slice(r+1,e)}return null}var et=qr;var te="3.1.2";var Xr=te;function Zr(t,e){let r={now:!1};function n(o,c,f,s){let l=(0,B.default)(o),p,u=v({depth:-1,path:""},f);if(u.depth+=1,Array.isArray(l))for(let a=0,g=l.length;a<g&&!s.now;a++){let y=u.path?`${u.path}.${a}`:`${a}`;l[a]!==void 0?(u.parent=(0,B.default)(l),u.parentType="array",u.parentKey=et(y),p=n(c(l[a],void 0,w(v({},u),{path:y}),s),c,w(v({},u),{path:y}),s),Number.isNaN(p)&&a<l.length?(l.splice(a,1),a-=1):l[a]=p):l.splice(a,1)}else if((0,ee.default)(l))for(let a in l){if(s.now&&a!=null)break;let g=u.path?`${u.path}.${a}`:a;u.depth===0&&a!=null&&(u.topmostKey=a),u.parent=(0,B.default)(l),u.parentType="object",u.parentKey=et(g),p=n(c(a,l[a],w(v({},u),{path:g}),s),c,w(v({},u),{path:g}),s),Number.isNaN(p)?delete l[a]:l[a]=p}return l}return n(t,e,{},r)}return le(Qr);})();
10
+ "use strict";var astMonkeyTraverse=(()=>{var re=Object.create;var T=Object.defineProperty,ne=Object.defineProperties,oe=Object.getOwnPropertyDescriptor,ie=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertyNames,rt=Object.getOwnPropertySymbols,se=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var nt=(t,e,r)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,v=(t,e)=>{for(var r in e||(e={}))ot.call(e,r)&&nt(t,r,e[r]);if(rt)for(var r of rt(e))ce.call(e,r)&&nt(t,r,e[r]);return t},w=(t,e)=>ne(t,ie(e));var it=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ue=(t,e)=>{for(var r in e)T(t,r,{get:e[r],enumerable:!0})},at=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ae(e))!ot.call(t,o)&&o!==r&&T(t,o,{get:()=>e[o],enumerable:!(n=oe(e,o))||n.enumerable});return t};var st=(t,e,r)=>(r=t!=null?re(se(t)):{},at(e||!t||!t.__esModule?T(r,"default",{value:t,enumerable:!0}):r,t)),le=t=>at(T({},"__esModule",{value:!0}),t);var Yt=it((A,j)=>{var fe=200,mt="__lodash_hash_undefined__",$t=9007199254740991,q="[object Arguments]",pe="[object Array]",vt="[object Boolean]",jt="[object Date]",de="[object Error]",Y="[object Function]",Ot="[object GeneratorFunction]",P="[object Map]",St="[object Number]",X="[object Object]",ct="[object Promise]",xt="[object RegExp]",D="[object Set]",Tt="[object String]",wt="[object Symbol]",G="[object WeakMap]",At="[object ArrayBuffer]",N="[object DataView]",Et="[object Float32Array]",Ct="[object Float64Array]",It="[object Int8Array]",Pt="[object Int16Array]",Dt="[object Int32Array]",Nt="[object Uint8Array]",Kt="[object Uint8ClampedArray]",Vt="[object Uint16Array]",Mt="[object Uint32Array]",he=/[\\^$.*+?()[\]{}|]/g,ge=/\w*$/,be=/^\[object .+?Constructor\]$/,ye=/^(?:0|[1-9]\d*)$/,i={};i[q]=i[pe]=i[At]=i[N]=i[vt]=i[jt]=i[Et]=i[Ct]=i[It]=i[Pt]=i[Dt]=i[P]=i[St]=i[X]=i[xt]=i[D]=i[Tt]=i[wt]=i[Nt]=i[Kt]=i[Vt]=i[Mt]=!0;i[de]=i[Y]=i[G]=!1;var _e=typeof global=="object"&&global&&global.Object===Object&&global,me=typeof self=="object"&&self&&self.Object===Object&&self,d=_e||me||Function("return this")(),Rt=typeof A=="object"&&A&&!A.nodeType&&A,ut=Rt&&typeof j=="object"&&j&&!j.nodeType&&j,$e=ut&&ut.exports===Rt;function ve(t,e){return t.set(e[0],e[1]),t}function je(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 Se(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function Ut(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 xe(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function Te(t,e){return t==null?void 0:t[e]}function Bt(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function lt(t){var e=-1,r=Array(t.size);return t.forEach(function(n,o){r[++e]=[o,n]}),r}function Z(t,e){return function(r){return t(e(r))}}function ft(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var we=Array.prototype,Ae=Function.prototype,K=Object.prototype,k=d["__core-js_shared__"],pt=function(){var t=/[^.]+$/.exec(k&&k.keys&&k.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),kt=Ae.toString,b=K.hasOwnProperty,V=K.toString,Ee=RegExp("^"+kt.call(b).replace(he,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),dt=$e?d.Buffer:void 0,ht=d.Symbol,gt=d.Uint8Array,Ce=Z(Object.getPrototypeOf,Object),Ie=Object.create,Pe=K.propertyIsEnumerable,De=we.splice,bt=Object.getOwnPropertySymbols,Ne=dt?dt.isBuffer:void 0,Ke=Z(Object.keys,Object),F=x(d,"DataView"),E=x(d,"Map"),H=x(d,"Promise"),L=x(d,"Set"),J=x(d,"WeakMap"),C=x(Object,"create"),Ve=$(F),Me=$(E),Re=$(H),Ue=$(L),Be=$(J),yt=ht?ht.prototype:void 0,_t=yt?yt.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 ke(){this.__data__=C?C(null):{}}function Ge(t){return this.has(t)&&delete this.__data__[t]}function Fe(t){var e=this.__data__;if(C){var r=e[t];return r===mt?void 0:r}return b.call(e,t)?e[t]:void 0}function He(t){var e=this.__data__;return C?e[t]!==void 0:b.call(e,t)}function Le(t,e){var r=this.__data__;return r[t]=C&&e===void 0?mt:e,this}m.prototype.clear=ke;m.prototype.delete=Ge;m.prototype.get=Fe;m.prototype.has=He;m.prototype.set=Le;function h(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 Je(){this.__data__=[]}function We(t){var e=this.__data__,r=M(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():De.call(e,r,1),!0}function qe(t){var e=this.__data__,r=M(e,t);return r<0?void 0:e[r][1]}function Ye(t){return M(this.__data__,t)>-1}function Xe(t,e){var r=this.__data__,n=M(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}h.prototype.clear=Je;h.prototype.delete=We;h.prototype.get=qe;h.prototype.has=Ye;h.prototype.set=Xe;function O(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 Ze(){this.__data__={hash:new m,map:new(E||h),string:new m}}function Qe(t){return R(this,t).delete(t)}function ze(t){return R(this,t).get(t)}function tr(t){return R(this,t).has(t)}function er(t,e){return R(this,t).set(t,e),this}O.prototype.clear=Ze;O.prototype.delete=Qe;O.prototype.get=ze;O.prototype.has=tr;O.prototype.set=er;function S(t){this.__data__=new h(t)}function rr(){this.__data__=new h}function nr(t){return this.__data__.delete(t)}function or(t){return this.__data__.get(t)}function ir(t){return this.__data__.has(t)}function ar(t,e){var r=this.__data__;if(r instanceof h){var n=r.__data__;if(!E||n.length<fe-1)return n.push([t,e]),this;r=this.__data__=new O(n)}return r.set(t,e),this}S.prototype.clear=rr;S.prototype.delete=nr;S.prototype.get=or;S.prototype.has=ir;S.prototype.set=ar;function sr(t,e){var r=z(t)||Ir(t)?xe(t.length,String):[],n=r.length,o=!!n;for(var c in t)(e||b.call(t,c))&&!(o&&(c=="length"||wr(c,n)))&&r.push(c);return r}function Gt(t,e,r){var n=t[e];(!(b.call(t,e)&&Jt(n,r))||r===void 0&&!(e in t))&&(t[e]=r)}function M(t,e){for(var r=t.length;r--;)if(Jt(t[r][0],e))return r;return-1}function cr(t,e){return t&&Ft(e,tt(e),t)}function W(t,e,r,n,o,c,f){var s;if(n&&(s=c?n(t,o,c,f):n(t)),s!==void 0)return s;if(!U(t))return t;var l=z(t);if(l){if(s=Sr(t),!e)return vr(t,s)}else{var p=_(t),u=p==Y||p==Ot;if(Dr(t))return hr(t,e);if(p==X||p==q||u&&!c){if(Bt(t))return c?t:{};if(s=xr(u?{}:t),!e)return jr(t,cr(s,t))}else{if(!i[p])return c?t:{};s=Tr(t,p,W,e)}}f||(f=new S);var a=f.get(t);if(a)return a;if(f.set(t,s),!l)var g=r?Or(t):tt(t);return Oe(g||t,function(y,I){g&&(I=y,y=t[I]),Gt(s,I,W(y,e,r,n,I,t,f))}),s}function ur(t){return U(t)?Ie(t):{}}function lr(t,e,r){var n=e(t);return z(t)?n:Se(n,r(t))}function fr(t){return V.call(t)}function pr(t){if(!U(t)||Er(t))return!1;var e=qt(t)||Bt(t)?Ee:be;return e.test($(t))}function dr(t){if(!Lt(t))return Ke(t);var e=[];for(var r in Object(t))b.call(t,r)&&r!="constructor"&&e.push(r);return e}function hr(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 gr(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(lt(t),!0):lt(t);return Ut(n,ve,new t.constructor)}function yr(t){var e=new t.constructor(t.source,ge.exec(t));return e.lastIndex=t.lastIndex,e}function _r(t,e,r){var n=e?r(ft(t),!0):ft(t);return Ut(n,je,new t.constructor)}function mr(t){return _t?Object(_t.call(t)):{}}function $r(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 Ft(t,e,r,n){r||(r={});for(var o=-1,c=e.length;++o<c;){var f=e[o],s=n?n(r[f],t[f],f,r,t):void 0;Gt(r,f,s===void 0?t[f]:s)}return r}function jr(t,e){return Ft(t,Ht(t),e)}function Or(t){return lr(t,tt,Ht)}function R(t,e){var r=t.__data__;return Ar(e)?r[typeof e=="string"?"string":"hash"]:r.map}function x(t,e){var r=Te(t,e);return pr(r)?r:void 0}var Ht=bt?Z(bt,Object):Vr,_=fr;(F&&_(new F(new ArrayBuffer(1)))!=N||E&&_(new E)!=P||H&&_(H.resolve())!=ct||L&&_(new L)!=D||J&&_(new J)!=G)&&(_=function(t){var e=V.call(t),r=e==X?t.constructor:void 0,n=r?$(r):void 0;if(n)switch(n){case Ve:return N;case Me:return P;case Re:return ct;case Ue:return D;case Be:return G}return e});function Sr(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 xr(t){return typeof t.constructor=="function"&&!Lt(t)?ur(Ce(t)):{}}function Tr(t,e,r,n){var o=t.constructor;switch(e){case At:return Q(t);case vt:case jt:return new o(+t);case N:return gr(t,n);case Et:case Ct:case It:case Pt:case Dt:case Nt:case Kt:case Vt:case Mt:return $r(t,n);case P:return br(t,n,r);case St:case Tt:return new o(t);case xt:return yr(t);case D:return _r(t,n,r);case wt:return mr(t)}}function wr(t,e){return e=e==null?$t:e,!!e&&(typeof t=="number"||ye.test(t))&&t>-1&&t%1==0&&t<e}function Ar(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Er(t){return!!pt&&pt in t}function Lt(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||K;return t===r}function $(t){if(t!=null){try{return kt.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function Cr(t){return W(t,!0,!0)}function Jt(t,e){return t===e||t!==t&&e!==e}function Ir(t){return Pr(t)&&b.call(t,"callee")&&(!Pe.call(t,"callee")||V.call(t)==q)}var z=Array.isArray;function Wt(t){return t!=null&&Nr(t.length)&&!qt(t)}function Pr(t){return Kr(t)&&Wt(t)}var Dr=Ne||Mr;function qt(t){var e=U(t)?V.call(t):"";return e==Y||e==Ot}function Nr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=$t}function U(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Kr(t){return!!t&&typeof t=="object"}function tt(t){return Wt(t)?sr(t):dr(t)}function Vr(){return[]}function Mr(){return!1}j.exports=Cr});var zt=it((tn,Qt)=>{var Rr="[object Object]";function Ur(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function Br(t,e){return function(r){return t(e(r))}}var kr=Function.prototype,Xt=Object.prototype,Zt=kr.toString,Gr=Xt.hasOwnProperty,Fr=Zt.call(Object),Hr=Xt.toString,Lr=Br(Object.getPrototypeOf,Object);function Jr(t){return!!t&&typeof t=="object"}function Wr(t){if(!Jr(t)||Hr.call(t)!=Rr||Ur(t))return!1;var e=Lr(t);if(e===null)return!0;var r=Gr.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Zt.call(r)==Fr}Qt.exports=Wr});var Qr={};ue(Qr,{traverse:()=>Zr,version:()=>Xr});var B=st(Yt(),1),ee=st(zt(),1);function qr(t){if(t.includes(".")){let e=t.lastIndexOf(".");if(!t.slice(0,e).includes("."))return t.slice(0,e);for(let r=e-1;r--;)if(t[r]===".")return t.slice(r+1,e)}return null}var et=qr;var te="3.1.4";var Xr=te;function Zr(t,e){let r={now:!1};function n(o,c,f,s){let l=(0,B.default)(o),p,u=v({depth:-1,path:""},f);if(u.depth+=1,Array.isArray(l))for(let a=0,g=l.length;a<g&&!s.now;a++){let y=u.path?`${u.path}.${a}`:`${a}`;l[a]!==void 0?(u.parent=(0,B.default)(l),u.parentType="array",u.parentKey=et(y),p=n(c(l[a],void 0,w(v({},u),{path:y}),s),c,w(v({},u),{path:y}),s),Number.isNaN(p)&&a<l.length?(l.splice(a,1),a-=1):l[a]=p):l.splice(a,1)}else if((0,ee.default)(l))for(let a in l){if(s.now&&a!=null)break;let g=u.path?`${u.path}.${a}`:a;u.depth===0&&a!=null&&(u.topmostKey=a),u.parent=(0,B.default)(l),u.parentType="object",u.parentKey=et(g),p=n(c(a,l[a],w(v({},u),{path:g}),s),c,w(v({},u),{path:g}),s),Number.isNaN(p)?delete l[a]:l[a]=p}return l}return n(t,e,{},r)}return le(Qr);})();
11
11
  /**
12
12
  * @name ast-monkey-util
13
13
  * @fileoverview Utility library of AST helper functions
14
- * @version 2.1.2
14
+ * @version 2.1.4
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/ast-monkey-util/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ast-monkey-traverse",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "description": "Utility library to traverse AST",
5
5
  "keywords": [
6
6
  "ast",
@@ -52,7 +52,7 @@
52
52
  "examples": "node '../../ops/scripts/run-examples.js'",
53
53
  "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
54
54
  "letspublish": "yarn publish || :",
55
- "lint": "eslint . --fix",
55
+ "lint": "eslint 'test/test.js' --fix",
56
56
  "perf": "node perf/check.js",
57
57
  "prepare": "echo 'ready'",
58
58
  "prettier": "prettier",
@@ -79,7 +79,7 @@
79
79
  }
80
80
  },
81
81
  "dependencies": {
82
- "ast-monkey-util": "^2.1.2",
82
+ "ast-monkey-util": "^2.1.4",
83
83
  "lodash.clonedeep": "^4.5.0",
84
84
  "lodash.isplainobject": "^4.0.6"
85
85
  },
@@ -1,42 +0,0 @@
1
- // Quick Take
2
-
3
- import { strict as assert } from "assert";
4
-
5
- import { traverse } from "../dist/ast-monkey-traverse.esm.js";
6
-
7
- const paths = [];
8
- const source = {
9
- a: {
10
- foo: {
11
- bar: [
12
- {
13
- foo: "c",
14
- },
15
- ],
16
- d: {
17
- e: {
18
- foo: "f",
19
- },
20
- },
21
- },
22
- },
23
- };
24
-
25
- traverse(source, (key, val, innerObj) => {
26
- // if currently an object is traversed, you get both "key" and "val"
27
- // if it's array, only "key" is present, "val" is undefined
28
- let current = val !== undefined ? val : key;
29
- if (
30
- // it's object (not array)
31
- val !== undefined &&
32
- // and has the key we need
33
- key === "foo"
34
- ) {
35
- // push the path to array in the outer scope
36
- paths.push(innerObj.path);
37
- }
38
- return current;
39
- });
40
-
41
- // notice object-path notation "a.foo.bar.0.foo" - array segments use dots too:
42
- assert.deepEqual(paths, ["a.foo", "a.foo.bar.0.foo", "a.foo.d.e.foo"]);
@@ -1,26 +0,0 @@
1
- // Compatible With `object-path`
2
-
3
- import { strict as assert } from "assert";
4
- import op from "object-path";
5
-
6
- import { traverse } from "../dist/ast-monkey-traverse.esm.js";
7
-
8
- const input = { a: "1", b: [{ c: "2" }] };
9
- Object.freeze(input); // let's freeze it, just for fun
10
- const result1 = [];
11
-
12
- // the full traversal would look like this:
13
- traverse(input, (key1, val1, innerObj) => {
14
- let current = val1 !== undefined ? val1 : key1;
15
- result1.push(innerObj.path);
16
- return current;
17
- });
18
-
19
- // notice the object-path notation is "b.0.c" not "b[0].c"
20
- assert.deepEqual(result1, ["a", "b", "b.0", "b.0.c"]);
21
-
22
- // each reported path is fully compatible with `object-path` get() method
23
- assert.deepEqual(op.get(input, "a"), "1");
24
- assert.deepEqual(op.get(input, "b"), [{ c: "2" }]);
25
- assert.deepEqual(op.get(input, "b.0"), { c: "2" });
26
- assert.deepEqual(op.get(input, "b.0.c"), "2");
@@ -1,29 +0,0 @@
1
- // Stop
2
-
3
- import { strict as assert } from "assert";
4
-
5
- import { traverse } from "../dist/ast-monkey-traverse.esm.js";
6
-
7
- const input = { a: "1", b: { c: "2" } };
8
- const result1 = [];
9
-
10
- // the full traversal would look like this:
11
- traverse(input, (key1, val1, innerObj) => {
12
- let current = val1 !== undefined ? val1 : key1;
13
- result1.push(innerObj.path);
14
- return current;
15
- });
16
- assert.deepEqual(result1, ["a", "b", "b.c"]);
17
-
18
- // now let's stop the traversal at path "b" (that's real
19
- // path, how object-path would reference it)
20
- const result2 = [];
21
- traverse(input, (key1, val1, innerObj, stop) => {
22
- let current = val1 !== undefined ? val1 : key1;
23
- result2.push(innerObj.path);
24
- if (innerObj.path === "b") {
25
- stop.now = true; // <---------------- !!!!!!!!!!
26
- }
27
- return current;
28
- });
29
- assert.deepEqual(result2, ["a", "b"]);