ast-compare 4.0.30 → 4.0.31
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/dist/ast-compare.esm.js +2 -2
- package/dist/ast-compare.umd.js +5 -5
- package/package.json +4 -4
- package/types/index.d.ts +2 -10
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.0.
|
|
4
|
+
* @version 4.0.31
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-compare/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import i from"type-detect";import{empty as s}from"ast-contains-only-empty-space";import{isPlainObject as o,hasOwnProp as O}from"codsen-utils";import{isMatch as m}from"matcher";var f="4.0.
|
|
10
|
+
import i from"type-detect";import{empty as s}from"ast-contains-only-empty-space";import{isPlainObject as o,hasOwnProp as O}from"codsen-utils";import{isMatch as m}from"matcher";var f="4.0.31";var J=f;function V(e){return o(e)?!Object.keys(e).length:Array.isArray(e)||typeof e=="string"?!e.length:!1}var D={hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1};function d(e,t,b){let c,u,h,g=0,r={...D,...b};if(r.hungryForWhitespace&&r.matchStrictly&&o(e)&&s(e)&&o(t)&&!Object.keys(t).length)return!0;if((!r.hungryForWhitespace||r.hungryForWhitespace&&!s(e)&&s(t))&&o(e)&&Object.keys(e).length!==0&&o(t)&&Object.keys(t).length===0||i(e)!==i(t)&&(!r.hungryForWhitespace||r.hungryForWhitespace&&!s(e)))return!1;if(typeof e=="string"&&typeof t=="string")return r.hungryForWhitespace&&s(e)&&s(t)?!0:r.verboseWhenMismatches?e===t?!0:`Given string ${t} is not matched! We have ${e} on the other end.`:r.useWildcards?m(e,t,{caseSensitive:!0}):e===t;if(Array.isArray(e)&&Array.isArray(t)){if(r.hungryForWhitespace&&s(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, ${JSON.stringify(t,null,4)} is ${t.length} but the length of an array on the other end, ${JSON.stringify(e,null,4)} is ${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, ${JSON.stringify(e,null,4)} does have some`:!1;for(let n=0,a=t.length;n<a;n++){h=!1;for(let l=g,y=e.length;l<y;l++)if(g+=1,d(e[l],t[n],r)===!0){h=!0;break}if(!h)return r.verboseWhenMismatches?`The given array ${JSON.stringify(t,null,4)} is not a subset of an array on the other end, ${JSON.stringify(e,null,4)}`:!1}}else if(o(e)&&o(t)){if(c=new Set(Object.keys(t)),u=new Set(Object.keys(e)),r.matchStrictly&&c.size!==u.size){if(!r.verboseWhenMismatches)return!1;let n=new Set([...c].filter(p=>!u.has(p))),a=n.size?` First object has unique keys: ${JSON.stringify(n,null,4)}.`:"",l=new Set([...u].filter(p=>!c.has(p))),y=l.size?` Second object has unique keys:
|
|
11
11
|
${JSON.stringify(l,null,4)}.`:"";return`When matching strictly, we found that both objects have different amount of keys.${a}${y}`}for(let n of c){if(!O(e,n))return!r.useWildcards||r.useWildcards&&!n.includes("*")?r.verboseWhenMismatches?`The given object has key "${n}" which the other-one does not have.`:!1:Object.keys(e).some(a=>m(a,n,{caseSensitive:!0}))?!0:r.verboseWhenMismatches?`The given object has key "${n}" which the other-one does not have.`:!1;if(e[n]!=null&&i(e[n])!==i(t[n])){if(!(s(e[n])&&s(t[n])&&r.hungryForWhitespace))return r.verboseWhenMismatches?`The given key ${n} is of a different type on both objects. On the first-one, it's ${i(t[n])}, on the second-one, it's ${i(e[n])}`:!1}else if(d(e[n],t[n],r)!==!0)return r.verboseWhenMismatches?`The given piece ${JSON.stringify(t[n],null,4)} and ${JSON.stringify(e[n],null,4)} don't match.`:!1}}else return r.hungryForWhitespace&&s(e)&&s(t)&&(!r.matchStrictly||r.matchStrictly&&V(t))?!0:e===t;return!0}export{d as compare,D as defaults,J as version};
|
package/dist/ast-compare.umd.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-compare
|
|
3
3
|
* @fileoverview Compare anything: AST, objects, arrays, strings and nested thereof
|
|
4
|
-
* @version 4.0.
|
|
4
|
+
* @version 4.0.31
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-compare/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var astCompare=(()=>{var re=Object.create;var $=Object.defineProperty,ne=Object.defineProperties,oe=Object.getOwnPropertyDescriptor,se=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols,ae=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var J=(e,t,s)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,b=(e,t)=>{for(var s in t||(t={}))F.call(t,s)&&J(e,s,t[s]);if(B)for(var s of B(t))le.call(t,s)&&J(e,s,t[s]);return e},A=(e,t)=>ne(e,se(t));var I=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ue=(e,t)=>{for(var s in t)$(e,s,{get:t[s],enumerable:!0})},K=(e,t,s,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ie(t))!F.call(e,u)&&u!==s&&$(e,u,{get:()=>t[u],enumerable:!(c=oe(t,u))||c.enumerable});return e};var D=(e,t,s)=>(s=e!=null?re(ae(e)):{},K(t||!e||!e.__esModule?$(s,"default",{value:e,enumerable:!0}):s,e)),ce=e=>K($({},"__esModule",{value:!0}),e);var R=I((x,V)=>{(function(e,t){typeof x=="object"&&typeof V<"u"?V.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.typeDetect=t())})(x,function(){"use strict";var e=typeof Promise=="function",t=function(y){if(typeof globalThis=="object")return globalThis;Object.defineProperty(y,"typeDetectGlobalObject",{get:function(){return this},configurable:!0});var j=typeDetectGlobalObject;return delete y.typeDetectGlobalObject,j}(Object.prototype),s=typeof Symbol<"u",c=typeof Map<"u",u=typeof Set<"u",p=typeof WeakMap<"u",a=typeof WeakSet<"u",n=typeof DataView<"u",r=s&&typeof Symbol.iterator<"u",o=s&&typeof Symbol.toStringTag<"u",l=u&&typeof Set.prototype.entries=="function",i=c&&typeof Map.prototype.entries=="function",f=l&&Object.getPrototypeOf(new Set().entries()),d=i&&Object.getPrototypeOf(new Map().entries()),g=r&&typeof Array.prototype[Symbol.iterator]=="function",S=g&&Object.getPrototypeOf([][Symbol.iterator]()),L=r&&typeof String.prototype[Symbol.iterator]=="function",X=L&&Object.getPrototypeOf(""[Symbol.iterator]()),Y=8,ee=-1;function te(y){var j=typeof y;if(j!=="object")return j;if(y===null)return"null";if(y===t)return"global";if(Array.isArray(y)&&(o===!1||!(Symbol.toStringTag in y)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&y===window.location)return"Location";if(typeof window.document=="object"&&y===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&y===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&y===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&y instanceof window.HTMLElement){if(y.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(y.tagName==="TD")return"HTMLTableDataCellElement";if(y.tagName==="TH")return"HTMLTableHeaderCellElement"}}var E=o&&y[Symbol.toStringTag];if(typeof E=="string")return E;var h=Object.getPrototypeOf(y);return h===RegExp.prototype?"RegExp":h===Date.prototype?"Date":e&&h===Promise.prototype?"Promise":u&&h===Set.prototype?"Set":c&&h===Map.prototype?"Map":a&&h===WeakSet.prototype?"WeakSet":p&&h===WeakMap.prototype?"WeakMap":n&&h===DataView.prototype?"DataView":c&&h===d?"Map Iterator":u&&h===f?"Set Iterator":g&&h===S?"Array Iterator":L&&h===X?"String Iterator":h===null?"Object":Object.prototype.toString.call(y).slice(Y,ee)}return te})});var k=I((we,H)=>{"use strict";H.exports=fe;function w(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function fe(e){if(e=e||{},e.circles)return pe(e);let t=new Map;if(t.set(Date,a=>new Date(a)),t.set(Map,(a,n)=>new Map(c(Array.from(a),n))),t.set(Set,(a,n)=>new Set(c(Array.from(a),n))),e.constructorHandlers)for(let a of e.constructorHandlers)t.set(a[0],a[1]);let s=null;return e.proto?p:u;function c(a,n){let r=Object.keys(a),o=new Array(r.length);for(let l=0;l<r.length;l++){let i=r[l],f=a[i];typeof f!="object"||f===null?o[i]=f:f.constructor!==Object&&(s=t.get(f.constructor))?o[i]=s(f,n):ArrayBuffer.isView(f)?o[i]=w(f):o[i]=n(f)}return o}function u(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return c(a,u);if(a.constructor!==Object&&(s=t.get(a.constructor)))return s(a,u);let n={};for(let r in a){if(Object.hasOwnProperty.call(a,r)===!1)continue;let o=a[r];typeof o!="object"||o===null?n[r]=o:o.constructor!==Object&&(s=t.get(o.constructor))?n[r]=s(o,u):ArrayBuffer.isView(o)?n[r]=w(o):n[r]=u(o)}return n}function p(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return c(a,p);if(a.constructor!==Object&&(s=t.get(a.constructor)))return s(a,p);let n={};for(let r in a){let o=a[r];typeof o!="object"||o===null?n[r]=o:o.constructor!==Object&&(s=t.get(o.constructor))?n[r]=s(o,p):ArrayBuffer.isView(o)?n[r]=w(o):n[r]=p(o)}return n}}function pe(e){let t=[],s=[],c=new Map;if(c.set(Date,r=>new Date(r)),c.set(Map,(r,o)=>new Map(p(Array.from(r),o))),c.set(Set,(r,o)=>new Set(p(Array.from(r),o))),e.constructorHandlers)for(let r of e.constructorHandlers)c.set(r[0],r[1]);let u=null;return e.proto?n:a;function p(r,o){let l=Object.keys(r),i=new Array(l.length);for(let f=0;f<l.length;f++){let d=l[f],g=r[d];if(typeof g!="object"||g===null)i[d]=g;else if(g.constructor!==Object&&(u=c.get(g.constructor)))i[d]=u(g,o);else if(ArrayBuffer.isView(g))i[d]=w(g);else{let S=t.indexOf(g);S!==-1?i[d]=s[S]:i[d]=o(g)}}return i}function a(r){if(typeof r!="object"||r===null)return r;if(Array.isArray(r))return p(r,a);if(r.constructor!==Object&&(u=c.get(r.constructor)))return u(r,a);let o={};t.push(r),s.push(o);for(let l in r){if(Object.hasOwnProperty.call(r,l)===!1)continue;let i=r[l];if(typeof i!="object"||i===null)o[l]=i;else if(i.constructor!==Object&&(u=c.get(i.constructor)))o[l]=u(i,a);else if(ArrayBuffer.isView(i))o[l]=w(i);else{let f=t.indexOf(i);f!==-1?o[l]=s[f]:o[l]=a(i)}}return t.pop(),s.pop(),o}function n(r){if(typeof r!="object"||r===null)return r;if(Array.isArray(r))return p(r,n);if(r.constructor!==Object&&(u=c.get(r.constructor)))return u(r,n);let o={};t.push(r),s.push(o);for(let l in r){let i=r[l];if(typeof i!="object"||i===null)o[l]=i;else if(i.constructor!==Object&&(u=c.get(i.constructor)))o[l]=u(i,n);else if(ArrayBuffer.isView(i))o[l]=w(i);else{let f=t.indexOf(i);f!==-1?o[l]=s[f]:o[l]=n(i)}}return t.pop(),s.pop(),o}}});var Oe={};ue(Oe,{compare:()=>P,defaults:()=>_,version:()=>me});var v=D(R(),1);var U=D(k(),1);var Q=D(k(),1);var $e=(0,Q.default)();function O(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 ye(e){return typeof e=="string"}function q(e,t){return O(e)&&ye(t)&&t in e}function M(e){if(e.includes(".")){let t=e.lastIndexOf(".");if(!e.slice(0,t).includes("."))return e.slice(0,t);for(let s=t-1;s--;)if(e[s]===".")return e.slice(s+1,t)}return null}var T=(0,U.default)();function z(e,t){let s={now:!1};function c(u,p,a,n){let r=T(u),o,l=b({depth:-1,path:""},a);if(l.depth+=1,Array.isArray(r))for(let i=0,f=r.length;i<f&&!n.now;i++){let d=l.path?`${l.path}.${i}`:`${i}`;r[i]!==void 0?(l.parent=T(r),l.parentType="array",l.parentKey=M(d),o=c(p(r[i],void 0,A(b({},l),{path:d}),n),p,A(b({},l),{path:d}),n),Number.isNaN(o)&&i<r.length?(r.splice(i,1),i-=1):r[i]=o):r.splice(i,1)}else if(O(r))for(let i in r){if(n.now&&i!=null)break;let f=l.path?`${l.path}.${i}`:i;l.depth===0&&i!=null&&(l.topmostKey=i),l.parent=T(r),l.parentType="object",l.parentKey=M(f),o=c(p(i,r[i],A(b({},l),{path:f}),n),p,A(b({},l),{path:f}),n),Number.isNaN(o)?delete r[i]:r[i]=o}return r}return c(e,t,{},s)}function m(e){if(typeof e=="string")return!e.trim();if(!["object","string"].includes(typeof e)||!e)return!1;let t=!0;return e=z(e,(s,c,u,p)=>{let a=c!==void 0?c:s;return typeof a=="string"&&a.trim()&&(t=!1,p.now=!0),a}),t}function W(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var N=new Map,G=(e,t)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter(s=>{if(typeof s!="string"){if(typeof s>"u")return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof s}' in the array`)}return!0})},ge=(e,t)=>{t=b({caseSensitive:!1},t);let s=e+JSON.stringify(t);if(N.has(s))return N.get(s);let c=e[0]==="!";c&&(e=e.slice(1)),e=W(e).replace(/\\\*/g,"[\\s\\S]*");let u=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return u.negated=c,N.set(s,u),u},he=(e,t,s,c)=>{if(e=G(e,"inputs"),t=G(t,"patterns"),t.length===0)return[];t=t.map(a=>ge(a,s));let{allPatterns:u}=s||{},p=[];for(let a of e){let n,r=[...t].fill(!1);for(let[o,l]of t.entries())if(l.test(a)&&(r[o]=!0,n=!l.negated,!n))break;if(!(n===!1||n===void 0&&t.some(o=>!o.negated)||u&&r.some((o,l)=>!o&&!t[l].negated))&&(p.push(a),c))break}return p};function C(e,t,s){return he(e,t,s,!0).length>0}var Z="4.0.30";var me=Z;function be(e){return O(e)?!Object.keys(e).length:Array.isArray(e)||typeof e=="string"?!e.length:!1}var _={hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1};function P(e,t,s){let c,u,p,a=0,n=b(b({},_),s);if(n.hungryForWhitespace&&n.matchStrictly&&O(e)&&m(e)&&O(t)&&!Object.keys(t).length)return!0;if((!n.hungryForWhitespace||n.hungryForWhitespace&&!m(e)&&m(t))&&O(e)&&Object.keys(e).length!==0&&O(t)&&Object.keys(t).length===0||(0,v.default)(e)!==(0,v.default)(t)&&(!n.hungryForWhitespace||n.hungryForWhitespace&&!m(e)))return!1;if(typeof e=="string"&&typeof t=="string")return n.hungryForWhitespace&&m(e)&&m(t)?!0:n.verboseWhenMismatches?e===t?!0:`Given string ${t} is not matched! We have ${e} on the other end.`:n.useWildcards?C(e,t,{caseSensitive:!0}):e===t;if(Array.isArray(e)&&Array.isArray(t)){if(n.hungryForWhitespace&&m(t)&&(!n.matchStrictly||n.matchStrictly&&e.length===t.length))return!0;if(!n.hungryForWhitespace&&t.length>e.length||n.matchStrictly&&t.length!==e.length)return n.verboseWhenMismatches?`The length of a given array, ${JSON.stringify(t,null,4)} is ${t.length} but the length of an array on the other end, ${JSON.stringify(e,null,4)} is ${e.length}`:!1;if(t.length===0)return e.length===0?!0:n.verboseWhenMismatches?`The given array has no elements, but the array on the other end, ${JSON.stringify(e,null,4)} does have some`:!1;for(let r=0,o=t.length;r<o;r++){p=!1;for(let l=a,i=e.length;l<i;l++)if(a+=1,P(e[l],t[r],n)===!0){p=!0;break}if(!p)return n.verboseWhenMismatches?`The given array ${JSON.stringify(t,null,4)} is not a subset of an array on the other end, ${JSON.stringify(e,null,4)}`:!1}}else if(O(e)&&O(t)){if(c=new Set(Object.keys(t)),u=new Set(Object.keys(e)),n.matchStrictly&&c.size!==u.size){if(!n.verboseWhenMismatches)return!1;let r=new Set([...c].filter(f=>!u.has(f))),o=r.size?` First object has unique keys: ${JSON.stringify(r,null,4)}.`:"",l=new Set([...u].filter(f=>!c.has(f))),i=l.size?` Second object has unique keys:
|
|
10
|
+
"use strict";var astCompare=(()=>{var re=Object.create;var $=Object.defineProperty,ne=Object.defineProperties,oe=Object.getOwnPropertyDescriptor,se=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertyNames,B=Object.getOwnPropertySymbols,ae=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var J=(e,t,s)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,b=(e,t)=>{for(var s in t||(t={}))F.call(t,s)&&J(e,s,t[s]);if(B)for(var s of B(t))le.call(t,s)&&J(e,s,t[s]);return e},A=(e,t)=>ne(e,se(t));var I=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ue=(e,t)=>{for(var s in t)$(e,s,{get:t[s],enumerable:!0})},K=(e,t,s,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ie(t))!F.call(e,u)&&u!==s&&$(e,u,{get:()=>t[u],enumerable:!(c=oe(t,u))||c.enumerable});return e};var D=(e,t,s)=>(s=e!=null?re(ae(e)):{},K(t||!e||!e.__esModule?$(s,"default",{value:e,enumerable:!0}):s,e)),ce=e=>K($({},"__esModule",{value:!0}),e);var R=I((x,V)=>{(function(e,t){typeof x=="object"&&typeof V<"u"?V.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.typeDetect=t())})(x,function(){"use strict";var e=typeof Promise=="function",t=function(y){if(typeof globalThis=="object")return globalThis;Object.defineProperty(y,"typeDetectGlobalObject",{get:function(){return this},configurable:!0});var j=typeDetectGlobalObject;return delete y.typeDetectGlobalObject,j}(Object.prototype),s=typeof Symbol<"u",c=typeof Map<"u",u=typeof Set<"u",p=typeof WeakMap<"u",a=typeof WeakSet<"u",n=typeof DataView<"u",r=s&&typeof Symbol.iterator<"u",o=s&&typeof Symbol.toStringTag<"u",l=u&&typeof Set.prototype.entries=="function",i=c&&typeof Map.prototype.entries=="function",f=l&&Object.getPrototypeOf(new Set().entries()),d=i&&Object.getPrototypeOf(new Map().entries()),g=r&&typeof Array.prototype[Symbol.iterator]=="function",S=g&&Object.getPrototypeOf([][Symbol.iterator]()),L=r&&typeof String.prototype[Symbol.iterator]=="function",X=L&&Object.getPrototypeOf(""[Symbol.iterator]()),Y=8,ee=-1;function te(y){var j=typeof y;if(j!=="object")return j;if(y===null)return"null";if(y===t)return"global";if(Array.isArray(y)&&(o===!1||!(Symbol.toStringTag in y)))return"Array";if(typeof window=="object"&&window!==null){if(typeof window.location=="object"&&y===window.location)return"Location";if(typeof window.document=="object"&&y===window.document)return"Document";if(typeof window.navigator=="object"){if(typeof window.navigator.mimeTypes=="object"&&y===window.navigator.mimeTypes)return"MimeTypeArray";if(typeof window.navigator.plugins=="object"&&y===window.navigator.plugins)return"PluginArray"}if((typeof window.HTMLElement=="function"||typeof window.HTMLElement=="object")&&y instanceof window.HTMLElement){if(y.tagName==="BLOCKQUOTE")return"HTMLQuoteElement";if(y.tagName==="TD")return"HTMLTableDataCellElement";if(y.tagName==="TH")return"HTMLTableHeaderCellElement"}}var E=o&&y[Symbol.toStringTag];if(typeof E=="string")return E;var h=Object.getPrototypeOf(y);return h===RegExp.prototype?"RegExp":h===Date.prototype?"Date":e&&h===Promise.prototype?"Promise":u&&h===Set.prototype?"Set":c&&h===Map.prototype?"Map":a&&h===WeakSet.prototype?"WeakSet":p&&h===WeakMap.prototype?"WeakMap":n&&h===DataView.prototype?"DataView":c&&h===d?"Map Iterator":u&&h===f?"Set Iterator":g&&h===S?"Array Iterator":L&&h===X?"String Iterator":h===null?"Object":Object.prototype.toString.call(y).slice(Y,ee)}return te})});var k=I((we,H)=>{"use strict";H.exports=fe;function w(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function fe(e){if(e=e||{},e.circles)return pe(e);let t=new Map;if(t.set(Date,a=>new Date(a)),t.set(Map,(a,n)=>new Map(c(Array.from(a),n))),t.set(Set,(a,n)=>new Set(c(Array.from(a),n))),e.constructorHandlers)for(let a of e.constructorHandlers)t.set(a[0],a[1]);let s=null;return e.proto?p:u;function c(a,n){let r=Object.keys(a),o=new Array(r.length);for(let l=0;l<r.length;l++){let i=r[l],f=a[i];typeof f!="object"||f===null?o[i]=f:f.constructor!==Object&&(s=t.get(f.constructor))?o[i]=s(f,n):ArrayBuffer.isView(f)?o[i]=w(f):o[i]=n(f)}return o}function u(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return c(a,u);if(a.constructor!==Object&&(s=t.get(a.constructor)))return s(a,u);let n={};for(let r in a){if(Object.hasOwnProperty.call(a,r)===!1)continue;let o=a[r];typeof o!="object"||o===null?n[r]=o:o.constructor!==Object&&(s=t.get(o.constructor))?n[r]=s(o,u):ArrayBuffer.isView(o)?n[r]=w(o):n[r]=u(o)}return n}function p(a){if(typeof a!="object"||a===null)return a;if(Array.isArray(a))return c(a,p);if(a.constructor!==Object&&(s=t.get(a.constructor)))return s(a,p);let n={};for(let r in a){let o=a[r];typeof o!="object"||o===null?n[r]=o:o.constructor!==Object&&(s=t.get(o.constructor))?n[r]=s(o,p):ArrayBuffer.isView(o)?n[r]=w(o):n[r]=p(o)}return n}}function pe(e){let t=[],s=[],c=new Map;if(c.set(Date,r=>new Date(r)),c.set(Map,(r,o)=>new Map(p(Array.from(r),o))),c.set(Set,(r,o)=>new Set(p(Array.from(r),o))),e.constructorHandlers)for(let r of e.constructorHandlers)c.set(r[0],r[1]);let u=null;return e.proto?n:a;function p(r,o){let l=Object.keys(r),i=new Array(l.length);for(let f=0;f<l.length;f++){let d=l[f],g=r[d];if(typeof g!="object"||g===null)i[d]=g;else if(g.constructor!==Object&&(u=c.get(g.constructor)))i[d]=u(g,o);else if(ArrayBuffer.isView(g))i[d]=w(g);else{let S=t.indexOf(g);S!==-1?i[d]=s[S]:i[d]=o(g)}}return i}function a(r){if(typeof r!="object"||r===null)return r;if(Array.isArray(r))return p(r,a);if(r.constructor!==Object&&(u=c.get(r.constructor)))return u(r,a);let o={};t.push(r),s.push(o);for(let l in r){if(Object.hasOwnProperty.call(r,l)===!1)continue;let i=r[l];if(typeof i!="object"||i===null)o[l]=i;else if(i.constructor!==Object&&(u=c.get(i.constructor)))o[l]=u(i,a);else if(ArrayBuffer.isView(i))o[l]=w(i);else{let f=t.indexOf(i);f!==-1?o[l]=s[f]:o[l]=a(i)}}return t.pop(),s.pop(),o}function n(r){if(typeof r!="object"||r===null)return r;if(Array.isArray(r))return p(r,n);if(r.constructor!==Object&&(u=c.get(r.constructor)))return u(r,n);let o={};t.push(r),s.push(o);for(let l in r){let i=r[l];if(typeof i!="object"||i===null)o[l]=i;else if(i.constructor!==Object&&(u=c.get(i.constructor)))o[l]=u(i,n);else if(ArrayBuffer.isView(i))o[l]=w(i);else{let f=t.indexOf(i);f!==-1?o[l]=s[f]:o[l]=n(i)}}return t.pop(),s.pop(),o}}});var Oe={};ue(Oe,{compare:()=>P,defaults:()=>_,version:()=>me});var v=D(R(),1);var U=D(k(),1);var Q=D(k(),1);var $e=(0,Q.default)();function O(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 ye(e){return typeof e=="string"}function q(e,t){return O(e)&&ye(t)&&t in e}function M(e){if(e.includes(".")){let t=e.lastIndexOf(".");if(!e.slice(0,t).includes("."))return e.slice(0,t);for(let s=t-1;s--;)if(e[s]===".")return e.slice(s+1,t)}return null}var T=(0,U.default)();function z(e,t){let s={now:!1};function c(u,p,a,n){let r=T(u),o,l=b({depth:-1,path:""},a);if(l.depth+=1,Array.isArray(r))for(let i=0,f=r.length;i<f&&!n.now;i++){let d=l.path?`${l.path}.${i}`:`${i}`;r[i]!==void 0?(l.parent=T(r),l.parentType="array",l.parentKey=M(d),o=c(p(r[i],void 0,A(b({},l),{path:d}),n),p,A(b({},l),{path:d}),n),Number.isNaN(o)&&i<r.length?(r.splice(i,1),i-=1):r[i]=o):r.splice(i,1)}else if(O(r))for(let i in r){if(n.now&&i!=null)break;let f=l.path?`${l.path}.${i}`:i;l.depth===0&&i!=null&&(l.topmostKey=i),l.parent=T(r),l.parentType="object",l.parentKey=M(f),o=c(p(i,r[i],A(b({},l),{path:f}),n),p,A(b({},l),{path:f}),n),Number.isNaN(o)?delete r[i]:r[i]=o}return r}return c(e,t,{},s)}function m(e){if(typeof e=="string")return!e.trim();if(!["object","string"].includes(typeof e)||!e)return!1;let t=!0;return e=z(e,(s,c,u,p)=>{let a=c!==void 0?c:s;return typeof a=="string"&&a.trim()&&(t=!1,p.now=!0),a}),t}function W(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var N=new Map,G=(e,t)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter(s=>{if(typeof s!="string"){if(typeof s>"u")return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof s}' in the array`)}return!0})},ge=(e,t)=>{t=b({caseSensitive:!1},t);let s=e+JSON.stringify(t);if(N.has(s))return N.get(s);let c=e[0]==="!";c&&(e=e.slice(1)),e=W(e).replace(/\\\*/g,"[\\s\\S]*");let u=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return u.negated=c,N.set(s,u),u},he=(e,t,s,c)=>{if(e=G(e,"inputs"),t=G(t,"patterns"),t.length===0)return[];t=t.map(a=>ge(a,s));let{allPatterns:u}=s||{},p=[];for(let a of e){let n,r=[...t].fill(!1);for(let[o,l]of t.entries())if(l.test(a)&&(r[o]=!0,n=!l.negated,!n))break;if(!(n===!1||n===void 0&&t.some(o=>!o.negated)||u&&r.some((o,l)=>!o&&!t[l].negated))&&(p.push(a),c))break}return p};function C(e,t,s){return he(e,t,s,!0).length>0}var Z="4.0.31";var me=Z;function be(e){return O(e)?!Object.keys(e).length:Array.isArray(e)||typeof e=="string"?!e.length:!1}var _={hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1};function P(e,t,s){let c,u,p,a=0,n=b(b({},_),s);if(n.hungryForWhitespace&&n.matchStrictly&&O(e)&&m(e)&&O(t)&&!Object.keys(t).length)return!0;if((!n.hungryForWhitespace||n.hungryForWhitespace&&!m(e)&&m(t))&&O(e)&&Object.keys(e).length!==0&&O(t)&&Object.keys(t).length===0||(0,v.default)(e)!==(0,v.default)(t)&&(!n.hungryForWhitespace||n.hungryForWhitespace&&!m(e)))return!1;if(typeof e=="string"&&typeof t=="string")return n.hungryForWhitespace&&m(e)&&m(t)?!0:n.verboseWhenMismatches?e===t?!0:`Given string ${t} is not matched! We have ${e} on the other end.`:n.useWildcards?C(e,t,{caseSensitive:!0}):e===t;if(Array.isArray(e)&&Array.isArray(t)){if(n.hungryForWhitespace&&m(t)&&(!n.matchStrictly||n.matchStrictly&&e.length===t.length))return!0;if(!n.hungryForWhitespace&&t.length>e.length||n.matchStrictly&&t.length!==e.length)return n.verboseWhenMismatches?`The length of a given array, ${JSON.stringify(t,null,4)} is ${t.length} but the length of an array on the other end, ${JSON.stringify(e,null,4)} is ${e.length}`:!1;if(t.length===0)return e.length===0?!0:n.verboseWhenMismatches?`The given array has no elements, but the array on the other end, ${JSON.stringify(e,null,4)} does have some`:!1;for(let r=0,o=t.length;r<o;r++){p=!1;for(let l=a,i=e.length;l<i;l++)if(a+=1,P(e[l],t[r],n)===!0){p=!0;break}if(!p)return n.verboseWhenMismatches?`The given array ${JSON.stringify(t,null,4)} is not a subset of an array on the other end, ${JSON.stringify(e,null,4)}`:!1}}else if(O(e)&&O(t)){if(c=new Set(Object.keys(t)),u=new Set(Object.keys(e)),n.matchStrictly&&c.size!==u.size){if(!n.verboseWhenMismatches)return!1;let r=new Set([...c].filter(f=>!u.has(f))),o=r.size?` First object has unique keys: ${JSON.stringify(r,null,4)}.`:"",l=new Set([...u].filter(f=>!c.has(f))),i=l.size?` Second object has unique keys:
|
|
11
11
|
${JSON.stringify(l,null,4)}.`:"";return`When matching strictly, we found that both objects have different amount of keys.${o}${i}`}for(let r of c){if(!q(e,r))return!n.useWildcards||n.useWildcards&&!r.includes("*")?n.verboseWhenMismatches?`The given object has key "${r}" which the other-one does not have.`:!1:Object.keys(e).some(o=>C(o,r,{caseSensitive:!0}))?!0:n.verboseWhenMismatches?`The given object has key "${r}" which the other-one does not have.`:!1;if(e[r]!=null&&(0,v.default)(e[r])!==(0,v.default)(t[r])){if(!(m(e[r])&&m(t[r])&&n.hungryForWhitespace))return n.verboseWhenMismatches?`The given key ${r} is of a different type on both objects. On the first-one, it's ${(0,v.default)(t[r])}, on the second-one, it's ${(0,v.default)(e[r])}`:!1}else if(P(e[r],t[r],n)!==!0)return n.verboseWhenMismatches?`The given piece ${JSON.stringify(t[r],null,4)} and ${JSON.stringify(e[r],null,4)} don't match.`:!1}}else return n.hungryForWhitespace&&m(e)&&m(t)&&(!n.matchStrictly||n.matchStrictly&&be(t))?!0:e===t;return!0}return ce(Oe);})();
|
|
12
12
|
/**
|
|
13
13
|
* @name codsen-utils
|
|
14
14
|
* @fileoverview Various utility functions
|
|
15
|
-
* @version 1.6.
|
|
15
|
+
* @version 1.6.8
|
|
16
16
|
* @author Roy Revelt, Codsen Ltd
|
|
17
17
|
* @license MIT
|
|
18
18
|
* {@link https://codsen.com/os/codsen-utils/}
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
/**
|
|
29
29
|
* @name ast-monkey-traverse
|
|
30
30
|
* @fileoverview Utility library to traverse AST
|
|
31
|
-
* @version 4.0.
|
|
31
|
+
* @version 4.0.20
|
|
32
32
|
* @author Roy Revelt, Codsen Ltd
|
|
33
33
|
* @license MIT
|
|
34
34
|
* {@link https://codsen.com/os/ast-monkey-traverse/}
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
/**
|
|
37
37
|
* @name ast-contains-only-empty-space
|
|
38
38
|
* @fileoverview Does AST contain only empty space?
|
|
39
|
-
* @version 4.0.
|
|
39
|
+
* @version 4.0.20
|
|
40
40
|
* @author Roy Revelt, Codsen Ltd
|
|
41
41
|
* @license MIT
|
|
42
42
|
* {@link https://codsen.com/os/ast-contains-only-empty-space/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ast-compare",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.31",
|
|
4
4
|
"description": "Compare anything: AST, objects, arrays, strings and nested thereof",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -77,13 +77,13 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"ast-contains-only-empty-space": "^4.0.
|
|
81
|
-
"codsen-utils": "^1.6.
|
|
80
|
+
"ast-contains-only-empty-space": "^4.0.20",
|
|
81
|
+
"codsen-utils": "^1.6.8",
|
|
82
82
|
"matcher": "^5.0.0",
|
|
83
83
|
"type-detect": "^4.1.0"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@types/type-detect": "^4.0.3",
|
|
87
|
-
"type-fest": "^4.
|
|
87
|
+
"type-fest": "^4.41.0"
|
|
88
88
|
}
|
|
89
89
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -23,13 +23,5 @@ declare function compare(
|
|
|
23
23
|
opts?: Partial<Opts>,
|
|
24
24
|
): boolean | string;
|
|
25
25
|
|
|
26
|
-
export {
|
|
27
|
-
|
|
28
|
-
type JsonArray,
|
|
29
|
-
type JsonObject,
|
|
30
|
-
type JsonValue,
|
|
31
|
-
type Opts,
|
|
32
|
-
compare,
|
|
33
|
-
defaults,
|
|
34
|
-
version,
|
|
35
|
-
};
|
|
26
|
+
export { compare, defaults, version };
|
|
27
|
+
export type { AnyObject, JsonArray, JsonObject, JsonValue, Opts };
|