ast-get-values-by-key 5.0.0 → 5.0.1

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,17 +3,13 @@
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
- # 5.0.0 (2022-12-01)
7
-
8
- ### Features
9
-
10
- - drop Node v12 support; minimum version requirement now is v14.18 and above ([c8049e8](https://github.com/codsen/codsen/commit/c8049e82a5844d3f72587740f1cc74e3c9020d22))
6
+ ## 5.0.0 (2022-12-01)
11
7
 
12
8
  ### BREAKING CHANGES
13
9
 
14
10
  - Minimum supported Node version is v14.18; we're dropping v12 support
15
11
 
16
- # 4.1.0 (2022-08-12)
12
+ ## 4.1.0 (2022-08-12)
17
13
 
18
14
  ### Features
19
15
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ast-get-values-by-key",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Extract values and paths from AST by keys OR set them by keys",
5
5
  "keywords": [
6
6
  "ast",
@@ -44,22 +44,22 @@
44
44
  },
45
45
  "types": "types/index.d.ts",
46
46
  "scripts": {
47
- "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
47
+ "build": "node '../../ops/scripts/esbuild.js' && npm run dts",
48
48
  "cjs-off": "exit 0",
49
49
  "cjs-on": "exit 0",
50
- "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
51
- "devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
52
- "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
50
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
51
+ "devtest": "c8 npm run unit && npm run examples && npm run lint",
52
+ "dts": "rollup -c && npm run prettier -- 'types/index.d.ts' --write --loglevel 'silent'",
53
53
  "examples": "node '../../ops/scripts/run-examples.js'",
54
- "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
55
- "letspublish": "yarn publish || :",
54
+ "lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
55
+ "letspublish": "npm publish || :",
56
56
  "lint": "eslint . --ext .js --ext .ts --fix",
57
57
  "perf": "node perf/check.js",
58
- "prepare": "echo 'ready'",
58
+ "prep": "echo 'ready'",
59
59
  "prettier": "prettier",
60
- "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
61
- "pretest": "yarn run lect && yarn run build",
62
- "test": "yarn run devtest",
60
+ "prettier:format": "npm run prettier -- --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern --loglevel 'silent'",
61
+ "pretest": "npm run lect && npm run build",
62
+ "test": "npm run devtest",
63
63
  "unit": "uvu test"
64
64
  },
65
65
  "engines": {
@@ -80,7 +80,7 @@
80
80
  }
81
81
  },
82
82
  "dependencies": {
83
- "ast-monkey-traverse": "^4.0.0",
83
+ "ast-monkey-traverse": "^4.0.1",
84
84
  "lodash.clonedeep": "^4.5.0",
85
85
  "matcher": "^5.0.0"
86
86
  },
@@ -1,10 +0,0 @@
1
- /**
2
- * @name ast-get-values-by-key
3
- * @fileoverview Extract values and paths from AST by keys OR set them by keys
4
- * @version 5.0.0
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/ast-get-values-by-key/}
8
- */
9
-
10
- import{traverse as y}from"ast-monkey-traverse";import{isMatch as m}from"matcher";import d from"lodash.clonedeep";var i="5.0.0";var b=i;function j(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{j as getByKey,b as version};
@@ -1,26 +0,0 @@
1
- /**
2
- * @name ast-get-values-by-key
3
- * @fileoverview Extract values and paths from AST by keys OR set them by keys
4
- * @version 5.0.0
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/ast-get-values-by-key/}
8
- */
9
-
10
- "use strict";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="5.0.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
- /**
12
- * @name ast-monkey-traverse
13
- * @fileoverview Utility library to traverse AST
14
- * @version 4.0.0
15
- * @author Roy Revelt, Codsen Ltd
16
- * @license MIT
17
- * {@link https://codsen.com/os/ast-monkey-traverse/}
18
- */
19
- /**
20
- * @name ast-monkey-util
21
- * @fileoverview Utility library of AST helper functions
22
- * @version 3.0.0
23
- * @author Roy Revelt, Codsen Ltd
24
- * @license MIT
25
- * {@link https://codsen.com/os/ast-monkey-util/}
26
- */