ast-get-values-by-key 5.1.0 → 5.2.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 CHANGED
@@ -3,11 +3,22 @@
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.1.0 (2025-10-15)
6
+ ## 5.2.0 (2026-08-19)
7
+
8
+ ### Bug Fixes
9
+
10
+ - resolve review findings REV-004 through REV-007 ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
11
+ - retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
7
12
 
8
13
  ### Features
9
14
 
10
- - if value to be added is a number, keep it as is, don't stringify ([ce3e1a5](https://github.com/codsen/codsen/commit/ce3e1a525998ca3c0abf0142affef95b14cd1990))
15
+ - add codsen-glob and migrate glob consumers ([5595a2b](https://github.com/codsen/codsen/commit/5595a2b267eaa6cb60072d037aef00b7a28edd42))
16
+ - refresh the tooling and generate with the latest dependencies ([781f802](https://github.com/codsen/codsen/commit/781f802911066a82a4533b0e5a3fcbd742d0dd83))
17
+
18
+ ### Reverts
19
+
20
+ - Revert "Merge pull request #128 from codsen/release/npm-32198404552-1" ([5baeeaa](https://github.com/codsen/codsen/commit/5baeeaaa677b86f1eaa6396cadf3aea32b06416e)), closes [#128](https://github.com/codsen/codsen/issues/128)
21
+ - Revert "Merge pull request #127 from codsen/release/npm-32194020886-1" ([5f1e94d](https://github.com/codsen/codsen/commit/5f1e94deef910ce735266b16aeee08a76de7a862)), closes [#127](https://github.com/codsen/codsen/issues/127)
11
22
 
12
23
  ## 5.0.0 (2022-12-01)
13
24
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright © 2010-2025 Roy Revelt and other contributors
3
+ Copyright © 2010-2026 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -32,13 +32,10 @@ npm i ast-get-values-by-key
32
32
  ## Quick Take
33
33
 
34
34
  ```js
35
- import { strict as assert } from "assert";
35
+ import { strict as assert } from "node:assert";
36
36
 
37
37
  import { getByKey } from "ast-get-values-by-key";
38
38
 
39
- // GETTER
40
- // ======
41
-
42
39
  // returns "object-path" notation paths where arrays use dots:
43
40
  assert.deepEqual(
44
41
  getByKey(
@@ -53,47 +50,12 @@ assert.deepEqual(
53
50
  ),
54
51
  [{ val: "html", path: "parsed.0.tag" }],
55
52
  );
56
-
57
- // SETTER
58
- // ======
59
-
60
- assert.deepEqual(
61
- getByKey(
62
- {
63
- parsed: [
64
- {
65
- tag: "html",
66
- },
67
- ],
68
- foo: {
69
- tag: null,
70
- },
71
- bar: {
72
- tag: null,
73
- },
74
- },
75
- "tag", // value to search for
76
- [123, 456], // pot of values to pick from (one result not enough)
77
- ),
78
- {
79
- parsed: [
80
- {
81
- tag: 123,
82
- },
83
- ],
84
- foo: {
85
- tag: 456,
86
- },
87
- bar: {
88
- tag: null, // value pot was depleted and there was nothing left to put here
89
- },
90
- },
91
- );
92
53
  ```
93
54
 
55
+
94
56
  ## Documentation
95
57
 
96
- Please [visit codsen.com](https://codsen.com/os/ast-get-values-by-key/) for a full description of the API.
58
+ Please [visit codsen.com](https://codsen.com/os/ast-get-values-by-key/) for a full description of the API. If you’re looking for the **Changelog**, it’s [here](https://github.com/codsen/codsen/blob/main/packages/ast-get-values-by-key/CHANGELOG.md).
97
59
 
98
60
  ## Contributing
99
61
 
@@ -103,6 +65,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
103
65
 
104
66
  MIT License
105
67
 
106
- Copyright © 2010-2025 Roy Revelt and other contributors
68
+ Copyright © 2010-2026 Roy Revelt and other contributors
107
69
 
108
70
  <p align="center"><img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center"></p>
@@ -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 5.1.0
4
+ * @version 5.2.0
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-get-values-by-key/}
8
8
  */
9
9
 
10
- import{traverse as m}from"ast-monkey-traverse";import{isMatch as y}from"matcher";import h from"rfdc";var i="5.1.0";var p=h(),j=i;function k(o,d,t){let e;t!==void 0&&(e=Array.isArray(t)?p(t):[p(t)]);let r=[],c=m(o,(n,s,u)=>{let l=s!==void 0?s:n;if(s!==void 0&&y(n,d,{caseSensitive:!0})){if(e===void 0)r.push({val:s,path:u.path});else if(e.length)return e.shift()}return l});return e===void 0?r:c}export{k as getByKey,j as version};
10
+ import{traverse as m}from"ast-monkey-traverse";import{deepClone as o,match as y}from"codsen-utils";var i="5.2.0";var v=i;function k(p,c,t){let e;t!==void 0&&(e=Array.isArray(t)?o(t):[o(t)]);let n=[],d=m(p,(r,s,a)=>{let l=s!==void 0?s:r;if(s!==void 0&&y(r,c,{caseSensitiveMatch:!0})){if(e===void 0)n.push({val:s,path:a.path});else if(e.length)return e.shift()}return l});return e===void 0?n:d}export{k as getByKey,v as version};
@@ -1,33 +1,25 @@
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 5.1.0
4
+ * @version 5.2.0
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-get-values-by-key/}
8
8
  */
9
9
 
10
- "use strict";var astGetValuesByKey=(()=>{var U=Object.create,$=Object.freeze,g=Object.defineProperty,J=Object.defineProperties,W=Object.getOwnPropertyDescriptor,q=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols,Z=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable;var E=(e,r,s)=>r in e?g(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,h=(e,r)=>{for(var s in r||(r={}))B.call(r,s)&&E(e,s,r[s]);if(C)for(var s of C(r))G.call(r,s)&&E(e,s,r[s]);return e},b=(e,r)=>J(e,q(r));var X=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Y=(e,r)=>{for(var s in r)g(e,s,{get:r[s],enumerable:!0})},D=(e,r,s,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of z(r))!B.call(e,l)&&l!==s&&g(e,l,{get:()=>r[l],enumerable:!(c=W(r,l))||c.enumerable});return e};var x=(e,r,s)=>(s=e!=null?U(Z(e)):{},D(r||!e||!e.__esModule?g(s,"default",{value:e,enumerable:!0}):s,e)),ee=e=>D(g({},"__esModule",{value:!0}),e);var A=(e,r)=>$(g(e,"raw",{value:$(r||e.slice())}));var w=X((le,_)=>{"use strict";_.exports=te;function m(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function te(e){if(e=e||{},e.circles)return re(e);let r=new Map;if(r.set(Date,o=>new Date(o)),r.set(Map,(o,a)=>new Map(c(Array.from(o),a))),r.set(Set,(o,a)=>new Set(c(Array.from(o),a))),e.constructorHandlers)for(let o of e.constructorHandlers)r.set(o[0],o[1]);let s=null;return e.proto?f:l;function c(o,a){let t=Object.keys(o),n=new Array(t.length);for(let u=0;u<t.length;u++){let i=t[u],p=o[i];typeof p!="object"||p===null?n[i]=p:p.constructor!==Object&&(s=r.get(p.constructor))?n[i]=s(p,a):ArrayBuffer.isView(p)?n[i]=m(p):n[i]=a(p)}return n}function l(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,l);if(o.constructor!==Object&&(s=r.get(o.constructor)))return s(o,l);let a={};for(let t in o){if(Object.hasOwnProperty.call(o,t)===!1)continue;let n=o[t];typeof n!="object"||n===null?a[t]=n:n.constructor!==Object&&(s=r.get(n.constructor))?a[t]=s(n,l):ArrayBuffer.isView(n)?a[t]=m(n):a[t]=l(n)}return a}function f(o){if(typeof o!="object"||o===null)return o;if(Array.isArray(o))return c(o,f);if(o.constructor!==Object&&(s=r.get(o.constructor)))return s(o,f);let a={};for(let t in o){let n=o[t];typeof n!="object"||n===null?a[t]=n:n.constructor!==Object&&(s=r.get(n.constructor))?a[t]=s(n,f):ArrayBuffer.isView(n)?a[t]=m(n):a[t]=f(n)}return a}}function re(e){let r=[],s=[],c=new Map;if(c.set(Date,t=>new Date(t)),c.set(Map,(t,n)=>new Map(f(Array.from(t),n))),c.set(Set,(t,n)=>new Set(f(Array.from(t),n))),e.constructorHandlers)for(let t of e.constructorHandlers)c.set(t[0],t[1]);let l=null;return e.proto?a:o;function f(t,n){let u=Object.keys(t),i=new Array(u.length);for(let p=0;p<u.length;p++){let d=u[p],y=t[d];if(typeof y!="object"||y===null)i[d]=y;else if(y.constructor!==Object&&(l=c.get(y.constructor)))i[d]=l(y,n);else if(ArrayBuffer.isView(y))i[d]=m(y);else{let O=r.indexOf(y);O!==-1?i[d]=s[O]:i[d]=n(y)}}return i}function o(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return f(t,o);if(t.constructor!==Object&&(l=c.get(t.constructor)))return l(t,o);let n={};r.push(t),s.push(n);for(let u in t){if(Object.hasOwnProperty.call(t,u)===!1)continue;let i=t[u];if(typeof i!="object"||i===null)n[u]=i;else if(i.constructor!==Object&&(l=c.get(i.constructor)))n[u]=l(i,o);else if(ArrayBuffer.isView(i))n[u]=m(i);else{let p=r.indexOf(i);p!==-1?n[u]=s[p]:n[u]=o(i)}}return r.pop(),s.pop(),n}function a(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return f(t,a);if(t.constructor!==Object&&(l=c.get(t.constructor)))return l(t,a);let n={};r.push(t),s.push(n);for(let u in t){let i=t[u];if(typeof i!="object"||i===null)n[u]=i;else if(i.constructor!==Object&&(l=c.get(i.constructor)))n[u]=l(i,a);else if(ArrayBuffer.isView(i))n[u]=m(i);else{let p=r.indexOf(i);p!==-1?n[u]=s[p]:n[u]=a(i)}}return r.pop(),s.pop(),n}}});var ae={};Y(ae,{getByKey:()=>ue,version:()=>oe});var T=x(w(),1);var P=x(w(),1);var fe=(0,P.default)();function N(e){if(e==null||typeof e!="object")return!1;let r=Object.getPrototypeOf(e);return r!==null&&r!==Object.prototype&&Object.getPrototypeOf(r)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function v(e){if(e.includes(".")){let r=e.lastIndexOf(".");if(!e.slice(0,r).includes("."))return e.slice(0,r);for(let s=r-1;s--;)if(e[s]===".")return e.slice(s+1,r)}return null}var S=(0,T.default)();function M(e,r){let s={now:!1};function c(l,f,o,a){let t=S(l),n,u=h({depth:-1,path:""},o);if(u.depth+=1,Array.isArray(t))for(let i=0,p=t.length;i<p&&!a.now;i++){let d=u.path?"".concat(u.path,".").concat(i):"".concat(i);t[i]!==void 0?(u.parent=S(t),u.parentType="array",u.parentKey=v(d),n=c(f(t[i],void 0,b(h({},u),{path:d}),a),f,b(h({},u),{path:d}),a),Number.isNaN(n)&&i<t.length?(t.splice(i,1),i-=1):t[i]=n):t.splice(i,1)}else if(N(t))for(let i in t){if(a.now&&i!=null)break;let p=u.path?"".concat(u.path,".").concat(i):i;u.depth===0&&i!=null&&(u.topmostKey=i),u.parent=S(t),u.parentType="object",u.parentKey=v(p),n=c(f(i,t[i],b(h({},u),{path:p}),a),f,b(h({},u),{path:p}),a),Number.isNaN(n)?delete t[i]:t[i]=n}return t}return c(e,r,{},s)}function j(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var k=new Map,R=(e,r)=>{if(!Array.isArray(e))switch(typeof e){case"string":{e=[e];break}case"undefined":{e=[];break}default:throw new TypeError("Expected '".concat(r,"' to be a string or an array, but got a type of '").concat(typeof e,"'"))}return e.filter(s=>{if(typeof s!="string"){if(s===void 0)return!1;throw new TypeError("Expected '".concat(r,"' to be an array of strings, but found a type of '").concat(typeof s,"' in the array"))}return!0})},I,L,F,ne=(e,r)=>{r=h({caseSensitive:!1},r);let s="s"+(r.caseSensitive?"":"i"),c=e+"|"+s;if(k.has(c))return k.get(c);let l=e[0]==="!";l&&(e=e.slice(1)),e=e.replaceAll(String.raw(I||(I=A(["*"],["\\*"]))),"__ESCAPED_STAR__").replaceAll("\\\\","__ESCAPED_BACKSLASH__").replaceAll(/\\(.)/g,"$1"),e=j(e).replaceAll(String.raw(L||(L=A(["*"],["\\*"]))),".*"),e=e.replaceAll("__ESCAPED_STAR__",String.raw(F||(F=A(["*"],["\\*"])))).replaceAll("__ESCAPED_BACKSLASH__","\\\\");let f=new RegExp("^".concat(e,"$"),s);return f.negated=l,k.set(c,f),f},se=(e,r,s,c)=>{if(e=R(e,"inputs"),r=R(r,"patterns"),r.length===0)return[];r=r.map(t=>ne(t,s));let l=r.filter(t=>t.negated),f=r.filter(t=>!t.negated),{allPatterns:o}=s||{},a=[];if(o&&c&&l.length>1&&f.length===0){for(let t of e)for(let n of l)if(n.test(t))return[];return e.slice(0,1)}for(let t of e){let n=!1;for(let u of l)if(u.test(t)){n=!0;break}if(!n){if(f.length===0)a.push(t);else if(o){let u=Array.from({length:f.length},()=>!1);for(let[i,p]of f.entries())p.test(t)&&(u[i]=!0);u.every(Boolean)&&a.push(t)}else{let u=!1;for(let i of f)if(i.test(t)){u=!0;break}u&&a.push(t)}if(c&&a.length>0)break}}return a};function H(e,r,s){return se(e,r,s,!0).length>0}var Q=x(w(),1);var K="5.1.0";var V=(0,Q.default)(),oe=K;function ue(e,r,s){let c;s!==void 0&&(c=Array.isArray(s)?V(s):[V(s)]);let l=[],f=M(e,(o,a,t)=>{let n=a!==void 0?a:o;if(a!==void 0&&H(o,r,{caseSensitive:!0})){if(c===void 0)l.push({val:a,path:t.path});else if(c.length)return c.shift()}return n});return c===void 0?l:f}return ee(ae);})();
10
+ "use strict";var astGetValuesByKey=(()=>{var C=Object.defineProperty,H=Object.defineProperties,Q=Object.getOwnPropertyDescriptor,z=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var $=(e,t,r)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))B.call(t,r)&&$(e,r,t[r]);if(I)for(var r of I(t))Z.call(t,r)&&$(e,r,t[r]);return e},w=(e,t)=>H(e,z(t));var q=(e,t)=>{for(var r in t)C(e,r,{get:t[r],enumerable:!0})},J=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of G(t))!B.call(e,l)&&l!==r&&C(e,l,{get:()=>t[l],enumerable:!(i=Q(t,l))||i.enumerable});return e};var Y=e=>J(C({},"__esModule",{value:!0}),e);var k=(e,t,r)=>$(e,typeof t!="symbol"?t+"":t,r);var de={};q(de,{getByKey:()=>he,version:()=>ce});var ye=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);var X=class{constructor(){k(this,"hasRepeatedReferences",!1);k(this,"clones",[]);k(this,"index");k(this,"sources",[])}get(e){if(this.index){let r=this.index.get(e);return r!==void 0&&(this.hasRepeatedReferences=!0),r}let t=this.sources.indexOf(e);if(t!==-1)return this.hasRepeatedReferences=!0,this.clones[t]}set(e,t){if(this.index){this.index.set(e,t);return}if(this.sources.push(e),this.clones.push(t),this.sources.length===32){this.index=new WeakMap;for(let r=0;r<this.sources.length;r++)this.index.set(this.sources[r],this.clones[r]);this.sources=[],this.clones=[]}}};function L(e,t){let r=t.get(e);if(r!==void 0)return r;let i=e.slice(0);return t.set(e,i),i}function ee(e,t){if(typeof Buffer<"u"&&Buffer.isBuffer(e)){let n=Buffer.from(e);return t.set(e,n),n}let r=L(e.buffer,t);if(e instanceof DataView){let n=new DataView(r,e.byteOffset,e.byteLength);return t.set(e,n),n}let i=e.constructor,l=new i(r,e.byteOffset,e.length);return t.set(e,l),l}function W(e,t,r,i){for(let l of r){let n=t[l];e[l]=typeof n!="object"||n===null?n:A(n,i)}}function A(e,t){if(typeof e!="object"||e===null)return e;let r=t.get(e);if(r!==void 0)return r;if(Array.isArray(e)){let n=e.length,s=new Array(n);t.set(e,s);let o=e,u=Object.keys(e);if(u.length===n&&(n===0||u[n-1]==="".concat(n-1)))for(let f=0;f<n;f++){let a=o[f];s[f]=typeof a!="object"||a===null?a:A(a,t)}else W(s,o,u,t);return s}let i=Object.getPrototypeOf(e);if(i===Object.prototype||i===null){let n={};return t.set(e,n),W(n,e,Object.keys(e),t),n}if(e instanceof Date){let n=new Date(e.getTime());return t.set(e,n),n}if(ArrayBuffer.isView(e))return ee(e,t);if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return L(e,t);if(e instanceof Map){let n=new Map;t.set(e,n);for(let[s,o]of e)n.set(A(s,t),A(o,t));return n}if(e instanceof Set){let n=new Set;t.set(e,n);for(let s of e)n.add(A(s,t));return n}let l={};return t.set(e,l),W(l,e,Object.keys(e),t),l}function m(e){return A(e,new X)}function N(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}var te=256,re=1024,ne=1,ie=new Map,se=new Map;function M(e){if(e>=97&&e<=122)return e-32;if(e>65535)return e;let t=String.fromCharCode(e).toUpperCase();if(t.length!==1)return e;let r=t.charCodeAt(0);return e>127&&r<128?e:r}function D(e,t,r,i,l,n){for(let s=0;s<l;s++){let o=e.charCodeAt(t+s),u=r.charCodeAt(i+s);if(n||(o>=97&&o<=122&&(o-=32),u>=97&&u<=122&&(u-=32)),o!==u)return!1}return!0}function T(e,t,r){let i=t.indexOf("\\");if(i===-1&&e===t)return!0;let l=t.indexOf("*");if(i===-1&&l===-1){if(r)return!1;for(let a=0;a<t.length;a++)if(t.charCodeAt(a)>127)return;return e.length===t.length&&D(e,0,t,0,t.length,!1)}if(i!==-1)return;let n=0,s=!1,o=-1;for(let a=0;a<t.length;a++){let p=t.charCodeAt(a);if(p>127)return;if(p===42){if(o=a,!s){if(n++,n>1)return;s=!0}}else s=!1}let u=o+1,f=t.length-u;return e.length<l+f?!1:D(e,0,t,0,l,r)&&D(e,e.length-f,t,u,f,r)}function le(e){let t=new Uint32Array(e.length),r=0;for(let i=1;i<e.length;i++){for(;r>0&&e[i]!==e[r];)r=t[r-1];e[i]===e[r]&&r++,t[i]=r}return t}function oe(e,t){let r=[[]],i=!0,l=!1,n=!1,s=0;for(let c=0;c<e.length;){let d=e.codePointAt(c);if(d!==92){if(d===42)l=!0,n||(r.push([]),n=!0);else{let b=t?d:M(d);r[r.length-1].push(b),i&&(i=b<=127),s++,n=!1}c+=d>65535?2:1;continue}let h=c+1;for(;e.charCodeAt(h)===92;)h++;let y=h-c,g=e.codePointAt(h),x,j=!1;g===42?(j=y%2===0,x=j?y/2:(y-1)/2):g===void 0||g===10||g===13||g===8232||g===8233?x=Math.ceil(y/2):x=Math.floor(y/2);for(let b=0;b<x;b++)r[r.length-1].push(92),s++;if(j){n=!1,c=h;continue}if(g!==void 0){let b=t?g:M(g);r[r.length-1].push(b),i&&(i=b<=127),s++,h+=g>65535?2:1}n=!1,c=h}let o=l&&r[0].length===0,u=l&&r[r.length-1].length===0,f=[];for(let c of r)c.length&&f.push({values:c});let a=o?0:1,p=f.length-(u?0:1);for(let c=a;c<p;c++)f[c].values.length>ne&&(f[c].failure=le(f[c].values));return{asciiOnly:i,endsWithWildcard:u,hasWildcard:l,minimumInputLength:s,segments:f,startsWithWildcard:o}}function P(e,t){let r=t?ie:se,i=e.length<=re;if(i){let n=r.get(e);if(n)return n}let l=oe(e,t);if(i){if(r.size>=te){let n=r.keys().next().value;n!==void 0&&r.delete(n)}r.set(e,l)}return l}function E(e,t){if(t){let l=[];for(let n=0;n<e.length;){let s=e.codePointAt(n);l.push(s),n+=s>65535?2:1}return l}let r=new Uint32Array(e.length),i=0;for(let l=0;l<e.length;){let n=e.codePointAt(l);r[i]=M(n),i++,l+=n>65535?2:1}return i===r.length?r:r.subarray(0,i)}function O(e,t,r,i){for(let l=0;l<r.values.length;l++){let n=e.charCodeAt(t+l);if(!i&&n>=97&&n<=122&&(n-=32),n!==r.values[l])return!1}return!0}function ue(e,t,r,i,l){let n=i-t.values.length;if(n<r)return-1;if(!t.failure){for(let o=r;o<=n;o++)if(O(e,o,t,l))return o;return-1}let s=0;for(let o=r;o<i;o++){let u=e.charCodeAt(o);for(!l&&u>=97&&u<=122&&(u-=32);s>0&&u!==t.values[s];)s=t.failure[s-1];if(u===t.values[s]&&(s++,s===t.values.length))return o-s+1}return-1}function F(e,t,r){if(e.length<t.minimumInputLength)return!1;if(!t.hasWildcard)return e.length===t.minimumInputLength&&O(e,0,t.segments[0],r);let i=0,l=t.segments.length,n=0,s=e.length;if(!t.startsWithWildcard){let o=t.segments[0];if(!O(e,0,o,r))return!1;n=o.values.length,i++}if(!t.endsWithWildcard){l--;let o=t.segments[l];if(s-=o.values.length,!O(e,s,o,r))return!1}for(let o=i;o<l;o++){let u=t.segments[o],f=ue(e,u,n,s,r);if(f===-1)return!1;n=f+u.values.length}return!0}function S(e,t,r){for(let i=0;i<r.values.length;i++)if(e[t+i]!==r.values[i])return!1;return!0}function ae(e,t,r,i){let l=i-t.values.length;if(l<r)return-1;if(!t.failure){for(let s=r;s<=l;s++)if(S(e,s,t))return s;return-1}let n=0;for(let s=r;s<i;s++){for(;n>0&&e[s]!==t.values[n];)n=t.failure[n-1];if(e[s]===t.values[n]&&(n++,n===t.values.length))return s-n+1}return-1}function U(e,t){if(e.length<t.minimumInputLength)return!1;if(!t.hasWildcard)return e.length===t.minimumInputLength&&S(e,0,t.segments[0]);let r=0,i=t.segments.length,l=0,n=e.length;if(!t.startsWithWildcard){let s=t.segments[0];if(!S(e,0,s))return!1;l=s.values.length,r++}if(!t.endsWithWildcard){i--;let s=t.segments[i];if(n-=s.values.length,!S(e,n,s))return!1}for(let s=r;s<i;s++){let o=t.segments[s],u=ae(e,o,l,n);if(u===-1)return!1;l=u+o.values.length}return!0}function fe(e,t,r){let i=T(e,t,r);if(i!==void 0)return i;let l=P(t,r);return l.asciiOnly?F(e,l,r):U(E(e,r),l)}function R(e,t,r,i){var s;let l=T(e,t,r);if(l!==void 0)return l;let n=P(t,r);return n.asciiOnly?F(e,n,r):((s=i.tokens)!=null||(i.tokens=E(e,r)),U(i.tokens,n))}function K(e,t,r){if(typeof t!="string"&&!t.length)return!1;let i=r===void 0?!1:r.caseSensitiveMatch===!0;if(typeof t=="string"){let o=t.charCodeAt(0)===33,u=o?t.slice(1):t,f=fe(e,u,i);return o?!f:f}let l={},n=!1,s=!1;for(let o of t){let u=o.charCodeAt(0)===33,f=u?o.slice(1):o;if(u){if(R(e,f,i,l))return!1}else n=!0,!s&&R(e,f,i,l)&&(s=!0)}return n?s:!0}function V(e,t){if(typeof t!="function")throw new TypeError("ast-monkey-traverse/traverse(): [THROW_ID_01] The second argument must be a callback function. It was ".concat(typeof t,"."));let r={now:!1};function i(l,n,s,o){let u=l,f,a=v({depth:-1,path:""},s);if(a.depth+=1,Array.isArray(u))for(let p=0,c=u.length;p<c&&!o.now;p++){let d=a.path?"".concat(a.path,".").concat(p):"".concat(p);if(u[p]!==void 0){a.parent=m(u),a.parentType="array",a.parentKey=a.path?a.path.slice(a.path.lastIndexOf(".")+1):null;let h=u[p],y=n(h,void 0,w(v({},a),{path:d}),o);f=i(y===h?y:m(y),n,w(v({},a),{path:d}),o),Number.isNaN(f)&&p<u.length?(u.splice(p,1),p-=1):u[p]=f}else u.splice(p,1)}else if(N(u))for(let p in u){if(o.now&&p!=null)break;let c=a.path?"".concat(a.path,".").concat(p):p;a.depth===0&&p!=null&&(a.topmostKey=p),a.parent=m(u),a.parentType="object",a.parentKey=a.path?a.path.slice(a.path.lastIndexOf(".")+1):null;let d=u[p],h=n(p,d,w(v({},a),{path:c}),o);f=i(h===d?h:m(h),n,w(v({},a),{path:c}),o),Number.isNaN(f)?delete u[p]:u[p]=f}return u}return i(m(e),t,{},r)}var _="5.2.0";var ce=_;function he(e,t,r){let i;r!==void 0&&(i=Array.isArray(r)?m(r):[m(r)]);let l=[],n=V(e,(s,o,u)=>{let f=o!==void 0?o:s;if(o!==void 0&&K(s,t,{caseSensitiveMatch:!0})){if(i===void 0)l.push({val:o,path:u.path});else if(i.length)return i.shift()}return f});return i===void 0?l:n}return Y(de);})();
11
11
  /**
12
12
  * @name codsen-utils
13
13
  * @fileoverview Various utility functions
14
- * @version 1.7.0
14
+ * @version 1.8.0
15
15
  * @author Roy Revelt
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/codsen-utils/}
18
18
  */
19
- /**
20
- * @name ast-monkey-util
21
- * @fileoverview Utility library of AST helper functions
22
- * @version 3.1.0
23
- * @author Roy Revelt
24
- * @license MIT
25
- * {@link https://codsen.com/os/ast-monkey-util/}
26
- */
27
19
  /**
28
20
  * @name ast-monkey-traverse
29
21
  * @fileoverview Utility library to traverse AST
30
- * @version 4.1.0
22
+ * @version 4.2.0
31
23
  * @author Roy Revelt
32
24
  * @license MIT
33
25
  * {@link https://codsen.com/os/ast-monkey-traverse/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ast-get-values-by-key",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "Extract values and paths from AST by keys OR set them by keys",
5
5
  "keywords": [
6
6
  "ast",
@@ -44,45 +44,43 @@
44
44
  },
45
45
  "types": "types/index.d.ts",
46
46
  "scripts": {
47
- "build": "node '../../ops/scripts/esbuild.js' && npm run dts",
48
- "cjs-off": "exit 0",
49
- "cjs-on": "exit 0",
50
- "dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
47
+ "build": "node ../../ops/scripts/esbuild.js && npm run dts",
48
+ "coverage": "c8 uvu test",
49
+ "dev": "node ../../ops/scripts/esbuild.js --dev && npm run dts",
51
50
  "devtest": "c8 npm run unit && npm run examples && npm run lint",
52
- "dts": "rollup -c && npm run prettier -- 'types/index.d.ts' --write --log-level 'silent'",
51
+ "dts": "rollup -c && biome format --write --config-path=../../biome.json --vcs-enabled=false --use-editorconfig=false types/index.d.ts",
53
52
  "examples": "node '../../ops/scripts/run-examples.js'",
54
- "lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
55
- "letspublish": "npm publish --provenance || :",
56
- "lint": "eslint . --fix --concurrency=auto --cache",
53
+ "lect": "node '../../ops/lect/lect.js'",
54
+ "lect:check": "node '../../ops/lect/lect.js' --check",
55
+ "lint": "biome lint --error-on-warnings . && npm run typecheck",
56
+ "lint:fix": "biome lint --write --error-on-warnings . && npm run typecheck",
57
57
  "perf": "node perf/check.js",
58
58
  "prep": "echo 'ready'",
59
- "prettier": "prettier",
60
- "prettier:format": "npm run prettier -- --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern --log-level 'silent'",
61
- "pretest": "npm run lect && npm run build",
59
+ "prettier": "biome format",
60
+ "prettier:format": "biome format --write .",
61
+ "pretest": "npm run lect:check && npm run build",
62
62
  "test": "npm run devtest",
63
+ "typecheck": "tsc --noEmit --pretty false --project tsconfig.json",
63
64
  "unit": "uvu test"
64
65
  },
65
- "engines": {
66
- "node": ">=14.18.0"
67
- },
68
66
  "c8": {
67
+ "all": true,
69
68
  "check-coverage": true,
70
- "exclude": [
71
- "**/test/**/*.*"
72
- ],
69
+ "exclude": ["**/test/**/*.*"],
70
+ "include": ["dist/*.esm.js"],
73
71
  "lines": 100
74
72
  },
75
73
  "lect": {
76
74
  "licence": {
77
- "extras": [
78
- ""
79
- ]
75
+ "extras": [""]
80
76
  }
81
77
  },
82
78
  "dependencies": {
83
- "ast-monkey-traverse": "^4.1.0",
84
- "matcher": "^6.0.0",
85
- "rfdc": "^1.4.1"
79
+ "ast-monkey-traverse": "^4.2.0",
80
+ "codsen-utils": "^1.8.0"
81
+ },
82
+ "engines": {
83
+ "node": ">=18.20.8"
86
84
  },
87
85
  "publishConfig": {
88
86
  "registry": "https://registry.npmjs.org/"
package/.eslintcache DELETED
@@ -1 +0,0 @@
1
- [{"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/examples/_quickTake.js":"1","/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/examples/real-use.js":"2","/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/examples/wildcards.js":"3","/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/perf/check.js":"4","/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/rollup.config.js":"5","/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/src/main.ts":"6","/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/test/get.js":"7","/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/test/other.js":"8","/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/test/set.js":"9","/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/test/wildcards.js":"10"},{"size":933,"mtime":1760566739070,"results":"11","hashOfConfig":"12"},{"size":1407,"mtime":1760566739070,"results":"13","hashOfConfig":"12"},{"size":836,"mtime":1760566739070,"results":"14","hashOfConfig":"12"},{"size":379,"mtime":1760566739070,"results":"15","hashOfConfig":"16"},{"size":373,"mtime":1760566739070,"results":"17","hashOfConfig":"12"},{"size":1291,"mtime":1760566739070,"results":"18","hashOfConfig":"16"},{"size":4909,"mtime":1760566739070,"results":"19","hashOfConfig":"20"},{"size":832,"mtime":1760566739070,"results":"21","hashOfConfig":"20"},{"size":2936,"mtime":1760566739070,"results":"22","hashOfConfig":"20"},{"size":931,"mtime":1760566739070,"results":"23","hashOfConfig":"20"},{"filePath":"24","messages":"25","suppressedMessages":"26","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1nlhngw",{"filePath":"27","messages":"28","suppressedMessages":"29","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"30","messages":"31","suppressedMessages":"32","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"33","messages":"34","suppressedMessages":"35","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1xjytlu",{"filePath":"36","messages":"37","suppressedMessages":"38","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"39","messages":"40","suppressedMessages":"41","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"42","messages":"43","suppressedMessages":"44","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"nrihsz",{"filePath":"45","messages":"46","suppressedMessages":"47","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"48","messages":"49","suppressedMessages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"51","messages":"52","suppressedMessages":"53","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/examples/_quickTake.js",[],[],"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/examples/real-use.js",[],[],"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/examples/wildcards.js",[],[],"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/perf/check.js",[],[],"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/rollup.config.js",[],[],"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/src/main.ts",[],[],"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/test/get.js",[],["54","55","56","57","58","59"],"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/test/other.js",[],["60","61","62","63","64"],"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/test/set.js",[],["65","66","67","68","69","70"],"/home/runner/work/codsen/codsen/packages/ast-get-values-by-key/test/wildcards.js",[],["71","72","73","74","75","76"],{"ruleId":"77","severity":2,"message":"78","line":3,"column":17,"nodeType":null,"messageId":"79","endLine":3,"endColumn":19,"suppressions":"80"},{"ruleId":"77","severity":2,"message":"81","line":3,"column":21,"nodeType":null,"messageId":"79","endLine":3,"endColumn":23,"suppressions":"82"},{"ruleId":"77","severity":2,"message":"83","line":3,"column":25,"nodeType":null,"messageId":"79","endLine":3,"endColumn":31,"suppressions":"84"},{"ruleId":"77","severity":2,"message":"85","line":3,"column":33,"nodeType":null,"messageId":"79","endLine":3,"endColumn":37,"suppressions":"86"},{"ruleId":"77","severity":2,"message":"87","line":3,"column":39,"nodeType":null,"messageId":"79","endLine":3,"endColumn":42,"suppressions":"88"},{"ruleId":"77","severity":2,"message":"89","line":3,"column":44,"nodeType":null,"messageId":"79","endLine":3,"endColumn":49,"suppressions":"90"},{"ruleId":"77","severity":2,"message":"81","line":3,"column":21,"nodeType":null,"messageId":"79","endLine":3,"endColumn":23,"suppressions":"91"},{"ruleId":"77","severity":2,"message":"83","line":3,"column":25,"nodeType":null,"messageId":"79","endLine":3,"endColumn":31,"suppressions":"92"},{"ruleId":"77","severity":2,"message":"85","line":3,"column":33,"nodeType":null,"messageId":"79","endLine":3,"endColumn":37,"suppressions":"93"},{"ruleId":"77","severity":2,"message":"87","line":3,"column":39,"nodeType":null,"messageId":"79","endLine":3,"endColumn":42,"suppressions":"94"},{"ruleId":"77","severity":2,"message":"89","line":3,"column":44,"nodeType":null,"messageId":"79","endLine":3,"endColumn":49,"suppressions":"95"},{"ruleId":"77","severity":2,"message":"78","line":3,"column":17,"nodeType":null,"messageId":"79","endLine":3,"endColumn":19,"suppressions":"96"},{"ruleId":"77","severity":2,"message":"81","line":3,"column":21,"nodeType":null,"messageId":"79","endLine":3,"endColumn":23,"suppressions":"97"},{"ruleId":"77","severity":2,"message":"83","line":3,"column":25,"nodeType":null,"messageId":"79","endLine":3,"endColumn":31,"suppressions":"98"},{"ruleId":"77","severity":2,"message":"85","line":3,"column":33,"nodeType":null,"messageId":"79","endLine":3,"endColumn":37,"suppressions":"99"},{"ruleId":"77","severity":2,"message":"87","line":3,"column":39,"nodeType":null,"messageId":"79","endLine":3,"endColumn":42,"suppressions":"100"},{"ruleId":"77","severity":2,"message":"89","line":3,"column":44,"nodeType":null,"messageId":"79","endLine":3,"endColumn":49,"suppressions":"101"},{"ruleId":"77","severity":2,"message":"78","line":3,"column":17,"nodeType":null,"messageId":"79","endLine":3,"endColumn":19,"suppressions":"102"},{"ruleId":"77","severity":2,"message":"81","line":3,"column":21,"nodeType":null,"messageId":"79","endLine":3,"endColumn":23,"suppressions":"103"},{"ruleId":"77","severity":2,"message":"83","line":3,"column":25,"nodeType":null,"messageId":"79","endLine":3,"endColumn":31,"suppressions":"104"},{"ruleId":"77","severity":2,"message":"85","line":3,"column":33,"nodeType":null,"messageId":"79","endLine":3,"endColumn":37,"suppressions":"105"},{"ruleId":"77","severity":2,"message":"87","line":3,"column":39,"nodeType":null,"messageId":"79","endLine":3,"endColumn":42,"suppressions":"106"},{"ruleId":"77","severity":2,"message":"89","line":3,"column":44,"nodeType":null,"messageId":"79","endLine":3,"endColumn":49,"suppressions":"107"},"@typescript-eslint/no-unused-vars","'is' is defined but never used.","unusedVar",["108"],"'ok' is defined but never used.",["109"],"'throws' is defined but never used.",["110"],"'type' is defined but never used.",["111"],"'not' is defined but never used.",["112"],"'match' is defined but never used.",["113"],["114"],["115"],["116"],["117"],["118"],["119"],["120"],["121"],["122"],["123"],["124"],["125"],["126"],["127"],["128"],["129"],["130"],{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},{"kind":"131","justification":"132"},"directive",""]