ast-compare 3.0.2 → 3.0.6

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,12 +3,6 @@
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
- ## 3.0.1 (2021-09-13)
7
-
8
- ### Bug Fixes
9
-
10
- - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
11
-
12
6
  ## 3.0.0 (2021-09-09)
13
7
 
14
8
  ### Features
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-%YEAR% Roy Revelt and other contributors
3
+ Copyright (c) 2010-2021 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
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name ast-compare
3
3
  * @fileoverview Compare anything: AST, objects, arrays, strings and nested thereof
4
- * @version 3.0.2
4
+ * @version 3.0.6
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-compare/}
@@ -10,137 +10,162 @@
10
10
  import typeDetect from 'type-detect';
11
11
  import { empty } from 'ast-contains-only-empty-space';
12
12
  import isObj from 'lodash.isplainobject';
13
- import matcher from 'matcher';
13
+ import { isMatch } from 'matcher';
14
14
 
15
15
  /* istanbul ignore next */
16
16
  function isBlank(something) {
17
- if (isObj(something)) {
18
- return !Object.keys(something).length;
19
- }
20
- if (Array.isArray(something) || typeof something === "string") {
21
- return !something.length;
22
- }
23
- return false;
24
- }
25
- function compare(b, s, originalOpts) {
26
- let sKeys;
27
- let bKeys;
28
- let found;
29
- let bOffset = 0;
30
- const defaults = {
31
- hungryForWhitespace: false,
32
- matchStrictly: false,
33
- verboseWhenMismatches: false,
34
- useWildcards: false
35
- };
36
- const opts = { ...defaults,
37
- ...originalOpts
38
- };
39
- if (opts.hungryForWhitespace && opts.matchStrictly && isObj(b) && empty(b) && isObj(s) && !Object.keys(s).length) {
40
- return true;
41
- }
42
- if ((!opts.hungryForWhitespace || opts.hungryForWhitespace && !empty(b) && empty(s)) && isObj(b) && Object.keys(b).length !== 0 && isObj(s) && Object.keys(s).length === 0 || typeDetect(b) !== typeDetect(s) && (!opts.hungryForWhitespace || opts.hungryForWhitespace && !empty(b))) {
43
- return false;
44
- }
45
- if (typeof b === "string" && typeof s === "string") {
46
- if (opts.hungryForWhitespace && empty(b) && empty(s)) {
47
- return true;
17
+ if (isObj(something)) {
18
+ return !Object.keys(something).length;
48
19
  }
49
- if (opts.verboseWhenMismatches) {
50
- return b === s ? true : `Given string ${s} is not matched! We have ${b} on the other end.`;
20
+ if (Array.isArray(something) || typeof something === "string") {
21
+ return !something.length;
51
22
  }
52
- return opts.useWildcards ? matcher.isMatch(b, s, {
53
- caseSensitive: true
54
- }) : b === s;
55
- }
56
- if (Array.isArray(b) && Array.isArray(s)) {
57
- if (opts.hungryForWhitespace && empty(s) && (!opts.matchStrictly || opts.matchStrictly && b.length === s.length)) {
58
- return true;
23
+ return false;
24
+ }
25
+ function compare(b, s, originalOpts) {
26
+ let sKeys;
27
+ let bKeys;
28
+ let found;
29
+ let bOffset = 0;
30
+ const defaults = {
31
+ hungryForWhitespace: false,
32
+ matchStrictly: false,
33
+ verboseWhenMismatches: false,
34
+ useWildcards: false,
35
+ };
36
+ const opts = { ...defaults, ...originalOpts };
37
+ if (opts.hungryForWhitespace &&
38
+ opts.matchStrictly &&
39
+ isObj(b) &&
40
+ empty(b) &&
41
+ isObj(s) &&
42
+ !Object.keys(s).length) {
43
+ return true;
59
44
  }
60
- if (!opts.hungryForWhitespace && s.length > b.length || opts.matchStrictly && s.length !== b.length) {
61
- if (!opts.verboseWhenMismatches) {
45
+ if (((!opts.hungryForWhitespace ||
46
+ (opts.hungryForWhitespace && !empty(b) && empty(s))) &&
47
+ isObj(b) &&
48
+ Object.keys(b).length !== 0 &&
49
+ isObj(s) &&
50
+ Object.keys(s).length === 0) ||
51
+ (typeDetect(b) !== typeDetect(s) &&
52
+ (!opts.hungryForWhitespace || (opts.hungryForWhitespace && !empty(b))))) {
62
53
  return false;
63
- }
64
- return `The length of a given array, ${JSON.stringify(s, null, 4)} is ${s.length} but the length of an array on the other end, ${JSON.stringify(b, null, 4)} is ${b.length}`;
65
- }
66
- if (s.length === 0) {
67
- if (b.length === 0) {
68
- return true;
69
- }
70
- if (opts.verboseWhenMismatches) {
71
- return `The given array has no elements, but the array on the other end, ${JSON.stringify(b, null, 4)} does have some`;
72
- }
73
- return false;
74
54
  }
75
- for (let i = 0, sLen = s.length; i < sLen; i++) {
76
- found = false;
77
- for (let j = bOffset, bLen = b.length; j < bLen; j++) {
78
- bOffset += 1;
79
- if (compare(b[j], s[i], opts) === true) {
80
- found = true;
81
- break;
55
+ if (typeof b === "string" && typeof s === "string") {
56
+ if (opts.hungryForWhitespace && empty(b) && empty(s)) {
57
+ return true;
82
58
  }
83
- }
84
- if (!found) {
85
- if (!opts.verboseWhenMismatches) {
86
- return false;
59
+ if (opts.verboseWhenMismatches) {
60
+ return b === s
61
+ ? true
62
+ : `Given string ${s} is not matched! We have ${b} on the other end.`;
87
63
  }
88
- return `The given array ${JSON.stringify(s, null, 4)} is not a subset of an array on the other end, ${JSON.stringify(b, null, 4)}`;
89
- }
64
+ return opts.useWildcards ? isMatch(b, s, { caseSensitive: true }) : b === s;
90
65
  }
91
- } else if (isObj(b) && isObj(s)) {
92
- sKeys = new Set(Object.keys(s));
93
- bKeys = new Set(Object.keys(b));
94
- if (opts.matchStrictly && sKeys.size !== bKeys.size) {
95
- if (!opts.verboseWhenMismatches) {
96
- return false;
97
- }
98
- const uniqueKeysOnS = new Set([...sKeys].filter(x => !bKeys.has(x)));
99
- const sMessage = uniqueKeysOnS.size ? ` First object has unique keys: ${JSON.stringify(uniqueKeysOnS, null, 4)}.` : "";
100
- const uniqueKeysOnB = new Set([...bKeys].filter(x => !sKeys.has(x)));
101
- const bMessage = uniqueKeysOnB.size ? ` Second object has unique keys:
102
- ${JSON.stringify(uniqueKeysOnB, null, 4)}.` : "";
103
- return `When matching strictly, we found that both objects have different amount of keys.${sMessage}${bMessage}`;
104
- }
105
- for (const sKey of sKeys) {
106
- if (!Object.prototype.hasOwnProperty.call(b, sKey)) {
107
- if (!opts.useWildcards || opts.useWildcards && !sKey.includes("*")) {
108
- if (!opts.verboseWhenMismatches) {
109
- return false;
110
- }
111
- return `The given object has key "${sKey}" which the other-one does not have.`;
66
+ if (Array.isArray(b) && Array.isArray(s)) {
67
+ if (opts.hungryForWhitespace &&
68
+ empty(s) &&
69
+ (!opts.matchStrictly || (opts.matchStrictly && b.length === s.length))) {
70
+ return true;
112
71
  }
113
- if (Object.keys(b).some(bKey => matcher.isMatch(bKey, sKey, {
114
- caseSensitive: true
115
- }))) {
116
- return true;
72
+ if ((!opts.hungryForWhitespace && s.length > b.length) ||
73
+ (opts.matchStrictly && s.length !== b.length)) {
74
+ if (!opts.verboseWhenMismatches) {
75
+ return false;
76
+ }
77
+ return `The length of a given array, ${JSON.stringify(s, null, 4)} is ${s.length} but the length of an array on the other end, ${JSON.stringify(b, null, 4)} is ${b.length}`;
117
78
  }
118
- if (!opts.verboseWhenMismatches) {
119
- return false;
120
- }
121
- return `The given object has key "${sKey}" which the other-one does not have.`;
122
- }
123
- if (b[sKey] != null && typeDetect(b[sKey]) !== typeDetect(s[sKey])) {
124
- if (!(empty(b[sKey]) && empty(s[sKey]) && opts.hungryForWhitespace)) {
125
- if (!opts.verboseWhenMismatches) {
79
+ if (s.length === 0) {
80
+ if (b.length === 0) {
81
+ return true;
82
+ }
83
+ if (opts.verboseWhenMismatches) {
84
+ return `The given array has no elements, but the array on the other end, ${JSON.stringify(b, null, 4)} does have some`;
85
+ }
126
86
  return false;
127
- }
128
- return `The given key ${sKey} is of a different type on both objects. On the first-one, it's ${typeDetect(s[sKey])}, on the second-one, it's ${typeDetect(b[sKey])}`;
129
87
  }
130
- } else if (compare(b[sKey], s[sKey], opts) !== true) {
131
- if (!opts.verboseWhenMismatches) {
132
- return false;
88
+ for (let i = 0, sLen = s.length; i < sLen; i++) {
89
+ found = false;
90
+ for (let j = bOffset, bLen = b.length; j < bLen; j++) {
91
+ bOffset += 1;
92
+ if (compare(b[j], s[i], opts) === true) {
93
+ found = true;
94
+ break;
95
+ }
96
+ }
97
+ if (!found) {
98
+ if (!opts.verboseWhenMismatches) {
99
+ return false;
100
+ }
101
+ return `The given array ${JSON.stringify(s, null, 4)} is not a subset of an array on the other end, ${JSON.stringify(b, null, 4)}`;
102
+ }
133
103
  }
134
- return `The given piece ${JSON.stringify(s[sKey], null, 4)} and ${JSON.stringify(b[sKey], null, 4)} don't match.`;
135
- }
136
104
  }
137
- } else {
138
- if (opts.hungryForWhitespace && empty(b) && empty(s) && (!opts.matchStrictly || opts.matchStrictly && isBlank(s))) {
139
- return true;
105
+ else if (isObj(b) && isObj(s)) {
106
+ sKeys = new Set(Object.keys(s));
107
+ bKeys = new Set(Object.keys(b));
108
+ if (opts.matchStrictly && sKeys.size !== bKeys.size) {
109
+ if (!opts.verboseWhenMismatches) {
110
+ return false;
111
+ }
112
+ const uniqueKeysOnS = new Set([...sKeys].filter((x) => !bKeys.has(x)));
113
+ const sMessage = uniqueKeysOnS.size
114
+ ? ` First object has unique keys: ${JSON.stringify(uniqueKeysOnS, null, 4)}.`
115
+ : "";
116
+ const uniqueKeysOnB = new Set([...bKeys].filter((x) => !sKeys.has(x)));
117
+ const bMessage = uniqueKeysOnB.size
118
+ ? ` Second object has unique keys:
119
+ ${JSON.stringify(uniqueKeysOnB, null, 4)}.`
120
+ : "";
121
+ return `When matching strictly, we found that both objects have different amount of keys.${sMessage}${bMessage}`;
122
+ }
123
+ for (const sKey of sKeys) {
124
+ if (!Object.prototype.hasOwnProperty.call(b, sKey)) {
125
+ if (!opts.useWildcards || (opts.useWildcards && !sKey.includes("*"))) {
126
+ if (!opts.verboseWhenMismatches) {
127
+ return false;
128
+ }
129
+ return `The given object has key "${sKey}" which the other-one does not have.`;
130
+ }
131
+ if (Object.keys(b).some((bKey) => isMatch(bKey, sKey, { caseSensitive: true }))) {
132
+ return true;
133
+ }
134
+ if (!opts.verboseWhenMismatches) {
135
+ return false;
136
+ }
137
+ return `The given object has key "${sKey}" which the other-one does not have.`;
138
+ }
139
+ if (b[sKey] != null &&
140
+ typeDetect(b[sKey]) !==
141
+ typeDetect(s[sKey])) {
142
+ if (!(empty(b[sKey]) &&
143
+ empty(s[sKey]) &&
144
+ opts.hungryForWhitespace)) {
145
+ if (!opts.verboseWhenMismatches) {
146
+ return false;
147
+ }
148
+ return `The given key ${sKey} is of a different type on both objects. On the first-one, it's ${typeDetect(s[sKey])}, on the second-one, it's ${typeDetect(b[sKey])}`;
149
+ }
150
+ }
151
+ else if (compare(b[sKey], s[sKey], opts) !== true) {
152
+ if (!opts.verboseWhenMismatches) {
153
+ return false;
154
+ }
155
+ return `The given piece ${JSON.stringify(s[sKey], null, 4)} and ${JSON.stringify(b[sKey], null, 4)} don't match.`;
156
+ }
157
+ }
158
+ }
159
+ else {
160
+ if (opts.hungryForWhitespace &&
161
+ empty(b) &&
162
+ empty(s) &&
163
+ (!opts.matchStrictly || (opts.matchStrictly && isBlank(s)))) {
164
+ return true;
165
+ }
166
+ return b === s;
140
167
  }
141
- return b === s;
142
- }
143
- return true;
168
+ return true;
144
169
  }
145
170
 
146
171
  export { compare };
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * @name ast-compare
3
3
  * @fileoverview Compare anything: AST, objects, arrays, strings and nested thereof
4
- * @version 3.0.2
4
+ * @version 3.0.6
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
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).astCompare={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(t,r){t.exports=function(){var t="function"==typeof Promise,r="object"==typeof self?self:e,n="undefined"!=typeof Symbol,o="undefined"!=typeof Map,i="undefined"!=typeof Set,a="undefined"!=typeof WeakMap,c="undefined"!=typeof WeakSet,u="undefined"!=typeof DataView,s=n&&void 0!==Symbol.iterator,f=n&&void 0!==Symbol.toStringTag,l=i&&"function"==typeof Set.prototype.entries,p=o&&"function"==typeof Map.prototype.entries,y=l&&Object.getPrototypeOf((new Set).entries()),h=p&&Object.getPrototypeOf((new Map).entries()),d=s&&"function"==typeof Array.prototype[Symbol.iterator],g=d&&Object.getPrototypeOf([][Symbol.iterator]()),b=s&&"function"==typeof String.prototype[Symbol.iterator],v=b&&Object.getPrototypeOf(""[Symbol.iterator]()),_=8,j=-1;function w(e){var n=typeof e;if("object"!==n)return n;if(null===e)return"null";if(e===r)return"global";if(Array.isArray(e)&&(!1===f||!(Symbol.toStringTag in e)))return"Array";if("object"==typeof window&&null!==window){if("object"==typeof window.location&&e===window.location)return"Location";if("object"==typeof window.document&&e===window.document)return"Document";if("object"==typeof window.navigator){if("object"==typeof window.navigator.mimeTypes&&e===window.navigator.mimeTypes)return"MimeTypeArray";if("object"==typeof window.navigator.plugins&&e===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"==typeof window.HTMLElement)&&e instanceof window.HTMLElement){if("BLOCKQUOTE"===e.tagName)return"HTMLQuoteElement";if("TD"===e.tagName)return"HTMLTableDataCellElement";if("TH"===e.tagName)return"HTMLTableHeaderCellElement"}}var s=f&&e[Symbol.toStringTag];if("string"==typeof s)return s;var l=Object.getPrototypeOf(e);return l===RegExp.prototype?"RegExp":l===Date.prototype?"Date":t&&l===Promise.prototype?"Promise":i&&l===Set.prototype?"Set":o&&l===Map.prototype?"Map":c&&l===WeakSet.prototype?"WeakSet":a&&l===WeakMap.prototype?"WeakMap":u&&l===DataView.prototype?"DataView":o&&l===h?"Map Iterator":i&&l===y?"Set Iterator":d&&l===g?"Array Iterator":b&&l===v?"String Iterator":null===l?"Object":Object.prototype.toString.call(e).slice(_,j)}return w}()}(r);var n=r.exports,o={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",a="[object Boolean]",c="[object Date]",u="[object Function]",s="[object GeneratorFunction]",f="[object Map]",l="[object Number]",p="[object Object]",y="[object Promise]",h="[object RegExp]",d="[object Set]",g="[object String]",b="[object Symbol]",v="[object WeakMap]",_="[object ArrayBuffer]",j="[object DataView]",w="[object Float32Array]",m="[object Float64Array]",O="[object Int8Array]",S="[object Int16Array]",$="[object Int32Array]",A="[object Uint8Array]",T="[object Uint8ClampedArray]",M="[object Uint16Array]",W="[object Uint32Array]",x=/\w*$/,k=/^\[object .+?Constructor\]$/,E=/^(?:0|[1-9]\d*)$/,N={};N[i]=N["[object Array]"]=N[_]=N[j]=N[a]=N[c]=N[w]=N[m]=N[O]=N[S]=N[$]=N[f]=N[l]=N[p]=N[h]=N[d]=N[g]=N[b]=N[A]=N[T]=N[M]=N[W]=!0,N["[object Error]"]=N[u]=N[v]=!1;var P="object"==typeof self&&self&&self.Object===Object&&self,F="object"==typeof e&&e&&e.Object===Object&&e||P||Function("return this")(),I=r&&!r.nodeType&&r,D=I&&t&&!t.nodeType&&t,J=D&&D.exports===I;function L(t,e){return t.set(e[0],e[1]),t}function H(t,e){return t.add(e),t}function z(t,e,r,n){var o=-1,i=t?t.length:0;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}function B(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function C(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function R(t,e){return function(r){return t(e(r))}}function U(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var V,K=Array.prototype,q=Function.prototype,G=Object.prototype,Q=F["__core-js_shared__"],X=(V=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Y=q.toString,Z=G.hasOwnProperty,tt=G.toString,et=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=J?F.Buffer:void 0,nt=F.Symbol,ot=F.Uint8Array,it=R(Object.getPrototypeOf,Object),at=Object.create,ct=G.propertyIsEnumerable,ut=K.splice,st=Object.getOwnPropertySymbols,ft=rt?rt.isBuffer:void 0,lt=R(Object.keys,Object),pt=Dt(F,"DataView"),yt=Dt(F,"Map"),ht=Dt(F,"Promise"),dt=Dt(F,"Set"),gt=Dt(F,"WeakMap"),bt=Dt(Object,"create"),vt=Bt(pt),_t=Bt(yt),jt=Bt(ht),wt=Bt(dt),mt=Bt(gt),Ot=nt?nt.prototype:void 0,St=Ot?Ot.valueOf:void 0;function $t(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function At(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Tt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Mt(t){this.__data__=new At(t)}function Wt(t,e){var r=Rt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ut(t)}(t)&&Z.call(t,"callee")&&(!ct.call(t,"callee")||tt.call(t)==i)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var a in t)!e&&!Z.call(t,a)||o&&("length"==a||Ht(a,n))||r.push(a);return r}function xt(t,e,r){var n=t[e];Z.call(t,e)&&Ct(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function kt(t,e){for(var r=t.length;r--;)if(Ct(t[r][0],e))return r;return-1}function Et(t,e,r,n,o,y,v){var k;if(n&&(k=y?n(t,o,y,v):n(t)),void 0!==k)return k;if(!qt(t))return t;var E=Rt(t);if(E){if(k=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Z.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!e)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(t,k)}else{var P=Lt(t),F=P==u||P==s;if(Vt(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if(P==p||P==i||F&&!y){if(B(t))return y?t:{};if(k=function(t){return"function"!=typeof t.constructor||zt(t)?{}:(e=it(t),qt(e)?at(e):{});var e}(F?{}:t),!e)return function(t,e){return Ft(t,Jt(t),e)}(t,function(t,e){return t&&Ft(e,Gt(e),t)}(k,t))}else{if(!N[P])return y?t:{};k=function(t,e,r,n){var o=t.constructor;switch(e){case _:return Pt(t);case a:case c:return new o(+t);case j:return function(t,e){var r=e?Pt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case w:case m:case O:case S:case $:case A:case T:case M:case W:return function(t,e){var r=e?Pt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case f:return function(t,e,r){return z(e?r(C(t),!0):C(t),L,new t.constructor)}(t,n,r);case l:case g:return new o(t);case h:return function(t){var e=new t.constructor(t.source,x.exec(t));return e.lastIndex=t.lastIndex,e}(t);case d:return function(t,e,r){return z(e?r(U(t),!0):U(t),H,new t.constructor)}(t,n,r);case b:return i=t,St?Object(St.call(i)):{}}var i}(t,P,Et,e)}}v||(v=new Mt);var I=v.get(t);if(I)return I;if(v.set(t,k),!E)var D=r?function(t){return function(t,e,r){var n=e(t);return Rt(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,Gt,Jt)}(t):Gt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(D||t,(function(o,i){D&&(o=t[i=o]),xt(k,i,Et(o,e,r,n,i,t,v))})),k}function Nt(t){return!(!qt(t)||(e=t,X&&X in e))&&(Kt(t)||B(t)?et:k).test(Bt(t));var e}function Pt(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Ft(t,e,r,n){r||(r={});for(var o=-1,i=e.length;++o<i;){var a=e[o],c=n?n(r[a],t[a],a,r,t):void 0;xt(r,a,void 0===c?t[a]:c)}return r}function It(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Dt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Nt(r)?r:void 0}$t.prototype.clear=function(){this.__data__=bt?bt(null):{}},$t.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},$t.prototype.get=function(t){var e=this.__data__;if(bt){var r=e[t];return r===n?void 0:r}return Z.call(e,t)?e[t]:void 0},$t.prototype.has=function(t){var e=this.__data__;return bt?void 0!==e[t]:Z.call(e,t)},$t.prototype.set=function(t,e){return this.__data__[t]=bt&&void 0===e?n:e,this},At.prototype.clear=function(){this.__data__=[]},At.prototype.delete=function(t){var e=this.__data__,r=kt(e,t);return!(r<0)&&(r==e.length-1?e.pop():ut.call(e,r,1),!0)},At.prototype.get=function(t){var e=this.__data__,r=kt(e,t);return r<0?void 0:e[r][1]},At.prototype.has=function(t){return kt(this.__data__,t)>-1},At.prototype.set=function(t,e){var r=this.__data__,n=kt(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},Tt.prototype.clear=function(){this.__data__={hash:new $t,map:new(yt||At),string:new $t}},Tt.prototype.delete=function(t){return It(this,t).delete(t)},Tt.prototype.get=function(t){return It(this,t).get(t)},Tt.prototype.has=function(t){return It(this,t).has(t)},Tt.prototype.set=function(t,e){return It(this,t).set(t,e),this},Mt.prototype.clear=function(){this.__data__=new At},Mt.prototype.delete=function(t){return this.__data__.delete(t)},Mt.prototype.get=function(t){return this.__data__.get(t)},Mt.prototype.has=function(t){return this.__data__.has(t)},Mt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof At){var n=r.__data__;if(!yt||n.length<199)return n.push([t,e]),this;r=this.__data__=new Tt(n)}return r.set(t,e),this};var Jt=st?R(st,Object):function(){return[]},Lt=function(t){return tt.call(t)};function Ht(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||E.test(t))&&t>-1&&t%1==0&&t<e}function zt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||G)}function Bt(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Ct(t,e){return t===e||t!=t&&e!=e}(pt&&Lt(new pt(new ArrayBuffer(1)))!=j||yt&&Lt(new yt)!=f||ht&&Lt(ht.resolve())!=y||dt&&Lt(new dt)!=d||gt&&Lt(new gt)!=v)&&(Lt=function(t){var e=tt.call(t),r=e==p?t.constructor:void 0,n=r?Bt(r):void 0;if(n)switch(n){case vt:return j;case _t:return f;case jt:return y;case wt:return d;case mt:return v}return e});var Rt=Array.isArray;function Ut(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Kt(t)}var Vt=ft||function(){return!1};function Kt(t){var e=qt(t)?tt.call(t):"";return e==u||e==s}function qt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Gt(t){return Ut(t)?Wt(t):function(t){if(!zt(t))return lt(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Et(t,!0,!0)}}(o,o.exports);var i=o.exports;var a,c,u=Object.prototype,s=Function.prototype.toString,f=u.hasOwnProperty,l=s.call(Object),p=u.toString,y=(a=Object.getPrototypeOf,c=Object,function(t){return a(c(t))});var h=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=p.call(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=y(t);if(null===e)return!0;var r=f.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&s.call(r)==l};
10
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).astCompare={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(t,r){t.exports=function(){var t="function"==typeof Promise,r="object"==typeof self?self:e,n="undefined"!=typeof Symbol,o="undefined"!=typeof Map,i="undefined"!=typeof Set,a="undefined"!=typeof WeakMap,c="undefined"!=typeof WeakSet,u="undefined"!=typeof DataView,s=n&&void 0!==Symbol.iterator,f=n&&void 0!==Symbol.toStringTag,l=i&&"function"==typeof Set.prototype.entries,p=o&&"function"==typeof Map.prototype.entries,y=l&&Object.getPrototypeOf((new Set).entries()),h=p&&Object.getPrototypeOf((new Map).entries()),d=s&&"function"==typeof Array.prototype[Symbol.iterator],g=d&&Object.getPrototypeOf([][Symbol.iterator]()),b=s&&"function"==typeof String.prototype[Symbol.iterator],v=b&&Object.getPrototypeOf(""[Symbol.iterator]()),_=8,j=-1;function w(e){var n=typeof e;if("object"!==n)return n;if(null===e)return"null";if(e===r)return"global";if(Array.isArray(e)&&(!1===f||!(Symbol.toStringTag in e)))return"Array";if("object"==typeof window&&null!==window){if("object"==typeof window.location&&e===window.location)return"Location";if("object"==typeof window.document&&e===window.document)return"Document";if("object"==typeof window.navigator){if("object"==typeof window.navigator.mimeTypes&&e===window.navigator.mimeTypes)return"MimeTypeArray";if("object"==typeof window.navigator.plugins&&e===window.navigator.plugins)return"PluginArray"}if(("function"==typeof window.HTMLElement||"object"==typeof window.HTMLElement)&&e instanceof window.HTMLElement){if("BLOCKQUOTE"===e.tagName)return"HTMLQuoteElement";if("TD"===e.tagName)return"HTMLTableDataCellElement";if("TH"===e.tagName)return"HTMLTableHeaderCellElement"}}var s=f&&e[Symbol.toStringTag];if("string"==typeof s)return s;var l=Object.getPrototypeOf(e);return l===RegExp.prototype?"RegExp":l===Date.prototype?"Date":t&&l===Promise.prototype?"Promise":i&&l===Set.prototype?"Set":o&&l===Map.prototype?"Map":c&&l===WeakSet.prototype?"WeakSet":a&&l===WeakMap.prototype?"WeakMap":u&&l===DataView.prototype?"DataView":o&&l===h?"Map Iterator":i&&l===y?"Set Iterator":d&&l===g?"Array Iterator":b&&l===v?"String Iterator":null===l?"Object":Object.prototype.toString.call(e).slice(_,j)}return w}()}(r);var n=r.exports,o={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",a="[object Boolean]",c="[object Date]",u="[object Function]",s="[object GeneratorFunction]",f="[object Map]",l="[object Number]",p="[object Object]",y="[object Promise]",h="[object RegExp]",d="[object Set]",g="[object String]",b="[object Symbol]",v="[object WeakMap]",_="[object ArrayBuffer]",j="[object DataView]",w="[object Float32Array]",m="[object Float64Array]",O="[object Int8Array]",S="[object Int16Array]",$="[object Int32Array]",A="[object Uint8Array]",T="[object Uint8ClampedArray]",W="[object Uint16Array]",M="[object Uint32Array]",k=/\w*$/,x=/^\[object .+?Constructor\]$/,E=/^(?:0|[1-9]\d*)$/,P={};P[i]=P["[object Array]"]=P[_]=P[j]=P[a]=P[c]=P[w]=P[m]=P[O]=P[S]=P[$]=P[f]=P[l]=P[p]=P[h]=P[d]=P[g]=P[b]=P[A]=P[T]=P[W]=P[M]=!0,P["[object Error]"]=P[u]=P[v]=!1;var N="object"==typeof self&&self&&self.Object===Object&&self,F="object"==typeof e&&e&&e.Object===Object&&e||N||Function("return this")(),I=r&&!r.nodeType&&r,D=I&&t&&!t.nodeType&&t,J=D&&D.exports===I;function L(t,e){return t.set(e[0],e[1]),t}function H(t,e){return t.add(e),t}function z(t,e,r,n){var o=-1,i=t?t.length:0;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}function B(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function C(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function R(t,e){return function(r){return t(e(r))}}function U(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var V,K=Array.prototype,q=Function.prototype,G=Object.prototype,Q=F["__core-js_shared__"],X=(V=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+V:"",Y=q.toString,Z=G.hasOwnProperty,tt=G.toString,et=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=J?F.Buffer:void 0,nt=F.Symbol,ot=F.Uint8Array,it=R(Object.getPrototypeOf,Object),at=Object.create,ct=G.propertyIsEnumerable,ut=K.splice,st=Object.getOwnPropertySymbols,ft=rt?rt.isBuffer:void 0,lt=R(Object.keys,Object),pt=Dt(F,"DataView"),yt=Dt(F,"Map"),ht=Dt(F,"Promise"),dt=Dt(F,"Set"),gt=Dt(F,"WeakMap"),bt=Dt(Object,"create"),vt=Bt(pt),_t=Bt(yt),jt=Bt(ht),wt=Bt(dt),mt=Bt(gt),Ot=nt?nt.prototype:void 0,St=Ot?Ot.valueOf:void 0;function $t(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function At(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Tt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Wt(t){this.__data__=new At(t)}function Mt(t,e){var r=Rt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Ut(t)}(t)&&Z.call(t,"callee")&&(!ct.call(t,"callee")||tt.call(t)==i)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var a in t)!e&&!Z.call(t,a)||o&&("length"==a||Ht(a,n))||r.push(a);return r}function kt(t,e,r){var n=t[e];Z.call(t,e)&&Ct(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function xt(t,e){for(var r=t.length;r--;)if(Ct(t[r][0],e))return r;return-1}function Et(t,e,r,n,o,y,v){var x;if(n&&(x=y?n(t,o,y,v):n(t)),void 0!==x)return x;if(!qt(t))return t;var E=Rt(t);if(E){if(x=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Z.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!e)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(t,x)}else{var N=Lt(t),F=N==u||N==s;if(Vt(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if(N==p||N==i||F&&!y){if(B(t))return y?t:{};if(x=function(t){return"function"!=typeof t.constructor||zt(t)?{}:(e=it(t),qt(e)?at(e):{});var e}(F?{}:t),!e)return function(t,e){return Ft(t,Jt(t),e)}(t,function(t,e){return t&&Ft(e,Gt(e),t)}(x,t))}else{if(!P[N])return y?t:{};x=function(t,e,r,n){var o=t.constructor;switch(e){case _:return Nt(t);case a:case c:return new o(+t);case j:return function(t,e){var r=e?Nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case w:case m:case O:case S:case $:case A:case T:case W:case M:return function(t,e){var r=e?Nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case f:return function(t,e,r){return z(e?r(C(t),!0):C(t),L,new t.constructor)}(t,n,r);case l:case g:return new o(t);case h:return function(t){var e=new t.constructor(t.source,k.exec(t));return e.lastIndex=t.lastIndex,e}(t);case d:return function(t,e,r){return z(e?r(U(t),!0):U(t),H,new t.constructor)}(t,n,r);case b:return i=t,St?Object(St.call(i)):{}}var i}(t,N,Et,e)}}v||(v=new Wt);var I=v.get(t);if(I)return I;if(v.set(t,x),!E)var D=r?function(t){return function(t,e,r){var n=e(t);return Rt(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,Gt,Jt)}(t):Gt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(D||t,(function(o,i){D&&(o=t[i=o]),kt(x,i,Et(o,e,r,n,i,t,v))})),x}function Pt(t){return!(!qt(t)||(e=t,X&&X in e))&&(Kt(t)||B(t)?et:x).test(Bt(t));var e}function Nt(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Ft(t,e,r,n){r||(r={});for(var o=-1,i=e.length;++o<i;){var a=e[o],c=n?n(r[a],t[a],a,r,t):void 0;kt(r,a,void 0===c?t[a]:c)}return r}function It(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Dt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Pt(r)?r:void 0}$t.prototype.clear=function(){this.__data__=bt?bt(null):{}},$t.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},$t.prototype.get=function(t){var e=this.__data__;if(bt){var r=e[t];return r===n?void 0:r}return Z.call(e,t)?e[t]:void 0},$t.prototype.has=function(t){var e=this.__data__;return bt?void 0!==e[t]:Z.call(e,t)},$t.prototype.set=function(t,e){return this.__data__[t]=bt&&void 0===e?n:e,this},At.prototype.clear=function(){this.__data__=[]},At.prototype.delete=function(t){var e=this.__data__,r=xt(e,t);return!(r<0)&&(r==e.length-1?e.pop():ut.call(e,r,1),!0)},At.prototype.get=function(t){var e=this.__data__,r=xt(e,t);return r<0?void 0:e[r][1]},At.prototype.has=function(t){return xt(this.__data__,t)>-1},At.prototype.set=function(t,e){var r=this.__data__,n=xt(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},Tt.prototype.clear=function(){this.__data__={hash:new $t,map:new(yt||At),string:new $t}},Tt.prototype.delete=function(t){return It(this,t).delete(t)},Tt.prototype.get=function(t){return It(this,t).get(t)},Tt.prototype.has=function(t){return It(this,t).has(t)},Tt.prototype.set=function(t,e){return It(this,t).set(t,e),this},Wt.prototype.clear=function(){this.__data__=new At},Wt.prototype.delete=function(t){return this.__data__.delete(t)},Wt.prototype.get=function(t){return this.__data__.get(t)},Wt.prototype.has=function(t){return this.__data__.has(t)},Wt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof At){var n=r.__data__;if(!yt||n.length<199)return n.push([t,e]),this;r=this.__data__=new Tt(n)}return r.set(t,e),this};var Jt=st?R(st,Object):function(){return[]},Lt=function(t){return tt.call(t)};function Ht(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||E.test(t))&&t>-1&&t%1==0&&t<e}function zt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||G)}function Bt(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Ct(t,e){return t===e||t!=t&&e!=e}(pt&&Lt(new pt(new ArrayBuffer(1)))!=j||yt&&Lt(new yt)!=f||ht&&Lt(ht.resolve())!=y||dt&&Lt(new dt)!=d||gt&&Lt(new gt)!=v)&&(Lt=function(t){var e=tt.call(t),r=e==p?t.constructor:void 0,n=r?Bt(r):void 0;if(n)switch(n){case vt:return j;case _t:return f;case jt:return y;case wt:return d;case mt:return v}return e});var Rt=Array.isArray;function Ut(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Kt(t)}var Vt=ft||function(){return!1};function Kt(t){var e=qt(t)?tt.call(t):"";return e==u||e==s}function qt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Gt(t){return Ut(t)?Mt(t):function(t){if(!zt(t))return lt(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Et(t,!0,!0)}}(o,o.exports);var i=o.exports;var a,c,u=Object.prototype,s=Function.prototype.toString,f=u.hasOwnProperty,l=s.call(Object),p=u.toString,y=(a=Object.getPrototypeOf,c=Object,function(t){return a(c(t))});var h=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=p.call(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=y(t);if(null===e)return!0;var r=f.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&s.call(r)==l};
11
11
  /**
12
12
  * @name ast-monkey-util
13
13
  * @fileoverview Utility library of AST helper functions
14
- * @version 2.0.2
14
+ * @version 2.0.6
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/ast-monkey-util/}
@@ -19,7 +19,7 @@
19
19
  /**
20
20
  * @name ast-monkey-traverse
21
21
  * @fileoverview Utility library to traverse AST
22
- * @version 3.0.2
22
+ * @version 3.0.6
23
23
  * @author Roy Revelt, Codsen Ltd
24
24
  * @license MIT
25
25
  * {@link https://codsen.com/os/ast-monkey-traverse/}
@@ -27,9 +27,9 @@
27
27
  /**
28
28
  * @name ast-contains-only-empty-space
29
29
  * @fileoverview Does AST contain only empty space?
30
- * @version 3.0.2
30
+ * @version 3.0.6
31
31
  * @author Roy Revelt, Codsen Ltd
32
32
  * @license MIT
33
33
  * {@link https://codsen.com/os/ast-contains-only-empty-space/}
34
34
  */
35
- function g(t){if("string"==typeof t)return!t.trim();if(!["object","string"].includes(typeof t)||!t)return!1;let e=!0;return t=function t(e,r,n,o){const a=i(e);let c;const u={depth:-1,path:"",...n};if(u.depth+=1,Array.isArray(a))for(let e=0,n=a.length;e<n&&!o.now;e++){const n=u.path?`${u.path}.${e}`:`${e}`;void 0!==a[e]?(u.parent=i(a),u.parentType="array",u.parentKey=d(n),c=t(r(a[e],void 0,{...u,path:n},o),r,{...u,path:n},o),Number.isNaN(c)&&e<a.length?(a.splice(e,1),e-=1):a[e]=c):a.splice(e,1)}else if(h(a))for(const e in a){if(o.now&&null!=e)break;const n=u.path?`${u.path}.${e}`:e;0===u.depth&&null!=e&&(u.topmostKey=e),u.parent=i(a),u.parentType="object",u.parentKey=d(n),c=t(r(e,a[e],{...u,path:n},o),r,{...u,path:n},o),Number.isNaN(c)?delete a[e]:a[e]=c}return a}(t,((t,r,n,o)=>{const i=void 0!==r?r:t;return"string"==typeof i&&i.trim()&&(e=!1,o.now=!0),i}),{},{now:!1}),e}var b={exports:{}};const v=t=>{if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")},_=new Map;function j(t,e){if(!Array.isArray(t))switch(typeof t){case"string":t=[t];break;case"undefined":t=[];break;default:throw new TypeError(`Expected '${e}' to be a string or an array, but got a type of '${typeof t}'`)}return t.filter((t=>{if("string"!=typeof t){if(void 0===t)return!1;throw new TypeError(`Expected '${e}' to be an array of strings, but found a type of '${typeof t}' in the array`)}return!0}))}function w(t,e){e={caseSensitive:!1,...e};const r=t+JSON.stringify(e);if(_.has(r))return _.get(r);const n="!"===t[0];n&&(t=t.slice(1)),t=v(t).replace(/\\\*/g,"[\\s\\S]*");const o=new RegExp(`^${t}$`,e.caseSensitive?"":"i");return o.negated=n,_.set(r,o),o}b.exports=(t,e,r)=>{if(t=j(t,"inputs"),0===(e=j(e,"patterns")).length)return[];const n="!"===e[0][0];e=e.map((t=>w(t,r)));const o=[];for(const r of t){let t=n;for(const n of e)n.test(r)&&(t=!n.negated);t&&o.push(r)}return o},b.exports.isMatch=(t,e,r)=>(t=j(t,"inputs"),0!==(e=j(e,"patterns")).length&&t.some((t=>e.every((e=>{const n=w(e,r),o=n.test(t);return n.negated?!o:o})))));var m=b.exports;t.compare=function t(e,r,o){let i,a,c,u=0;const s={hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1,...o};if(s.hungryForWhitespace&&s.matchStrictly&&h(e)&&g(e)&&h(r)&&!Object.keys(r).length)return!0;if((!s.hungryForWhitespace||s.hungryForWhitespace&&!g(e)&&g(r))&&h(e)&&0!==Object.keys(e).length&&h(r)&&0===Object.keys(r).length||n(e)!==n(r)&&(!s.hungryForWhitespace||s.hungryForWhitespace&&!g(e)))return!1;if("string"==typeof e&&"string"==typeof r)return!!(s.hungryForWhitespace&&g(e)&&g(r))||(s.verboseWhenMismatches?e===r||`Given string ${r} is not matched! We have ${e} on the other end.`:s.useWildcards?m.isMatch(e,r,{caseSensitive:!0}):e===r);if(Array.isArray(e)&&Array.isArray(r)){if(s.hungryForWhitespace&&g(r)&&(!s.matchStrictly||s.matchStrictly&&e.length===r.length))return!0;if(!s.hungryForWhitespace&&r.length>e.length||s.matchStrictly&&r.length!==e.length)return!!s.verboseWhenMismatches&&`The length of a given array, ${JSON.stringify(r,null,4)} is ${r.length} but the length of an array on the other end, ${JSON.stringify(e,null,4)} is ${e.length}`;if(0===r.length)return 0===e.length||!!s.verboseWhenMismatches&&`The given array has no elements, but the array on the other end, ${JSON.stringify(e,null,4)} does have some`;for(let n=0,o=r.length;n<o;n++){c=!1;for(let o=u,i=e.length;o<i;o++)if(u+=1,!0===t(e[o],r[n],s)){c=!0;break}if(!c)return!!s.verboseWhenMismatches&&`The given array ${JSON.stringify(r,null,4)} is not a subset of an array on the other end, ${JSON.stringify(e,null,4)}`}}else{if(!h(e)||!h(r))return!(!(s.hungryForWhitespace&&g(e)&&g(r))||s.matchStrictly&&(!s.matchStrictly||(f=r,h(f)?Object.keys(f).length:!Array.isArray(f)&&"string"!=typeof f||f.length)))||e===r;if(i=new Set(Object.keys(r)),a=new Set(Object.keys(e)),s.matchStrictly&&i.size!==a.size){if(!s.verboseWhenMismatches)return!1;const t=new Set([...i].filter((t=>!a.has(t)))),e=t.size?` First object has unique keys: ${JSON.stringify(t,null,4)}.`:"",r=new Set([...a].filter((t=>!i.has(t))));return`When matching strictly, we found that both objects have different amount of keys.${e}${r.size?` Second object has unique keys:\n ${JSON.stringify(r,null,4)}.`:""}`}for(const o of i){if(!Object.prototype.hasOwnProperty.call(e,o))return!s.useWildcards||s.useWildcards&&!o.includes("*")?!!s.verboseWhenMismatches&&`The given object has key "${o}" which the other-one does not have.`:!!Object.keys(e).some((t=>m.isMatch(t,o,{caseSensitive:!0})))||!!s.verboseWhenMismatches&&`The given object has key "${o}" which the other-one does not have.`;if(null!=e[o]&&n(e[o])!==n(r[o])){if(!(g(e[o])&&g(r[o])&&s.hungryForWhitespace))return!!s.verboseWhenMismatches&&`The given key ${o} is of a different type on both objects. On the first-one, it's ${n(r[o])}, on the second-one, it's ${n(e[o])}`}else if(!0!==t(e[o],r[o],s))return!!s.verboseWhenMismatches&&`The given piece ${JSON.stringify(r[o],null,4)} and ${JSON.stringify(e[o],null,4)} don't match.`}}var f;return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
35
+ function g(t){if("string"==typeof t)return!t.trim();if(!["object","string"].includes(typeof t)||!t)return!1;let e=!0;return t=function t(e,r,n,o){const a=i(e);let c;const u={depth:-1,path:"",...n};if(u.depth+=1,Array.isArray(a))for(let e=0,n=a.length;e<n&&!o.now;e++){const n=u.path?`${u.path}.${e}`:`${e}`;void 0!==a[e]?(u.parent=i(a),u.parentType="array",u.parentKey=d(n),c=t(r(a[e],void 0,{...u,path:n},o),r,{...u,path:n},o),Number.isNaN(c)&&e<a.length?(a.splice(e,1),e-=1):a[e]=c):a.splice(e,1)}else if(h(a))for(const e in a){if(o.now&&null!=e)break;const n=u.path?`${u.path}.${e}`:e;0===u.depth&&null!=e&&(u.topmostKey=e),u.parent=i(a),u.parentType="object",u.parentKey=d(n),c=t(r(e,a[e],{...u,path:n},o),r,{...u,path:n},o),Number.isNaN(c)?delete a[e]:a[e]=c}return a}(t,((t,r,n,o)=>{const i=void 0!==r?r:t;return"string"==typeof i&&i.trim()&&(e=!1,o.now=!0),i}),{},{now:!1}),e}const b=new Map,v=(t,e)=>{if(!Array.isArray(t))switch(typeof t){case"string":t=[t];break;case"undefined":t=[];break;default:throw new TypeError(`Expected '${e}' to be a string or an array, but got a type of '${typeof t}'`)}return t.filter((t=>{if("string"!=typeof t){if(void 0===t)return!1;throw new TypeError(`Expected '${e}' to be an array of strings, but found a type of '${typeof t}' in the array`)}return!0}))},_=(t,e)=>{e={caseSensitive:!1,...e};const r=t+JSON.stringify(e);if(b.has(r))return b.get(r);const n="!"===t[0];n&&(t=t.slice(1)),t=function(t){if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(t).replace(/\\\*/g,"[\\s\\S]*");const o=new RegExp(`^${t}$`,e.caseSensitive?"":"i");return o.negated=n,b.set(r,o),o};function j(t,e,r){return((t,e,r,n)=>{if(t=v(t,"inputs"),0===(e=v(e,"patterns")).length)return[];e=e.map((t=>_(t,r)));const{allPatterns:o}=r||{},i=[];for(const r of t){let t;const a=[...e].fill(!1);for(const[n,o]of e.entries())if(o.test(r)&&(a[n]=!0,t=!o.negated,!t))break;if(!(!1===t||void 0===t&&e.some((t=>!t.negated))||o&&a.some(((t,r)=>!t&&!e[r].negated)))&&(i.push(r),n))break}return i})(t,e,r,!0).length>0}t.compare=function t(e,r,o){let i,a,c,u=0;const s={hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1,...o};if(s.hungryForWhitespace&&s.matchStrictly&&h(e)&&g(e)&&h(r)&&!Object.keys(r).length)return!0;if((!s.hungryForWhitespace||s.hungryForWhitespace&&!g(e)&&g(r))&&h(e)&&0!==Object.keys(e).length&&h(r)&&0===Object.keys(r).length||n(e)!==n(r)&&(!s.hungryForWhitespace||s.hungryForWhitespace&&!g(e)))return!1;if("string"==typeof e&&"string"==typeof r)return!!(s.hungryForWhitespace&&g(e)&&g(r))||(s.verboseWhenMismatches?e===r||`Given string ${r} is not matched! We have ${e} on the other end.`:s.useWildcards?j(e,r,{caseSensitive:!0}):e===r);if(Array.isArray(e)&&Array.isArray(r)){if(s.hungryForWhitespace&&g(r)&&(!s.matchStrictly||s.matchStrictly&&e.length===r.length))return!0;if(!s.hungryForWhitespace&&r.length>e.length||s.matchStrictly&&r.length!==e.length)return!!s.verboseWhenMismatches&&`The length of a given array, ${JSON.stringify(r,null,4)} is ${r.length} but the length of an array on the other end, ${JSON.stringify(e,null,4)} is ${e.length}`;if(0===r.length)return 0===e.length||!!s.verboseWhenMismatches&&`The given array has no elements, but the array on the other end, ${JSON.stringify(e,null,4)} does have some`;for(let n=0,o=r.length;n<o;n++){c=!1;for(let o=u,i=e.length;o<i;o++)if(u+=1,!0===t(e[o],r[n],s)){c=!0;break}if(!c)return!!s.verboseWhenMismatches&&`The given array ${JSON.stringify(r,null,4)} is not a subset of an array on the other end, ${JSON.stringify(e,null,4)}`}}else{if(!h(e)||!h(r))return!(!(s.hungryForWhitespace&&g(e)&&g(r))||s.matchStrictly&&(!s.matchStrictly||(f=r,h(f)?Object.keys(f).length:!Array.isArray(f)&&"string"!=typeof f||f.length)))||e===r;if(i=new Set(Object.keys(r)),a=new Set(Object.keys(e)),s.matchStrictly&&i.size!==a.size){if(!s.verboseWhenMismatches)return!1;const t=new Set([...i].filter((t=>!a.has(t)))),e=t.size?` First object has unique keys: ${JSON.stringify(t,null,4)}.`:"",r=new Set([...a].filter((t=>!i.has(t))));return`When matching strictly, we found that both objects have different amount of keys.${e}${r.size?` Second object has unique keys:\n ${JSON.stringify(r,null,4)}.`:""}`}for(const o of i){if(!Object.prototype.hasOwnProperty.call(e,o))return!s.useWildcards||s.useWildcards&&!o.includes("*")?!!s.verboseWhenMismatches&&`The given object has key "${o}" which the other-one does not have.`:!!Object.keys(e).some((t=>j(t,o,{caseSensitive:!0})))||!!s.verboseWhenMismatches&&`The given object has key "${o}" which the other-one does not have.`;if(null!=e[o]&&n(e[o])!==n(r[o])){if(!(g(e[o])&&g(r[o])&&s.hungryForWhitespace))return!!s.verboseWhenMismatches&&`The given key ${o} is of a different type on both objects. On the first-one, it's ${n(r[o])}, on the second-one, it's ${n(e[o])}`}else if(!0!==t(e[o],r[o],s))return!!s.verboseWhenMismatches&&`The given piece ${JSON.stringify(r[o],null,4)} and ${JSON.stringify(e[o],null,4)} don't match.`}}var f;return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ast-compare",
3
- "version": "3.0.2",
3
+ "version": "3.0.6",
4
4
  "description": "Compare anything: AST, objects, arrays, strings and nested thereof",
5
5
  "keywords": [
6
6
  "array",
@@ -41,9 +41,10 @@
41
41
  "types": "types/index.d.ts",
42
42
  "scripts": {
43
43
  "build": "rollup -c",
44
- "esbuild": "node '../../scripts/esbuild.js'",
45
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
46
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
44
+ "build:esbuild": "node '../../scripts/esbuild.js'",
45
+ "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
46
+ "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
47
+ "clean_types": "../../scripts/cleanTypes.js",
47
48
  "dev": "rollup -c --dev",
48
49
  "devunittest": "npm run dev && tap --only -R 'base'",
49
50
  "format": "npm run lect && npm run prettier && npm run lint",
@@ -53,20 +54,15 @@
53
54
  "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
54
55
  "republish": "npm publish || :",
55
56
  "tap": "tap",
56
- "tsc": "tsc",
57
57
  "pretest": "npm run build",
58
- "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
58
+ "test": "npm run test:ci && npm run perf",
59
+ "test:ci": "npm run unittest && npm run test:examples && npm run format",
59
60
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
60
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
61
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
62
- "clean_types": "../../scripts/cleanTypes.js"
61
+ "tsc": "tsc",
62
+ "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
63
63
  },
64
64
  "tap": {
65
65
  "check-coverage": false,
66
- "coverage-report": [
67
- "json-summary",
68
- "text"
69
- ],
70
66
  "node-arg": [
71
67
  "--no-warnings",
72
68
  "--experimental-loader",
@@ -90,53 +86,53 @@
90
86
  }
91
87
  },
92
88
  "dependencies": {
93
- "@babel/runtime": "^7.15.4",
94
- "ast-contains-only-empty-space": "^3.0.2",
89
+ "@babel/runtime": "^7.16.3",
90
+ "ast-contains-only-empty-space": "^3.0.6",
95
91
  "lodash.isplainobject": "^4.0.6",
96
- "matcher": "^4.0.0",
92
+ "matcher": "^5.0.0",
97
93
  "type-detect": "^4.0.8"
98
94
  },
99
95
  "devDependencies": {
100
- "@babel/cli": "^7.15.4",
101
- "@babel/core": "^7.15.5",
102
- "@babel/node": "^7.15.4",
103
- "@babel/plugin-external-helpers": "^7.14.5",
104
- "@babel/plugin-proposal-class-properties": "^7.14.5",
105
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
106
- "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
107
- "@babel/plugin-proposal-optional-chaining": "^7.14.5",
108
- "@babel/plugin-transform-runtime": "^7.15.0",
109
- "@babel/preset-env": "^7.15.6",
110
- "@babel/preset-typescript": "^7.15.0",
111
- "@babel/register": "^7.15.3",
96
+ "@babel/cli": "^7.16.0",
97
+ "@babel/core": "^7.16.0",
98
+ "@babel/node": "^7.16.0",
99
+ "@babel/plugin-external-helpers": "^7.16.0",
100
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
101
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
102
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
103
+ "@babel/plugin-proposal-optional-chaining": "^7.16.0",
104
+ "@babel/plugin-transform-runtime": "^7.16.4",
105
+ "@babel/preset-env": "^7.16.4",
106
+ "@babel/preset-typescript": "^7.16.0",
107
+ "@babel/register": "^7.16.0",
112
108
  "@istanbuljs/esm-loader-hook": "^0.1.2",
113
109
  "@rollup/plugin-babel": "^5.3.0",
114
- "@rollup/plugin-commonjs": "^20.0.0",
115
- "@rollup/plugin-node-resolve": "^13.0.4",
110
+ "@rollup/plugin-commonjs": "^21.0.1",
111
+ "@rollup/plugin-node-resolve": "^13.0.6",
116
112
  "@rollup/plugin-strip": "^2.1.0",
117
- "@rollup/plugin-typescript": "^8.2.5",
113
+ "@rollup/plugin-typescript": "^8.3.0",
118
114
  "@types/lodash.isplainobject": "^4.0.6",
119
- "@types/node": "^16.9.1",
115
+ "@types/node": "^16.11.9",
120
116
  "@types/tap": "^15.0.5",
121
117
  "@types/type-detect": "^4.0.1",
122
- "@typescript-eslint/eslint-plugin": "^4.31.0",
123
- "@typescript-eslint/parser": "^4.31.0",
124
- "core-js": "^3.17.3",
118
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
119
+ "@typescript-eslint/parser": "^5.4.0",
120
+ "core-js": "^3.19.1",
125
121
  "cross-env": "^7.0.3",
126
- "eslint": "^7.32.0",
127
- "lect": "^0.18.2",
128
- "rollup": "^2.56.3",
122
+ "eslint": "^8.3.0",
123
+ "lect": "^0.18.6",
124
+ "rollup": "^2.60.0",
129
125
  "rollup-plugin-ascii": "^0.0.3",
130
126
  "rollup-plugin-banner": "^0.2.1",
131
127
  "rollup-plugin-cleanup": "^3.2.1",
132
- "rollup-plugin-dts": "^4.0.0",
128
+ "rollup-plugin-dts": "^4.0.1",
133
129
  "rollup-plugin-terser": "^7.0.2",
134
- "tap": "^15.0.9",
130
+ "tap": "^15.1.2",
135
131
  "tslib": "^2.3.1",
136
- "type-fest": "^2.3.2",
137
- "typescript": "^4.4.3"
132
+ "type-fest": "^2.5.4",
133
+ "typescript": "^4.5.2"
138
134
  },
139
135
  "engines": {
140
- "node": ">=12"
136
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
141
137
  }
142
138
  }