ast-compare 4.2.0 → 4.2.2
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 +7 -1
- package/dist/ast-compare.esm.js +2 -2
- package/dist/ast-compare.umd.js +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,13 +3,19 @@
|
|
|
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.2.2 (2026-08-22)
|
|
7
|
+
|
|
8
|
+
### Performance Improvements
|
|
9
|
+
|
|
10
|
+
- optimise package hot paths and JSON editing ([f3112bd](https://github.com/codsen/codsen/commit/f3112bd7fc0d7c9bc09312d3744c950691d72ca5))
|
|
11
|
+
|
|
6
12
|
## 4.2.0 (2026-08-19)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
|
9
15
|
|
|
10
16
|
- repair representative perf workloads ([975e958](https://github.com/codsen/codsen/commit/975e958c0794ec256eba84e088b472483fb69e52))
|
|
11
17
|
- require every wildard object key to match ([b6ab279](https://github.com/codsen/codsen/commit/b6ab2795ac11715ea142c74268c550ef443757c8))
|
|
12
|
-
- resolve review findings
|
|
18
|
+
- resolve various review findings ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
|
|
13
19
|
- retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
|
|
14
20
|
|
|
15
21
|
### Features
|
package/dist/ast-compare.esm.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-compare
|
|
3
3
|
* @fileoverview Compare anything: AST, objects, arrays, strings and nested thereof
|
|
4
|
-
* @version 4.2.
|
|
4
|
+
* @version 4.2.2
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-compare/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{empty as l}from"ast-contains-only-empty-space";import{hasOwnProp as D,isPlainObject as c,match as d}from"codsen-utils";var p="4.2.
|
|
10
|
+
import{empty as l}from"ast-contains-only-empty-space";import{hasOwnProp as D,isPlainObject as c,match as d}from"codsen-utils";var p="4.2.2";var x=p;function j(e){return c(e)?!Object.keys(e).length:Array.isArray(e)||typeof e=="string"?!e.length:!1}function b(e,n){return e===null||n===null?e===n:Array.isArray(e)||Array.isArray(n)?Array.isArray(e)&&Array.isArray(n):typeof e==typeof n}function $(e){return e===null?"null":Array.isArray(e)?"Array":c(e)?"Object":typeof e}var S={arrayOrder:"ordered",hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1};function w(e,n,t){return f(e,n,{...S,...t})}function f(e,n,t){let u,h,i,y=0;if(t.hungryForWhitespace&&t.matchStrictly&&c(e)&&l(e)&&c(n)&&!Object.keys(n).length)return!0;if((!t.hungryForWhitespace||t.hungryForWhitespace&&!l(e)&&l(n))&&c(e)&&Object.keys(e).length!==0&&c(n)&&Object.keys(n).length===0||!b(e,n)&&(!t.hungryForWhitespace||t.hungryForWhitespace&&!l(e)))return!1;if(typeof e=="string"&&typeof n=="string"){if(t.hungryForWhitespace&&l(e)&&l(n))return!0;let r=t.useWildcards?d(e,n,{caseSensitiveMatch:!0}):e===n;return t.verboseWhenMismatches?r?!0:`Given string ${n} is not matched! We have ${e} on the other end.`:r}if(Array.isArray(e)&&Array.isArray(n)){if(t.hungryForWhitespace&&l(n)&&(!t.matchStrictly||t.matchStrictly&&e.length===n.length))return!0;if(!t.hungryForWhitespace&&n.length>e.length||t.matchStrictly&&n.length!==e.length)return t.verboseWhenMismatches?`The length of a given array, ${JSON.stringify(n,null,4)} is ${n.length} but the length of an array on the other end, ${JSON.stringify(e,null,4)} is ${e.length}`:!1;if(n.length===0)return e.length===0?!0:t.verboseWhenMismatches?`The given array has no elements, but the array on the other end, ${JSON.stringify(e,null,4)} does have some`:!1;if(t.arrayOrder==="any")i=W(e,n,t);else{i=!0;for(let r=0,s=n.length;r<s;r++){i=!1;for(let o=y,a=e.length;o<a;o++)if(y+=1,f(e[o],n[r],t)===!0){i=!0;break}if(!i)break}}if(!i)return t.verboseWhenMismatches?`The given array ${JSON.stringify(n,null,4)} is not a subset of an array on the other end, ${JSON.stringify(e,null,4)}`:!1}else if(c(e)&&c(n)){if(u=Object.keys(n),h=Object.keys(e),t.matchStrictly&&u.length!==h.length){if(!t.verboseWhenMismatches)return!1;let r=new Set(u),s=new Set(h),o=u.filter(g=>!s.has(g)),a=o.length?` First object has unique keys: ${JSON.stringify(o,null,4)}.`:"",m=h.filter(g=>!r.has(g)),V=m.length?` Second object has unique keys:
|
|
11
11
|
${JSON.stringify(m,null,4)}.`:"";return`When matching strictly, we found that both objects have different amount of keys.${a}${V}`}for(let r of u){if(!D(e,r)){if(!t.useWildcards||t.useWildcards&&!r.includes("*"))return t.verboseWhenMismatches?`The given object has key "${r}" which the other-one does not have.`:!1;if(h.some(s=>d(s,r,{caseSensitiveMatch:!0})))continue;return t.verboseWhenMismatches?`The given object has key "${r}" which the other-one does not have.`:!1}if(e[r]!=null&&!b(e[r],n[r])){if(!(l(e[r])&&l(n[r])&&t.hungryForWhitespace))return t.verboseWhenMismatches?`The given key ${r} is of a different type on both objects. On the first-one, it's ${$(n[r])}, on the second-one, it's ${$(e[r])}`:!1}else if(f(e[r],n[r],t)!==!0)return t.verboseWhenMismatches?`The given piece ${JSON.stringify(n[r],null,4)} and ${JSON.stringify(e[r],null,4)} don't match.`:!1}}else return t.hungryForWhitespace&&l(e)&&l(n)&&(!t.matchStrictly||t.matchStrictly&&j(n))?!0:e===n;return!0}function W(e,n,t){let u=t.verboseWhenMismatches?{...t,verboseWhenMismatches:!1}:t,h=Array.from({length:n.length},(r,s)=>Array.from({length:e.length},(o,a)=>f(e[a],n[s],u)===!0)),i=new Array(e.length).fill(-1);function y(r,s){for(let o=0;o<e.length;o++){if(!h[r][o]||s[o])continue;s[o]=!0;let a=i[o];if(a===-1||y(a,s))return i[o]=r,!0}return!1}for(let r=0;r<n.length;r++)if(!y(r,new Array(e.length).fill(!1)))return!1;return!0}export{w as compare,S as defaults,x as version};
|
package/dist/ast-compare.umd.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-compare
|
|
3
3
|
* @fileoverview Compare anything: AST, objects, arrays, strings and nested thereof
|
|
4
|
-
* @version 4.2.
|
|
4
|
+
* @version 4.2.2
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-compare/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var astCompare=(()=>{var v=Object.defineProperty,_=Object.defineProperties,Q=Object.getOwnPropertyDescriptor,H=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var C=(e,t,r)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,S=(e,t)=>{for(var r in t||(t={}))M.call(t,r)&&C(e,r,t[r]);if(O)for(var r of O(t))z.call(t,r)&&C(e,r,t[r]);return e},F=(e,t)=>_(e,H(t));var Z=(e,t)=>{for(var r in t)v(e,r,{get:t[r],enumerable:!0})},Y=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of G(t))!M.call(e,s)&&s!==r&&v(e,s,{get:()=>t[s],enumerable:!(i=Q(t,s))||i.enumerable});return e};var X=e=>Y(v({},"__esModule",{value:!0}),e);var be={};Z(be,{compare:()=>de,defaults:()=>q,version:()=>ge});function ee(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)}function E(e){if(typeof e=="string")return!e.trim();if(Array.isArray(e)){for(let t of e)if(!E(t))return!1}else if(ee(e)){for(let t of Object.keys(e))if(!E(e[t]))return!1}return!0}function h(e){return typeof e=="string"?!e.trim():typeof e!="object"||!e?!1:E(e)}var Se=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"]),te=Object.prototype.hasOwnProperty;function g(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)}function re(e){return typeof e=="string"}function N(e,t){return g(e)&&re(t)&&te.call(e,t)}var ne=256,ie=1024,oe=1,se=new Map,le=new Map;function V(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 W(e,t,r,i,s,o){for(let l=0;l<s;l++){let n=e.charCodeAt(t+l),u=r.charCodeAt(i+l);if(o||(n>=97&&n<=122&&(n-=32),u>=97&&u<=122&&(u-=32)),n!==u)return!1}return!0}function B(e,t,r){let i=t.indexOf("\\");if(i===-1&&e===t)return!0;let s=t.indexOf("*");if(i===-1&&s===-1){if(r)return!1;for(let f=0;f<t.length;f++)if(t.charCodeAt(f)>127)return;return e.length===t.length&&W(e,0,t,0,t.length,!1)}if(i!==-1)return;let o=0,l=!1,n=-1;for(let f=0;f<t.length;f++){let m=t.charCodeAt(f);if(m>127)return;if(m===42){if(n=f,!l){if(o++,o>1)return;l=!0}}else l=!1}let u=n+1,a=t.length-u;return e.length<s+a?!1:W(e,0,t,0,s,r)&&W(e,e.length-a,t,u,a,r)}function ue(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 ae(e,t){let r=[[]],i=!0,s=!1,o=!1,l=0;for(let c=0;c<e.length;){let y=e.codePointAt(c);if(y!==92){if(y===42)s=!0,o||(r.push([]),o=!0);else{let d=t?y:V(y);r[r.length-1].push(d),i&&(i=d<=127),l++,o=!1}c+=y>65535?2:1;continue}let b=c+1;for(;e.charCodeAt(b)===92;)b++;let A=b-c,p=e.codePointAt(b),$,j=!1;p===42?(j=A%2===0,$=j?A/2:(A-1)/2):p===void 0||p===10||p===13||p===8232||p===8233?$=Math.ceil(A/2):$=Math.floor(A/2);for(let d=0;d<$;d++)r[r.length-1].push(92),l++;if(j){o=!1,c=b;continue}if(p!==void 0){let d=t?p:V(p);r[r.length-1].push(d),i&&(i=d<=127),l++,b+=p>65535?2:1}o=!1,c=b}let n=s&&r[0].length===0,u=s&&r[r.length-1].length===0,a=[];for(let c of r)c.length&&a.push({values:c});let f=n?0:1,m=a.length-(u?0:1);for(let c=f;c<m;c++)a[c].values.length>oe&&(a[c].failure=ue(a[c].values));return{asciiOnly:i,endsWithWildcard:u,hasWildcard:s,minimumInputLength:l,segments:a,startsWithWildcard:n}}function I(e,t){let r=t?se:le,i=e.length<=ie;if(i){let o=r.get(e);if(o)return o}let s=ae(e,t);if(i){if(r.size>=ne){let o=r.keys().next().value;o!==void 0&&r.delete(o)}r.set(e,s)}return s}function L(e,t){if(t){let s=[];for(let o=0;o<e.length;){let l=e.codePointAt(o);s.push(l),o+=l>65535?2:1}return s}let r=new Uint32Array(e.length),i=0;for(let s=0;s<e.length;){let o=e.codePointAt(s);r[i]=V(o),i++,s+=o>65535?2:1}return i===r.length?r:r.subarray(0,i)}function D(e,t,r,i){for(let s=0;s<r.values.length;s++){let o=e.charCodeAt(t+s);if(!i&&o>=97&&o<=122&&(o-=32),o!==r.values[s])return!1}return!0}function fe(e,t,r,i,s){let o=i-t.values.length;if(o<r)return-1;if(!t.failure){for(let n=r;n<=o;n++)if(D(e,n,t,s))return n;return-1}let l=0;for(let n=r;n<i;n++){let u=e.charCodeAt(n);for(!s&&u>=97&&u<=122&&(u-=32);l>0&&u!==t.values[l];)l=t.failure[l-1];if(u===t.values[l]&&(l++,l===t.values.length))return n-l+1}return-1}function R(e,t,r){if(e.length<t.minimumInputLength)return!1;if(!t.hasWildcard)return e.length===t.minimumInputLength&&D(e,0,t.segments[0],r);let i=0,s=t.segments.length,o=0,l=e.length;if(!t.startsWithWildcard){let n=t.segments[0];if(!D(e,0,n,r))return!1;o=n.values.length,i++}if(!t.endsWithWildcard){s--;let n=t.segments[s];if(l-=n.values.length,!D(e,l,n,r))return!1}for(let n=i;n<s;n++){let u=t.segments[n],a=fe(e,u,o,l,r);if(a===-1)return!1;o=a+u.values.length}return!0}function w(e,t,r){for(let i=0;i<r.values.length;i++)if(e[t+i]!==r.values[i])return!1;return!0}function ce(e,t,r,i){let s=i-t.values.length;if(s<r)return-1;if(!t.failure){for(let l=r;l<=s;l++)if(w(e,l,t))return l;return-1}let o=0;for(let l=r;l<i;l++){for(;o>0&&e[l]!==t.values[o];)o=t.failure[o-1];if(e[l]===t.values[o]&&(o++,o===t.values.length))return l-o+1}return-1}function T(e,t){if(e.length<t.minimumInputLength)return!1;if(!t.hasWildcard)return e.length===t.minimumInputLength&&w(e,0,t.segments[0]);let r=0,i=t.segments.length,s=0,o=e.length;if(!t.startsWithWildcard){let l=t.segments[0];if(!w(e,0,l))return!1;s=l.values.length,r++}if(!t.endsWithWildcard){i--;let l=t.segments[i];if(o-=l.values.length,!w(e,o,l))return!1}for(let l=r;l<i;l++){let n=t.segments[l],u=ce(e,n,s,o);if(u===-1)return!1;s=u+n.values.length}return!0}function he(e,t,r){let i=B(e,t,r);if(i!==void 0)return i;let s=I(t,r);return s.asciiOnly?R(e,s,r):T(L(e,r),s)}function J(e,t,r,i){var l;let s=B(e,t,r);if(s!==void 0)return s;let o=I(t,r);return o.asciiOnly?R(e,o,r):((l=i.tokens)!=null||(i.tokens=L(e,r)),T(i.tokens,o))}function x(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 n=t.charCodeAt(0)===33,u=n?t.slice(1):t,a=he(e,u,i);return n?!a:a}let s={},o=!1,l=!1;for(let n of t){let u=n.charCodeAt(0)===33,a=u?n.slice(1):n;if(u){if(J(e,a,i,s))return!1}else o=!0,!l&&J(e,a,i,s)&&(l=!0)}return o?l:!0}var P="4.2.0";var ge=P;function ye(e){return g(e)?!Object.keys(e).length:Array.isArray(e)||typeof e=="string"?!e.length:!1}function K(e,t){return e===null||t===null?e===t:Array.isArray(e)||Array.isArray(t)?Array.isArray(e)&&Array.isArray(t):typeof e==typeof t}function U(e){return e===null?"null":Array.isArray(e)?"Array":g(e)?"Object":typeof e}var q={arrayOrder:"ordered",hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1};function de(e,t,r){return k(e,t,S(S({},q),r))}function k(e,t,r){let i,s,o,l=0;if(r.hungryForWhitespace&&r.matchStrictly&&g(e)&&h(e)&&g(t)&&!Object.keys(t).length)return!0;if((!r.hungryForWhitespace||r.hungryForWhitespace&&!h(e)&&h(t))&&g(e)&&Object.keys(e).length!==0&&g(t)&&Object.keys(t).length===0||!K(e,t)&&(!r.hungryForWhitespace||r.hungryForWhitespace&&!h(e)))return!1;if(typeof e=="string"&&typeof t=="string"){if(r.hungryForWhitespace&&h(e)&&h(t))return!0;let n=r.useWildcards?x(e,t,{caseSensitiveMatch:!0}):e===t;return r.verboseWhenMismatches?n?!0:"Given string ".concat(t," is not matched! We have ").concat(e," on the other end."):n}if(Array.isArray(e)&&Array.isArray(t)){if(r.hungryForWhitespace&&h(t)&&(!r.matchStrictly||r.matchStrictly&&e.length===t.length))return!0;if(!r.hungryForWhitespace&&t.length>e.length||r.matchStrictly&&t.length!==e.length)return r.verboseWhenMismatches?"The length of a given array, ".concat(JSON.stringify(t,null,4)," is ").concat(t.length," but the length of an array on the other end, ").concat(JSON.stringify(e,null,4)," is ").concat(e.length):!1;if(t.length===0)return e.length===0?!0:r.verboseWhenMismatches?"The given array has no elements, but the array on the other end, ".concat(JSON.stringify(e,null,4)," does have some"):!1;if(r.arrayOrder==="any")o=me(e,t,r);else{o=!0;for(let n=0,u=t.length;n<u;n++){o=!1;for(let a=l,f=e.length;a<f;a++)if(l+=1,k(e[a],t[n],r)===!0){o=!0;break}if(!o)break}}if(!o)return r.verboseWhenMismatches?"The given array ".concat(JSON.stringify(t,null,4)," is not a subset of an array on the other end, ").concat(JSON.stringify(e,null,4)):!1}else if(g(e)&&g(t)){if(i=Object.keys(t),s=Object.keys(e),r.matchStrictly&&i.length!==s.length){if(!r.verboseWhenMismatches)return!1;let n=new Set(i),u=new Set(s),a=i.filter(y=>!u.has(y)),f=a.length?" First object has unique keys: ".concat(JSON.stringify(a,null,4),"."):"",m=s.filter(y=>!n.has(y)),c=m.length?" Second object has unique keys:\n ".concat(JSON.stringify(m,null,4),"."):"";return"When matching strictly, we found that both objects have different amount of keys.".concat(f).concat(c)}for(let n of i){if(!N(e,n)){if(!r.useWildcards||r.useWildcards&&!n.includes("*"))return r.verboseWhenMismatches?'The given object has key "'.concat(n,'" which the other-one does not have.'):!1;if(s.some(u=>x(u,n,{caseSensitiveMatch:!0})))continue;return r.verboseWhenMismatches?'The given object has key "'.concat(n,'" which the other-one does not have.'):!1}if(e[n]!=null&&!K(e[n],t[n])){if(!(h(e[n])&&h(t[n])&&r.hungryForWhitespace))return r.verboseWhenMismatches?"The given key ".concat(n," is of a different type on both objects. On the first-one, it's ").concat(U(t[n]),", on the second-one, it's ").concat(U(e[n])):!1}else if(k(e[n],t[n],r)!==!0)return r.verboseWhenMismatches?"The given piece ".concat(JSON.stringify(t[n],null,4)," and ").concat(JSON.stringify(e[n],null,4)," don't match."):!1}}else return r.hungryForWhitespace&&h(e)&&h(t)&&(!r.matchStrictly||r.matchStrictly&&ye(t))?!0:e===t;return!0}function me(e,t,r){let i=r.verboseWhenMismatches?F(S({},r),{verboseWhenMismatches:!1}):r,s=Array.from({length:t.length},(n,u)=>Array.from({length:e.length},(a,f)=>k(e[f],t[u],i)===!0)),o=new Array(e.length).fill(-1);function l(n,u){for(let a=0;a<e.length;a++){if(!s[n][a]||u[a])continue;u[a]=!0;let f=o[a];if(f===-1||l(f,u))return o[a]=n,!0}return!1}for(let n=0;n<t.length;n++)if(!l(n,new Array(e.length).fill(!1)))return!1;return!0}return X(be);})();
|
|
10
|
+
"use strict";var astCompare=(()=>{var S=Object.defineProperty,Q=Object.defineProperties,H=Object.getOwnPropertyDescriptor,G=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertyNames,W=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var C=(e,t,r)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))M.call(t,r)&&C(e,r,t[r]);if(W)for(var r of W(t))Z.call(t,r)&&C(e,r,t[r]);return e},F=(e,t)=>Q(e,G(t));var Y=(e,t)=>{for(var r in t)S(e,r,{get:t[r],enumerable:!0})},X=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of z(t))!M.call(e,l)&&l!==r&&S(e,l,{get:()=>t[l],enumerable:!(o=H(t,l))||o.enumerable});return e};var ee=e=>X(S({},"__esModule",{value:!0}),e);var Ae={};Y(Ae,{compare:()=>me,defaults:()=>_,version:()=>ye});function te(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)}function E(e){if(typeof e=="string")return!e.trim();if(Array.isArray(e)){for(let t of e)if(!E(t))return!1}else if(te(e)){for(let t of Object.keys(e))if(!E(e[t]))return!1}return!0}function h(e){return typeof e=="string"?!e.trim():typeof e!="object"||!e?!1:E(e)}var De=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"]),re=Object.prototype.hasOwnProperty;function g(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)}function ne(e){return typeof e=="string"}var R,we=(R=Object.getOwnPropertyDescriptor(RegExp.prototype,"source"))==null?void 0:R.get;var je=Date.prototype.getTime;function I(e,t){return g(e)&&ne(t)&&re.call(e,t)}var oe=256,ie=1024,le=1,se=new Map,ue=new Map;function x(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 O(e,t,r,o,l,i){for(let s=0;s<l;s++){let n=e.charCodeAt(t+s),u=r.charCodeAt(o+s);if(i||(n>=97&&n<=122&&(n-=32),u>=97&&u<=122&&(u-=32)),n!==u)return!1}return!0}function B(e,t,r){let o=t.indexOf("\\");if(o===-1&&e===t)return!0;let l=t.indexOf("*");if(o===-1&&l===-1){if(r)return!1;for(let f=0;f<t.length;f++)if(t.charCodeAt(f)>127)return;return e.length===t.length&&O(e,0,t,0,t.length,!1)}if(o!==-1)return;let i=0,s=!1,n=-1;for(let f=0;f<t.length;f++){let m=t.charCodeAt(f);if(m>127)return;if(m===42){if(n=f,!s){if(i++,i>1)return;s=!0}}else s=!1}let u=n+1,a=t.length-u;return e.length<l+a?!1:O(e,0,t,0,l,r)&&O(e,e.length-a,t,u,a,r)}function ae(e){let t=new Uint32Array(e.length),r=0;for(let o=1;o<e.length;o++){for(;r>0&&e[o]!==e[r];)r=t[r-1];e[o]===e[r]&&r++,t[o]=r}return t}function fe(e,t){let r=[[]],o=!0,l=!1,i=!1,s=0;for(let c=0;c<e.length;){let y=e.codePointAt(c);if(y!==92){if(y===42)l=!0,i||(r.push([]),i=!0);else{let d=t?y:x(y);r[r.length-1].push(d),o&&(o=d<=127),s++,i=!1}c+=y>65535?2:1;continue}let b=c+1;for(;e.charCodeAt(b)===92;)b++;let A=b-c,p=e.codePointAt(b),$,k=!1;p===42?(k=A%2===0,$=k?A/2:(A-1)/2):p===void 0||p===10||p===13||p===8232||p===8233?$=Math.ceil(A/2):$=Math.floor(A/2);for(let d=0;d<$;d++)r[r.length-1].push(92),s++;if(k){i=!1,c=b;continue}if(p!==void 0){let d=t?p:x(p);r[r.length-1].push(d),o&&(o=d<=127),s++,b+=p>65535?2:1}i=!1,c=b}let n=l&&r[0].length===0,u=l&&r[r.length-1].length===0,a=[];for(let c of r)c.length&&a.push({values:c});let f=n?0:1,m=a.length-(u?0:1);for(let c=f;c<m;c++)a[c].values.length>le&&(a[c].failure=ae(a[c].values));return{asciiOnly:o,endsWithWildcard:u,hasWildcard:l,minimumInputLength:s,segments:a,startsWithWildcard:n}}function L(e,t){let r=t?se:ue,o=e.length<=ie;if(o){let i=r.get(e);if(i)return i}let l=fe(e,t);if(o){if(r.size>=oe){let i=r.keys().next().value;i!==void 0&&r.delete(i)}r.set(e,l)}return l}function T(e,t){if(t){let l=[];for(let i=0;i<e.length;){let s=e.codePointAt(i);l.push(s),i+=s>65535?2:1}return l}let r=new Uint32Array(e.length),o=0;for(let l=0;l<e.length;){let i=e.codePointAt(l);r[o]=x(i),o++,l+=i>65535?2:1}return o===r.length?r:r.subarray(0,o)}function D(e,t,r,o){for(let l=0;l<r.values.length;l++){let i=e.charCodeAt(t+l);if(!o&&i>=97&&i<=122&&(i-=32),i!==r.values[l])return!1}return!0}function ce(e,t,r,o,l){let i=o-t.values.length;if(i<r)return-1;if(!t.failure){for(let n=r;n<=i;n++)if(D(e,n,t,l))return n;return-1}let s=0;for(let n=r;n<o;n++){let u=e.charCodeAt(n);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 n-s+1}return-1}function N(e,t,r){if(e.length<t.minimumInputLength)return!1;if(!t.hasWildcard)return e.length===t.minimumInputLength&&D(e,0,t.segments[0],r);let o=0,l=t.segments.length,i=0,s=e.length;if(!t.startsWithWildcard){let n=t.segments[0];if(!D(e,0,n,r))return!1;i=n.values.length,o++}if(!t.endsWithWildcard){l--;let n=t.segments[l];if(s-=n.values.length,!D(e,s,n,r))return!1}for(let n=o;n<l;n++){let u=t.segments[n],a=ce(e,u,i,s,r);if(a===-1)return!1;i=a+u.values.length}return!0}function w(e,t,r){for(let o=0;o<r.values.length;o++)if(e[t+o]!==r.values[o])return!1;return!0}function he(e,t,r,o){let l=o-t.values.length;if(l<r)return-1;if(!t.failure){for(let s=r;s<=l;s++)if(w(e,s,t))return s;return-1}let i=0;for(let s=r;s<o;s++){for(;i>0&&e[s]!==t.values[i];)i=t.failure[i-1];if(e[s]===t.values[i]&&(i++,i===t.values.length))return s-i+1}return-1}function P(e,t){if(e.length<t.minimumInputLength)return!1;if(!t.hasWildcard)return e.length===t.minimumInputLength&&w(e,0,t.segments[0]);let r=0,o=t.segments.length,l=0,i=e.length;if(!t.startsWithWildcard){let s=t.segments[0];if(!w(e,0,s))return!1;l=s.values.length,r++}if(!t.endsWithWildcard){o--;let s=t.segments[o];if(i-=s.values.length,!w(e,i,s))return!1}for(let s=r;s<o;s++){let n=t.segments[s],u=he(e,n,l,i);if(u===-1)return!1;l=u+n.values.length}return!0}function pe(e,t,r){let o=B(e,t,r);if(o!==void 0)return o;let l=L(t,r);return l.asciiOnly?N(e,l,r):P(T(e,r),l)}function J(e,t,r,o){var s;let l=B(e,t,r);if(l!==void 0)return l;let i=L(t,r);return i.asciiOnly?N(e,i,r):((s=o.tokens)!=null||(o.tokens=T(e,r)),P(o.tokens,i))}function V(e,t,r){if(typeof t!="string"&&!t.length)return!1;let o=r===void 0?!1:r.caseSensitiveMatch===!0;if(typeof t=="string"){let n=t.charCodeAt(0)===33,u=n?t.slice(1):t,a=pe(e,u,o);return n?!a:a}let l={},i=!1,s=!1;for(let n of t){let u=n.charCodeAt(0)===33,a=u?n.slice(1):n;if(u){if(J(e,a,o,l))return!1}else i=!0,!s&&J(e,a,o,l)&&(s=!0)}return i?s:!0}var K="4.2.2";var ye=K;function de(e){return g(e)?!Object.keys(e).length:Array.isArray(e)||typeof e=="string"?!e.length:!1}function U(e,t){return e===null||t===null?e===t:Array.isArray(e)||Array.isArray(t)?Array.isArray(e)&&Array.isArray(t):typeof e==typeof t}function q(e){return e===null?"null":Array.isArray(e)?"Array":g(e)?"Object":typeof e}var _={arrayOrder:"ordered",hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1};function me(e,t,r){return j(e,t,v(v({},_),r))}function j(e,t,r){let o,l,i,s=0;if(r.hungryForWhitespace&&r.matchStrictly&&g(e)&&h(e)&&g(t)&&!Object.keys(t).length)return!0;if((!r.hungryForWhitespace||r.hungryForWhitespace&&!h(e)&&h(t))&&g(e)&&Object.keys(e).length!==0&&g(t)&&Object.keys(t).length===0||!U(e,t)&&(!r.hungryForWhitespace||r.hungryForWhitespace&&!h(e)))return!1;if(typeof e=="string"&&typeof t=="string"){if(r.hungryForWhitespace&&h(e)&&h(t))return!0;let n=r.useWildcards?V(e,t,{caseSensitiveMatch:!0}):e===t;return r.verboseWhenMismatches?n?!0:"Given string ".concat(t," is not matched! We have ").concat(e," on the other end."):n}if(Array.isArray(e)&&Array.isArray(t)){if(r.hungryForWhitespace&&h(t)&&(!r.matchStrictly||r.matchStrictly&&e.length===t.length))return!0;if(!r.hungryForWhitespace&&t.length>e.length||r.matchStrictly&&t.length!==e.length)return r.verboseWhenMismatches?"The length of a given array, ".concat(JSON.stringify(t,null,4)," is ").concat(t.length," but the length of an array on the other end, ").concat(JSON.stringify(e,null,4)," is ").concat(e.length):!1;if(t.length===0)return e.length===0?!0:r.verboseWhenMismatches?"The given array has no elements, but the array on the other end, ".concat(JSON.stringify(e,null,4)," does have some"):!1;if(r.arrayOrder==="any")i=be(e,t,r);else{i=!0;for(let n=0,u=t.length;n<u;n++){i=!1;for(let a=s,f=e.length;a<f;a++)if(s+=1,j(e[a],t[n],r)===!0){i=!0;break}if(!i)break}}if(!i)return r.verboseWhenMismatches?"The given array ".concat(JSON.stringify(t,null,4)," is not a subset of an array on the other end, ").concat(JSON.stringify(e,null,4)):!1}else if(g(e)&&g(t)){if(o=Object.keys(t),l=Object.keys(e),r.matchStrictly&&o.length!==l.length){if(!r.verboseWhenMismatches)return!1;let n=new Set(o),u=new Set(l),a=o.filter(y=>!u.has(y)),f=a.length?" First object has unique keys: ".concat(JSON.stringify(a,null,4),"."):"",m=l.filter(y=>!n.has(y)),c=m.length?" Second object has unique keys:\n ".concat(JSON.stringify(m,null,4),"."):"";return"When matching strictly, we found that both objects have different amount of keys.".concat(f).concat(c)}for(let n of o){if(!I(e,n)){if(!r.useWildcards||r.useWildcards&&!n.includes("*"))return r.verboseWhenMismatches?'The given object has key "'.concat(n,'" which the other-one does not have.'):!1;if(l.some(u=>V(u,n,{caseSensitiveMatch:!0})))continue;return r.verboseWhenMismatches?'The given object has key "'.concat(n,'" which the other-one does not have.'):!1}if(e[n]!=null&&!U(e[n],t[n])){if(!(h(e[n])&&h(t[n])&&r.hungryForWhitespace))return r.verboseWhenMismatches?"The given key ".concat(n," is of a different type on both objects. On the first-one, it's ").concat(q(t[n]),", on the second-one, it's ").concat(q(e[n])):!1}else if(j(e[n],t[n],r)!==!0)return r.verboseWhenMismatches?"The given piece ".concat(JSON.stringify(t[n],null,4)," and ").concat(JSON.stringify(e[n],null,4)," don't match."):!1}}else return r.hungryForWhitespace&&h(e)&&h(t)&&(!r.matchStrictly||r.matchStrictly&&de(t))?!0:e===t;return!0}function be(e,t,r){let o=r.verboseWhenMismatches?F(v({},r),{verboseWhenMismatches:!1}):r,l=Array.from({length:t.length},(n,u)=>Array.from({length:e.length},(a,f)=>j(e[f],t[u],o)===!0)),i=new Array(e.length).fill(-1);function s(n,u){for(let a=0;a<e.length;a++){if(!l[n][a]||u[a])continue;u[a]=!0;let f=i[a];if(f===-1||s(f,u))return i[a]=n,!0}return!1}for(let n=0;n<t.length;n++)if(!s(n,new Array(e.length).fill(!1)))return!1;return!0}return ee(Ae);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name ast-contains-only-empty-space
|
|
13
13
|
* @fileoverview Does AST contain only empty space?
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* @name codsen-utils
|
|
21
21
|
* @fileoverview Various utility functions
|
|
22
|
-
* @version 1.
|
|
22
|
+
* @version 1.9.0
|
|
23
23
|
* @author Roy Revelt
|
|
24
24
|
* @license MIT
|
|
25
25
|
* {@link https://codsen.com/os/codsen-utils/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ast-compare",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Compare anything: AST, objects, arrays, strings and nested thereof",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"ast-contains-only-empty-space": "^4.2.0",
|
|
80
|
-
"codsen-utils": "^1.
|
|
80
|
+
"codsen-utils": "^1.9.0"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=18.20.8"
|