ast-get-values-by-key 4.0.12 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/ast-get-values-by-key.esm.js +2 -2
- package/dist/ast-get-values-by-key.umd.js +5 -5
- package/package.json +4 -3
- package/types/index.d.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 4.1.0 (2022-08-12)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- export types ([11b5fb9](https://github.com/codsen/codsen/commit/11b5fb936ce20e0a77c3a09806773e1cd7695c50))
|
|
11
|
+
|
|
6
12
|
## 4.0.0 (2021-09-09)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
This package is [pure ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If you're not ready yet, install an older version of this program, 3.1.0 (`npm i ast-get-values-by-key@3.1.0`).
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i ast-get-values-by-key
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-get-values-by-key
|
|
3
3
|
* @fileoverview Extract values and paths from AST by keys OR set them by keys
|
|
4
|
-
* @version 4.0
|
|
4
|
+
* @version 4.1.0
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-get-values-by-key/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{traverse as y}from"ast-monkey-traverse";import{isMatch as m}from"matcher";import d from"lodash.clonedeep";var i="4.0
|
|
10
|
+
import{traverse as y}from"ast-monkey-traverse";import{isMatch as m}from"matcher";import d from"lodash.clonedeep";var i="4.1.0";var x=i;function k(o,a,t){let e;t!==void 0&&(e=Array.isArray(t)?d(t):[d(t)]);let r=[],p=y(o,(n,s,u)=>{let c=s!==void 0?s:n;if(s!==void 0&&m(n,a,{caseSensitive:!0})){if(e===void 0)r.push({val:s,path:u.path});else if(e.length)return e.shift()}return c});return e===void 0?r:p}export{k as getByKey,x as version};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";/**
|
|
2
2
|
* @name ast-get-values-by-key
|
|
3
3
|
* @fileoverview Extract values and paths from AST by keys OR set them by keys
|
|
4
|
-
* @version 4.0
|
|
4
|
+
* @version 4.1.0
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-get-values-by-key/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var astGetValuesByKey=(()=>{var ue=Object.create;var T=Object.defineProperty,fe=Object.defineProperties,le=Object.getOwnPropertyDescriptor,pe=Object.getOwnPropertyDescriptors,de=Object.getOwnPropertyNames,st=Object.getOwnPropertySymbols,he=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable;var ut=(t,e,r)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,y=(t,e)=>{for(var r in e||(e={}))ct.call(e,r)&&ut(t,r,e[r]);if(st)for(var r of st(e))ge.call(e,r)&&ut(t,r,e[r]);return t},A=(t,e)=>fe(t,pe(e)),ft=t=>T(t,"__esModule",{value:!0});var lt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ye=(t,e)=>{for(var r in e)T(t,r,{get:e[r],enumerable:!0})},pt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of de(e))!ct.call(t,o)&&(r||o!=="default")&&T(t,o,{get:()=>e[o],enumerable:!(n=le(e,o))||n.enumerable});return t},G=(t,e)=>pt(ft(T(t!=null?ue(he(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),be=(t=>(e,r)=>t&&t.get(e)||(r=pt(ft({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var rt=lt(($,S)=>{var _e=200,dt="__lodash_hash_undefined__",ht=9007199254740991,H="[object Arguments]",me="[object Array]",gt="[object Boolean]",yt="[object Date]",ve="[object Error]",L="[object Function]",bt="[object GeneratorFunction]",P="[object Map]",_t="[object Number]",U="[object Object]",mt="[object Promise]",vt="[object RegExp]",M="[object Set]",xt="[object String]",wt="[object Symbol]",V="[object WeakMap]",jt="[object ArrayBuffer]",R="[object DataView]",Ot="[object Float32Array]",St="[object Float64Array]",Tt="[object Int8Array]",At="[object Int16Array]",Ct="[object Int32Array]",Et="[object Uint8Array]",$t="[object Uint8ClampedArray]",It="[object Uint16Array]",Pt="[object Uint32Array]",xe=/[\\^$.*+?()[\]{}|]/g,we=/\w*$/,je=/^\[object .+?Constructor\]$/,Oe=/^(?:0|[1-9]\d*)$/,i={};i[H]=i[me]=i[jt]=i[R]=i[gt]=i[yt]=i[Ot]=i[St]=i[Tt]=i[At]=i[Ct]=i[P]=i[_t]=i[U]=i[vt]=i[M]=i[xt]=i[wt]=i[Et]=i[$t]=i[It]=i[Pt]=!0;i[ve]=i[L]=i[V]=!1;var Se=typeof global=="object"&&global&&global.Object===Object&&global,Te=typeof self=="object"&&self&&self.Object===Object&&self,d=Se||Te||Function("return this")(),Mt=typeof $=="object"&&$&&!$.nodeType&&$,Rt=Mt&&typeof S=="object"&&S&&!S.nodeType&&S,Ae=Rt&&Rt.exports===Mt;function Ce(t,e){return t.set(e[0],e[1]),t}function Ee(t,e){return t.add(e),t}function $e(t,e){for(var r=-1,n=t?t.length:0;++r<n&&e(t[r],r,t)!==!1;);return t}function Ie(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function Nt(t,e,r,n){var o=-1,s=t?t.length:0;for(n&&s&&(r=t[++o]);++o<s;)r=e(r,t[o],o,t);return r}function Pe(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function Me(t,e){return t==null?void 0:t[e]}function kt(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function Ft(t){var e=-1,r=Array(t.size);return t.forEach(function(n,o){r[++e]=[o,n]}),r}function W(t,e){return function(r){return t(e(r))}}function Kt(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var Re=Array.prototype,Ne=Function.prototype,N=Object.prototype,J=d["__core-js_shared__"],Bt=function(){var t=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Dt=Ne.toString,b=N.hasOwnProperty,k=N.toString,ke=RegExp("^"+Dt.call(b).replace(xe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Gt=Ae?d.Buffer:void 0,Ht=d.Symbol,Lt=d.Uint8Array,Fe=W(Object.getPrototypeOf,Object),Ke=Object.create,Be=N.propertyIsEnumerable,De=Re.splice,Ut=Object.getOwnPropertySymbols,Ge=Gt?Gt.isBuffer:void 0,He=W(Object.keys,Object),q=O(d,"DataView"),C=O(d,"Map"),X=O(d,"Promise"),Y=O(d,"Set"),Z=O(d,"WeakMap"),E=O(Object,"create"),Le=x(q),Ue=x(C),Ve=x(X),We=x(Y),Je=x(Z),Vt=Ht?Ht.prototype:void 0,Wt=Vt?Vt.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 qe(){this.__data__=E?E(null):{}}function Xe(t){return this.has(t)&&delete this.__data__[t]}function Ye(t){var e=this.__data__;if(E){var r=e[t];return r===dt?void 0:r}return b.call(e,t)?e[t]:void 0}function Ze(t){var e=this.__data__;return E?e[t]!==void 0:b.call(e,t)}function Qe(t,e){var r=this.__data__;return r[t]=E&&e===void 0?dt:e,this}m.prototype.clear=qe;m.prototype.delete=Xe;m.prototype.get=Ye;m.prototype.has=Ze;m.prototype.set=Qe;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 ze(){this.__data__=[]}function tr(t){var e=this.__data__,r=F(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():De.call(e,r,1),!0}function er(t){var e=this.__data__,r=F(e,t);return r<0?void 0:e[r][1]}function rr(t){return F(this.__data__,t)>-1}function nr(t,e){var r=this.__data__,n=F(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}h.prototype.clear=ze;h.prototype.delete=tr;h.prototype.get=er;h.prototype.has=rr;h.prototype.set=nr;function w(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 or(){this.__data__={hash:new m,map:new(C||h),string:new m}}function ar(t){return K(this,t).delete(t)}function ir(t){return K(this,t).get(t)}function sr(t){return K(this,t).has(t)}function cr(t,e){return K(this,t).set(t,e),this}w.prototype.clear=or;w.prototype.delete=ar;w.prototype.get=ir;w.prototype.has=sr;w.prototype.set=cr;function j(t){this.__data__=new h(t)}function ur(){this.__data__=new h}function fr(t){return this.__data__.delete(t)}function lr(t){return this.__data__.get(t)}function pr(t){return this.__data__.has(t)}function dr(t,e){var r=this.__data__;if(r instanceof h){var n=r.__data__;if(!C||n.length<_e-1)return n.push([t,e]),this;r=this.__data__=new w(n)}return r.set(t,e),this}j.prototype.clear=ur;j.prototype.delete=fr;j.prototype.get=lr;j.prototype.has=pr;j.prototype.set=dr;function hr(t,e){var r=tt(t)||Kr(t)?Pe(t.length,String):[],n=r.length,o=!!n;for(var s in t)(e||b.call(t,s))&&!(o&&(s=="length"||Rr(s,n)))&&r.push(s);return r}function Jt(t,e,r){var n=t[e];(!(b.call(t,e)&&Zt(n,r))||r===void 0&&!(e in t))&&(t[e]=r)}function F(t,e){for(var r=t.length;r--;)if(Zt(t[r][0],e))return r;return-1}function gr(t,e){return t&&qt(e,et(e),t)}function Q(t,e,r,n,o,s,l){var a;if(n&&(a=s?n(t,o,s,l):n(t)),a!==void 0)return a;if(!B(t))return t;var u=tt(t);if(u){if(a=Ir(t),!e)return Cr(t,a)}else{var p=v(t),c=p==L||p==bt;if(Dr(t))return xr(t,e);if(p==U||p==H||c&&!s){if(kt(t))return s?t:{};if(a=Pr(c?{}:t),!e)return Er(t,gr(a,t))}else{if(!i[p])return s?t:{};a=Mr(t,p,Q,e)}}l||(l=new j);var f=l.get(t);if(f)return f;if(l.set(t,a),!u)var g=r?$r(t):et(t);return $e(g||t,function(_,I){g&&(I=_,_=t[I]),Jt(a,I,Q(_,e,r,n,I,t,l))}),a}function yr(t){return B(t)?Ke(t):{}}function br(t,e,r){var n=e(t);return tt(t)?n:Ie(n,r(t))}function _r(t){return k.call(t)}function mr(t){if(!B(t)||kr(t))return!1;var e=zt(t)||kt(t)?ke:je;return e.test(x(t))}function vr(t){if(!Yt(t))return He(t);var e=[];for(var r in Object(t))b.call(t,r)&&r!="constructor"&&e.push(r);return e}function xr(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}function z(t){var e=new t.constructor(t.byteLength);return new Lt(e).set(new Lt(t)),e}function wr(t,e){var r=e?z(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}function jr(t,e,r){var n=e?r(Ft(t),!0):Ft(t);return Nt(n,Ce,new t.constructor)}function Or(t){var e=new t.constructor(t.source,we.exec(t));return e.lastIndex=t.lastIndex,e}function Sr(t,e,r){var n=e?r(Kt(t),!0):Kt(t);return Nt(n,Ee,new t.constructor)}function Tr(t){return Wt?Object(Wt.call(t)):{}}function Ar(t,e){var r=e?z(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Cr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}function qt(t,e,r,n){r||(r={});for(var o=-1,s=e.length;++o<s;){var l=e[o],a=n?n(r[l],t[l],l,r,t):void 0;Jt(r,l,a===void 0?t[l]:a)}return r}function Er(t,e){return qt(t,Xt(t),e)}function $r(t){return br(t,et,Xt)}function K(t,e){var r=t.__data__;return Nr(e)?r[typeof e=="string"?"string":"hash"]:r.map}function O(t,e){var r=Me(t,e);return mr(r)?r:void 0}var Xt=Ut?W(Ut,Object):Lr,v=_r;(q&&v(new q(new ArrayBuffer(1)))!=R||C&&v(new C)!=P||X&&v(X.resolve())!=mt||Y&&v(new Y)!=M||Z&&v(new Z)!=V)&&(v=function(t){var e=k.call(t),r=e==U?t.constructor:void 0,n=r?x(r):void 0;if(n)switch(n){case Le:return R;case Ue:return P;case Ve:return mt;case We:return M;case Je:return V}return e});function Ir(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 Pr(t){return typeof t.constructor=="function"&&!Yt(t)?yr(Fe(t)):{}}function Mr(t,e,r,n){var o=t.constructor;switch(e){case jt:return z(t);case gt:case yt:return new o(+t);case R:return wr(t,n);case Ot:case St:case Tt:case At:case Ct:case Et:case $t:case It:case Pt:return Ar(t,n);case P:return jr(t,n,r);case _t:case xt:return new o(t);case vt:return Or(t);case M:return Sr(t,n,r);case wt:return Tr(t)}}function Rr(t,e){return e=e==null?ht:e,!!e&&(typeof t=="number"||Oe.test(t))&&t>-1&&t%1==0&&t<e}function Nr(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function kr(t){return!!Bt&&Bt in t}function Yt(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||N;return t===r}function x(t){if(t!=null){try{return Dt.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function Fr(t){return Q(t,!0,!0)}function Zt(t,e){return t===e||t!==t&&e!==e}function Kr(t){return Br(t)&&b.call(t,"callee")&&(!Be.call(t,"callee")||k.call(t)==H)}var tt=Array.isArray;function Qt(t){return t!=null&&Gr(t.length)&&!zt(t)}function Br(t){return Hr(t)&&Qt(t)}var Dr=Ge||Ur;function zt(t){var e=B(t)?k.call(t):"";return e==L||e==bt}function Gr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ht}function B(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Hr(t){return!!t&&typeof t=="object"}function et(t){return Qt(t)?hr(t):vr(t)}function Lr(){return[]}function Ur(){return!1}S.exports=Fr});var ne=lt((fn,re)=>{var Vr="[object Object]";function Wr(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function Jr(t,e){return function(r){return t(e(r))}}var qr=Function.prototype,te=Object.prototype,ee=qr.toString,Xr=te.hasOwnProperty,Yr=ee.call(Object),Zr=te.toString,Qr=Jr(Object.getPrototypeOf,Object);function zr(t){return!!t&&typeof t=="object"}function tn(t){if(!zr(t)||Zr.call(t)!=Vr||Wr(t))return!1;var e=Qr(t);if(e===null)return!0;var r=Xr.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&ee.call(r)==Yr}re.exports=tn});var cn={};ye(cn,{getByKey:()=>sn,version:()=>an});var D=G(rt(),1),oe=G(ne(),1);function en(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 nt=en;function ae(t,e){let r={now:!1};function n(o,s,l,a){let u=(0,D.default)(o),p,c=y({depth:-1,path:""},l);if(c.depth+=1,Array.isArray(u))for(let f=0,g=u.length;f<g&&!a.now;f++){let _=c.path?`${c.path}.${f}`:`${f}`;u[f]!==void 0?(c.parent=(0,D.default)(u),c.parentType="array",c.parentKey=nt(_),p=n(s(u[f],void 0,A(y({},c),{path:_}),a),s,A(y({},c),{path:_}),a),Number.isNaN(p)&&f<u.length?(u.splice(f,1),f-=1):u[f]=p):u.splice(f,1)}else if((0,oe.default)(u))for(let f in u){if(a.now&&f!=null)break;let g=c.path?`${c.path}.${f}`:f;c.depth===0&&f!=null&&(c.topmostKey=f),c.parent=(0,D.default)(u),c.parentType="object",c.parentKey=nt(g),p=n(s(f,u[f],A(y({},c),{path:g}),a),s,A(y({},c),{path:g}),a),Number.isNaN(p)?delete u[f]:u[f]=p}return u}return n(t,e,{},r)}function ot(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var at=new Map,ie=(t,e)=>{if(!Array.isArray(t))switch(typeof t){case"string":t=[t];break;case"undefined":t=[];break;default:throw new TypeError(`Expected '${e}' to be a string or an array, but got a type of '${typeof t}'`)}return t.filter(r=>{if(typeof r!="string"){if(typeof r=="undefined")return!1;throw new TypeError(`Expected '${e}' to be an array of strings, but found a type of '${typeof r}' in the array`)}return!0})},rn=(t,e)=>{e=y({caseSensitive:!1},e);let r=t+JSON.stringify(e);if(at.has(r))return at.get(r);let n=t[0]==="!";n&&(t=t.slice(1)),t=ot(t).replace(/\\\*/g,"[\\s\\S]*");let o=new RegExp(`^${t}$`,e.caseSensitive?"":"i");return o.negated=n,at.set(r,o),o},nn=(t,e,r,n)=>{if(t=ie(t,"inputs"),e=ie(e,"patterns"),e.length===0)return[];e=e.map(l=>rn(l,r));let{allPatterns:o}=r||{},s=[];for(let l of t){let a,u=[...e].fill(!1);for(let[p,c]of e.entries())if(c.test(l)&&(u[p]=!0,a=!c.negated,!a))break;if(!(a===!1||a===void 0&&e.some(p=>!p.negated)||o&&u.some((p,c)=>!p&&!e[c].negated))&&(s.push(l),n))break}return s};function se(t,e,r){return nn(t,e,r,!0).length>0}var it=G(rt(),1);var ce="4.0.12";var an=ce;function sn(t,e,r){let n;r!==void 0&&(n=Array.isArray(r)?(0,it.default)(r):[(0,it.default)(r)]);let o=[],s=ae(t,(l,a,u)=>{let p=a!==void 0?a:l;if(a!==void 0&&se(l,e,{caseSensitive:!0})){if(n===void 0)o.push({val:a,path:u.path});else if(n.length)return n.shift()}return p});return n===void 0?o:s}return be(cn);})();
|
|
10
|
+
var astGetValuesByKey=(()=>{var ce=Object.create;var T=Object.defineProperty,ue=Object.defineProperties,fe=Object.getOwnPropertyDescriptor,le=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertyNames,st=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var ct=(t,e,r)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,y=(t,e)=>{for(var r in e||(e={}))ut.call(e,r)&&ct(t,r,e[r]);if(st)for(var r of st(e))he.call(e,r)&&ct(t,r,e[r]);return t},A=(t,e)=>ue(t,le(e));var ft=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ge=(t,e)=>{for(var r in e)T(t,r,{get:e[r],enumerable:!0})},lt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of pe(e))!ut.call(t,o)&&o!==r&&T(t,o,{get:()=>e[o],enumerable:!(n=fe(e,o))||n.enumerable});return t};var G=(t,e,r)=>(r=t!=null?ce(de(t)):{},lt(e||!t||!t.__esModule?T(r,"default",{value:t,enumerable:!0}):r,t)),ye=t=>lt(T({},"__esModule",{value:!0}),t);var rt=ft((C,w)=>{var be=200,jt="__lodash_hash_undefined__",Ot=9007199254740991,X="[object Arguments]",_e="[object Array]",St="[object Boolean]",Tt="[object Date]",me="[object Error]",Y="[object Function]",At="[object GeneratorFunction]",P="[object Map]",Ct="[object Number]",Z="[object Object]",pt="[object Promise]",Et="[object RegExp]",M="[object Set]",$t="[object String]",It="[object Symbol]",L="[object WeakMap]",Pt="[object ArrayBuffer]",R="[object DataView]",Mt="[object Float32Array]",Rt="[object Float64Array]",Nt="[object Int8Array]",kt="[object Int16Array]",Ft="[object Int32Array]",Kt="[object Uint8Array]",Bt="[object Uint8ClampedArray]",Dt="[object Uint16Array]",Gt="[object Uint32Array]",ve=/[\\^$.*+?()[\]{}|]/g,xe=/\w*$/,we=/^\[object .+?Constructor\]$/,je=/^(?:0|[1-9]\d*)$/,i={};i[X]=i[_e]=i[Pt]=i[R]=i[St]=i[Tt]=i[Mt]=i[Rt]=i[Nt]=i[kt]=i[Ft]=i[P]=i[Ct]=i[Z]=i[Et]=i[M]=i[$t]=i[It]=i[Kt]=i[Bt]=i[Dt]=i[Gt]=!0;i[me]=i[Y]=i[L]=!1;var Oe=typeof global=="object"&&global&&global.Object===Object&&global,Se=typeof self=="object"&&self&&self.Object===Object&&self,d=Oe||Se||Function("return this")(),Ht=typeof C=="object"&&C&&!C.nodeType&&C,dt=Ht&&typeof w=="object"&&w&&!w.nodeType&&w,Te=dt&&dt.exports===Ht;function Ae(t,e){return t.set(e[0],e[1]),t}function Ce(t,e){return t.add(e),t}function Ee(t,e){for(var r=-1,n=t?t.length:0;++r<n&&e(t[r],r,t)!==!1;);return t}function $e(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}function Lt(t,e,r,n){var o=-1,s=t?t.length:0;for(n&&s&&(r=t[++o]);++o<s;)r=e(r,t[o],o,t);return r}function Ie(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}function Pe(t,e){return t==null?void 0:t[e]}function Ut(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function ht(t){var e=-1,r=Array(t.size);return t.forEach(function(n,o){r[++e]=[o,n]}),r}function Q(t,e){return function(r){return t(e(r))}}function gt(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}var Me=Array.prototype,Re=Function.prototype,N=Object.prototype,H=d["__core-js_shared__"],yt=function(){var t=/[^.]+$/.exec(H&&H.keys&&H.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Vt=Re.toString,b=N.hasOwnProperty,k=N.toString,Ne=RegExp("^"+Vt.call(b).replace(ve,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bt=Te?d.Buffer:void 0,_t=d.Symbol,mt=d.Uint8Array,ke=Q(Object.getPrototypeOf,Object),Fe=Object.create,Ke=N.propertyIsEnumerable,Be=Me.splice,vt=Object.getOwnPropertySymbols,De=bt?bt.isBuffer:void 0,Ge=Q(Object.keys,Object),U=S(d,"DataView"),E=S(d,"Map"),V=S(d,"Promise"),W=S(d,"Set"),J=S(d,"WeakMap"),$=S(Object,"create"),He=x(U),Le=x(E),Ue=x(V),Ve=x(W),We=x(J),xt=_t?_t.prototype:void 0,wt=xt?xt.valueOf:void 0;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 Je(){this.__data__=$?$(null):{}}function qe(t){return this.has(t)&&delete this.__data__[t]}function Xe(t){var e=this.__data__;if($){var r=e[t];return r===jt?void 0:r}return b.call(e,t)?e[t]:void 0}function Ye(t){var e=this.__data__;return $?e[t]!==void 0:b.call(e,t)}function Ze(t,e){var r=this.__data__;return r[t]=$&&e===void 0?jt:e,this}v.prototype.clear=Je;v.prototype.delete=qe;v.prototype.get=Xe;v.prototype.has=Ye;v.prototype.set=Ze;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 Qe(){this.__data__=[]}function ze(t){var e=this.__data__,r=F(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Be.call(e,r,1),!0}function tr(t){var e=this.__data__,r=F(e,t);return r<0?void 0:e[r][1]}function er(t){return F(this.__data__,t)>-1}function rr(t,e){var r=this.__data__,n=F(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}h.prototype.clear=Qe;h.prototype.delete=ze;h.prototype.get=tr;h.prototype.has=er;h.prototype.set=rr;function j(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 nr(){this.__data__={hash:new v,map:new(E||h),string:new v}}function or(t){return K(this,t).delete(t)}function ar(t){return K(this,t).get(t)}function ir(t){return K(this,t).has(t)}function sr(t,e){return K(this,t).set(t,e),this}j.prototype.clear=nr;j.prototype.delete=or;j.prototype.get=ar;j.prototype.has=ir;j.prototype.set=sr;function O(t){this.__data__=new h(t)}function cr(){this.__data__=new h}function ur(t){return this.__data__.delete(t)}function fr(t){return this.__data__.get(t)}function lr(t){return this.__data__.has(t)}function pr(t,e){var r=this.__data__;if(r instanceof h){var n=r.__data__;if(!E||n.length<be-1)return n.push([t,e]),this;r=this.__data__=new j(n)}return r.set(t,e),this}O.prototype.clear=cr;O.prototype.delete=ur;O.prototype.get=fr;O.prototype.has=lr;O.prototype.set=pr;function dr(t,e){var r=tt(t)||Fr(t)?Ie(t.length,String):[],n=r.length,o=!!n;for(var s in t)(e||b.call(t,s))&&!(o&&(s=="length"||Mr(s,n)))&&r.push(s);return r}function Wt(t,e,r){var n=t[e];(!(b.call(t,e)&&Yt(n,r))||r===void 0&&!(e in t))&&(t[e]=r)}function F(t,e){for(var r=t.length;r--;)if(Yt(t[r][0],e))return r;return-1}function hr(t,e){return t&&Jt(e,et(e),t)}function q(t,e,r,n,o,s,l){var a;if(n&&(a=s?n(t,o,s,l):n(t)),a!==void 0)return a;if(!B(t))return t;var u=tt(t);if(u){if(a=$r(t),!e)return Ar(t,a)}else{var p=m(t),c=p==Y||p==At;if(Br(t))return vr(t,e);if(p==Z||p==X||c&&!s){if(Ut(t))return s?t:{};if(a=Ir(c?{}:t),!e)return Cr(t,hr(a,t))}else{if(!i[p])return s?t:{};a=Pr(t,p,q,e)}}l||(l=new O);var f=l.get(t);if(f)return f;if(l.set(t,a),!u)var g=r?Er(t):et(t);return Ee(g||t,function(_,I){g&&(I=_,_=t[I]),Wt(a,I,q(_,e,r,n,I,t,l))}),a}function gr(t){return B(t)?Fe(t):{}}function yr(t,e,r){var n=e(t);return tt(t)?n:$e(n,r(t))}function br(t){return k.call(t)}function _r(t){if(!B(t)||Nr(t))return!1;var e=Qt(t)||Ut(t)?Ne:we;return e.test(x(t))}function mr(t){if(!Xt(t))return Ge(t);var e=[];for(var r in Object(t))b.call(t,r)&&r!="constructor"&&e.push(r);return e}function vr(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}function z(t){var e=new t.constructor(t.byteLength);return new mt(e).set(new mt(t)),e}function xr(t,e){var r=e?z(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}function wr(t,e,r){var n=e?r(ht(t),!0):ht(t);return Lt(n,Ae,new t.constructor)}function jr(t){var e=new t.constructor(t.source,xe.exec(t));return e.lastIndex=t.lastIndex,e}function Or(t,e,r){var n=e?r(gt(t),!0):gt(t);return Lt(n,Ce,new t.constructor)}function Sr(t){return wt?Object(wt.call(t)):{}}function Tr(t,e){var r=e?z(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Ar(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}function Jt(t,e,r,n){r||(r={});for(var o=-1,s=e.length;++o<s;){var l=e[o],a=n?n(r[l],t[l],l,r,t):void 0;Wt(r,l,a===void 0?t[l]:a)}return r}function Cr(t,e){return Jt(t,qt(t),e)}function Er(t){return yr(t,et,qt)}function K(t,e){var r=t.__data__;return Rr(e)?r[typeof e=="string"?"string":"hash"]:r.map}function S(t,e){var r=Pe(t,e);return _r(r)?r:void 0}var qt=vt?Q(vt,Object):Hr,m=br;(U&&m(new U(new ArrayBuffer(1)))!=R||E&&m(new E)!=P||V&&m(V.resolve())!=pt||W&&m(new W)!=M||J&&m(new J)!=L)&&(m=function(t){var e=k.call(t),r=e==Z?t.constructor:void 0,n=r?x(r):void 0;if(n)switch(n){case He:return R;case Le:return P;case Ue:return pt;case Ve:return M;case We:return L}return e});function $r(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 Ir(t){return typeof t.constructor=="function"&&!Xt(t)?gr(ke(t)):{}}function Pr(t,e,r,n){var o=t.constructor;switch(e){case Pt:return z(t);case St:case Tt:return new o(+t);case R:return xr(t,n);case Mt:case Rt:case Nt:case kt:case Ft:case Kt:case Bt:case Dt:case Gt:return Tr(t,n);case P:return wr(t,n,r);case Ct:case $t:return new o(t);case Et:return jr(t);case M:return Or(t,n,r);case It:return Sr(t)}}function Mr(t,e){return e=e==null?Ot:e,!!e&&(typeof t=="number"||je.test(t))&&t>-1&&t%1==0&&t<e}function Rr(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Nr(t){return!!yt&&yt in t}function Xt(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||N;return t===r}function x(t){if(t!=null){try{return Vt.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function kr(t){return q(t,!0,!0)}function Yt(t,e){return t===e||t!==t&&e!==e}function Fr(t){return Kr(t)&&b.call(t,"callee")&&(!Ke.call(t,"callee")||k.call(t)==X)}var tt=Array.isArray;function Zt(t){return t!=null&&Dr(t.length)&&!Qt(t)}function Kr(t){return Gr(t)&&Zt(t)}var Br=De||Lr;function Qt(t){var e=B(t)?k.call(t):"";return e==Y||e==At}function Dr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ot}function B(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Gr(t){return!!t&&typeof t=="object"}function et(t){return Zt(t)?dr(t):mr(t)}function Hr(){return[]}function Lr(){return!1}w.exports=kr});var re=ft((un,ee)=>{var Ur="[object Object]";function Vr(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(r){}return e}function Wr(t,e){return function(r){return t(e(r))}}var Jr=Function.prototype,zt=Object.prototype,te=Jr.toString,qr=zt.hasOwnProperty,Xr=te.call(Object),Yr=zt.toString,Zr=Wr(Object.getPrototypeOf,Object);function Qr(t){return!!t&&typeof t=="object"}function zr(t){if(!Qr(t)||Yr.call(t)!=Ur||Vr(t))return!1;var e=Zr(t);if(e===null)return!0;var r=qr.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&te.call(r)==Xr}ee.exports=zr});var sn={};ge(sn,{getByKey:()=>an,version:()=>on});var D=G(rt(),1),ne=G(re(),1);function tn(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 nt=tn;function oe(t,e){let r={now:!1};function n(o,s,l,a){let u=(0,D.default)(o),p,c=y({depth:-1,path:""},l);if(c.depth+=1,Array.isArray(u))for(let f=0,g=u.length;f<g&&!a.now;f++){let _=c.path?`${c.path}.${f}`:`${f}`;u[f]!==void 0?(c.parent=(0,D.default)(u),c.parentType="array",c.parentKey=nt(_),p=n(s(u[f],void 0,A(y({},c),{path:_}),a),s,A(y({},c),{path:_}),a),Number.isNaN(p)&&f<u.length?(u.splice(f,1),f-=1):u[f]=p):u.splice(f,1)}else if((0,ne.default)(u))for(let f in u){if(a.now&&f!=null)break;let g=c.path?`${c.path}.${f}`:f;c.depth===0&&f!=null&&(c.topmostKey=f),c.parent=(0,D.default)(u),c.parentType="object",c.parentKey=nt(g),p=n(s(f,u[f],A(y({},c),{path:g}),a),s,A(y({},c),{path:g}),a),Number.isNaN(p)?delete u[f]:u[f]=p}return u}return n(t,e,{},r)}function ot(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var at=new Map,ae=(t,e)=>{if(!Array.isArray(t))switch(typeof t){case"string":t=[t];break;case"undefined":t=[];break;default:throw new TypeError(`Expected '${e}' to be a string or an array, but got a type of '${typeof t}'`)}return t.filter(r=>{if(typeof r!="string"){if(typeof r>"u")return!1;throw new TypeError(`Expected '${e}' to be an array of strings, but found a type of '${typeof r}' in the array`)}return!0})},en=(t,e)=>{e=y({caseSensitive:!1},e);let r=t+JSON.stringify(e);if(at.has(r))return at.get(r);let n=t[0]==="!";n&&(t=t.slice(1)),t=ot(t).replace(/\\\*/g,"[\\s\\S]*");let o=new RegExp(`^${t}$`,e.caseSensitive?"":"i");return o.negated=n,at.set(r,o),o},rn=(t,e,r,n)=>{if(t=ae(t,"inputs"),e=ae(e,"patterns"),e.length===0)return[];e=e.map(l=>en(l,r));let{allPatterns:o}=r||{},s=[];for(let l of t){let a,u=[...e].fill(!1);for(let[p,c]of e.entries())if(c.test(l)&&(u[p]=!0,a=!c.negated,!a))break;if(!(a===!1||a===void 0&&e.some(p=>!p.negated)||o&&u.some((p,c)=>!p&&!e[c].negated))&&(s.push(l),n))break}return s};function ie(t,e,r){return rn(t,e,r,!0).length>0}var it=G(rt(),1);var se="4.1.0";var on=se;function an(t,e,r){let n;r!==void 0&&(n=Array.isArray(r)?(0,it.default)(r):[(0,it.default)(r)]);let o=[],s=oe(t,(l,a,u)=>{let p=a!==void 0?a:l;if(a!==void 0&&ie(l,e,{caseSensitive:!0})){if(n===void 0)o.push({val:a,path:u.path});else if(n.length)return n.shift()}return p});return n===void 0?o:s}return ye(sn);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name ast-monkey-traverse
|
|
13
13
|
* @fileoverview Utility library to traverse AST
|
|
14
|
-
* @version 3.0
|
|
14
|
+
* @version 3.1.0
|
|
15
15
|
* @author Roy Revelt, Codsen Ltd
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/ast-monkey-traverse/}
|
|
@@ -19,7 +19,7 @@ var astGetValuesByKey=(()=>{var ue=Object.create;var T=Object.defineProperty,fe=
|
|
|
19
19
|
/**
|
|
20
20
|
* @name ast-monkey-util
|
|
21
21
|
* @fileoverview Utility library of AST helper functions
|
|
22
|
-
* @version 2.0
|
|
22
|
+
* @version 2.1.0
|
|
23
23
|
* @author Roy Revelt, Codsen Ltd
|
|
24
24
|
* @license MIT
|
|
25
25
|
* {@link https://codsen.com/os/ast-monkey-util/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ast-get-values-by-key",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Extract values and paths from AST by keys OR set them by keys",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"type": "module",
|
|
40
40
|
"exports": {
|
|
41
|
+
"types": "./types/index.d.ts",
|
|
41
42
|
"script": "./dist/ast-get-values-by-key.umd.js",
|
|
42
43
|
"default": "./dist/ast-get-values-by-key.esm.js"
|
|
43
44
|
},
|
|
@@ -77,11 +78,11 @@
|
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
80
|
"dependencies": {
|
|
80
|
-
"ast-monkey-traverse": "^3.0
|
|
81
|
+
"ast-monkey-traverse": "^3.1.0",
|
|
81
82
|
"lodash.clonedeep": "^4.5.0",
|
|
82
83
|
"matcher": "^5.0.0"
|
|
83
84
|
},
|
|
84
85
|
"devDependencies": {
|
|
85
|
-
"@types/lodash.clonedeep": "^4.5.
|
|
86
|
+
"@types/lodash.clonedeep": "^4.5.7"
|
|
86
87
|
}
|
|
87
88
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
declare const version: string;
|
|
2
|
+
interface Findings {
|
|
3
|
+
val: any;
|
|
4
|
+
path: string;
|
|
5
|
+
}
|
|
2
6
|
/**
|
|
3
7
|
* Extract values and paths from AST by keys OR set them by keys
|
|
4
8
|
*/
|
|
@@ -8,4 +12,4 @@ declare function getByKey(
|
|
|
8
12
|
originalReplacement?: any
|
|
9
13
|
): any;
|
|
10
14
|
|
|
11
|
-
export { getByKey, version };
|
|
15
|
+
export { Findings, getByKey, version };
|