ast-get-values-by-key 5.2.0 → 5.2.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.
|
@@ -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.2.
|
|
4
|
+
* @version 5.2.1
|
|
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{deepClone as o,match as y}from"codsen-utils";var i="5.2.
|
|
10
|
+
import{traverse as m}from"ast-monkey-traverse";import{deepClone as o,match as y}from"codsen-utils";var i="5.2.1";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,13 +1,13 @@
|
|
|
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.2.
|
|
4
|
+
* @version 5.2.1
|
|
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 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.
|
|
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.1";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
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* @name ast-monkey-traverse
|
|
21
21
|
* @fileoverview Utility library to traverse AST
|
|
22
|
-
* @version 4.2.
|
|
22
|
+
* @version 4.2.1
|
|
23
23
|
* @author Roy Revelt
|
|
24
24
|
* @license MIT
|
|
25
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.2.
|
|
3
|
+
"version": "5.2.1",
|
|
4
4
|
"description": "Extract values and paths from AST by keys OR set them by keys",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"ast-monkey-traverse": "^4.2.
|
|
79
|
+
"ast-monkey-traverse": "^4.2.1",
|
|
80
80
|
"codsen-utils": "^1.8.0"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|