ast-compare 3.0.6 → 3.0.12
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/LICENSE +1 -1
- package/README.md +4 -5
- package/dist/ast-compare.esm.js +3 -163
- package/dist/ast-compare.umd.js +13 -13
- package/examples/_quickTake.js +1 -0
- package/examples/compare-arrays.js +1 -0
- package/examples/compare-objects.js +1 -0
- package/examples/compare-strings.js +1 -0
- package/examples/opts-hungryForWhitespace.js +1 -0
- package/examples/opts-verboseWhenMismatches.js +1 -0
- package/package.json +26 -77
- package/types/index.d.ts +18 -8
- package/examples/api.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -26,18 +26,17 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `2.1.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i ast-compare
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 2.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
38
|
import { strict as assert } from "assert";
|
|
39
|
+
|
|
41
40
|
import { compare } from "ast-compare";
|
|
42
41
|
|
|
43
42
|
// Find out, does an object/array/string/nested-mix is a subset or equal to another input:
|
|
@@ -64,7 +63,7 @@ assert.equal(
|
|
|
64
63
|
|
|
65
64
|
## Documentation
|
|
66
65
|
|
|
67
|
-
Please [visit codsen.com](https://codsen.com/os/ast-compare/) for a full description of the API
|
|
66
|
+
Please [visit codsen.com](https://codsen.com/os/ast-compare/) for a full description of the API.
|
|
68
67
|
|
|
69
68
|
## Contributing
|
|
70
69
|
|
|
@@ -74,6 +73,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
74
73
|
|
|
75
74
|
MIT License
|
|
76
75
|
|
|
77
|
-
Copyright (c) 2010-
|
|
76
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
78
77
|
|
|
79
78
|
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
package/dist/ast-compare.esm.js
CHANGED
|
@@ -1,171 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-compare
|
|
3
3
|
* @fileoverview Compare anything: AST, objects, arrays, strings and nested thereof
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.12
|
|
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
|
|
11
|
-
|
|
12
|
-
import isObj from 'lodash.isplainobject';
|
|
13
|
-
import { isMatch } from 'matcher';
|
|
14
|
-
|
|
15
|
-
/* istanbul ignore next */
|
|
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, ...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;
|
|
44
|
-
}
|
|
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))))) {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
if (typeof b === "string" && typeof s === "string") {
|
|
56
|
-
if (opts.hungryForWhitespace && empty(b) && empty(s)) {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
if (opts.verboseWhenMismatches) {
|
|
60
|
-
return b === s
|
|
61
|
-
? true
|
|
62
|
-
: `Given string ${s} is not matched! We have ${b} on the other end.`;
|
|
63
|
-
}
|
|
64
|
-
return opts.useWildcards ? isMatch(b, s, { caseSensitive: true }) : b === s;
|
|
65
|
-
}
|
|
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;
|
|
71
|
-
}
|
|
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}`;
|
|
78
|
-
}
|
|
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
|
-
}
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
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
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
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;
|
|
167
|
-
}
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export { compare };
|
|
10
|
+
import a from"type-detect";import{empty as o}from"ast-contains-only-empty-space";import s from"lodash.isplainobject";import{isMatch as $}from"matcher";function O(e){return s(e)?!Object.keys(e).length:Array.isArray(e)||typeof e=="string"?!e.length:!1}function m(e,t,b){let i,u,h,f=0,n={...{hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1},...b};if(n.hungryForWhitespace&&n.matchStrictly&&s(e)&&o(e)&&s(t)&&!Object.keys(t).length)return!0;if((!n.hungryForWhitespace||n.hungryForWhitespace&&!o(e)&&o(t))&&s(e)&&Object.keys(e).length!==0&&s(t)&&Object.keys(t).length===0||a(e)!==a(t)&&(!n.hungryForWhitespace||n.hungryForWhitespace&&!o(e)))return!1;if(typeof e=="string"&&typeof t=="string")return n.hungryForWhitespace&&o(e)&&o(t)?!0:n.verboseWhenMismatches?e===t?!0:`Given string ${t} is not matched! We have ${e} on the other end.`:n.useWildcards?$(e,t,{caseSensitive:!0}):e===t;if(Array.isArray(e)&&Array.isArray(t)){if(n.hungryForWhitespace&&o(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,c=t.length;r<c;r++){h=!1;for(let l=f,y=e.length;l<y;l++)if(f+=1,m(e[l],t[r],n)===!0){h=!0;break}if(!h)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(s(e)&&s(t)){if(i=new Set(Object.keys(t)),u=new Set(Object.keys(e)),n.matchStrictly&&i.size!==u.size){if(!n.verboseWhenMismatches)return!1;let r=new Set([...i].filter(g=>!u.has(g))),c=r.size?` First object has unique keys: ${JSON.stringify(r,null,4)}.`:"",l=new Set([...u].filter(g=>!i.has(g))),y=l.size?` Second object has unique keys:
|
|
11
|
+
${JSON.stringify(l,null,4)}.`:"";return`When matching strictly, we found that both objects have different amount of keys.${c}${y}`}for(let r of i){if(!Object.prototype.hasOwnProperty.call(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(c=>$(c,r,{caseSensitive:!0}))?!0:n.verboseWhenMismatches?`The given object has key "${r}" which the other-one does not have.`:!1;if(e[r]!=null&&a(e[r])!==a(t[r])){if(!(o(e[r])&&o(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 ${a(t[r])}, on the second-one, it's ${a(e[r])}`:!1}else if(m(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&&o(e)&&o(t)&&(!n.matchStrictly||n.matchStrictly&&O(t))?!0:e===t;return!0}export{m as compare};
|
package/dist/ast-compare.umd.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-compare
|
|
3
3
|
* @fileoverview Compare anything: AST, objects, arrays, strings and nested thereof
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.12
|
|
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]",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};
|
|
10
|
+
var astCompare=(()=>{var Et=Object.create;var M=Object.defineProperty,$t=Object.defineProperties,jt=Object.getOwnPropertyDescriptor,At=Object.getOwnPropertyDescriptors,Tt=Object.getOwnPropertyNames,Oe=Object.getOwnPropertySymbols,xt=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable;var Se=(e,t,r)=>t in e?M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,m=(e,t)=>{for(var r in t||(t={}))ve.call(t,r)&&Se(e,r,t[r]);if(Oe)for(var r of Oe(t))Dt.call(t,r)&&Se(e,r,t[r]);return e},C=(e,t)=>$t(e,At(t)),we=e=>M(e,"__esModule",{value:!0});var U=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vt=(e,t)=>{for(var r in t)M(e,r,{get:t[r],enumerable:!0})},_e=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Tt(t))!ve.call(e,i)&&(r||i!=="default")&&M(e,i,{get:()=>t[i],enumerable:!(n=jt(t,i))||n.enumerable});return e},N=(e,t)=>_e(we(M(e!=null?Et(xt(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),Mt=(e=>(t,r)=>e&&e.get(t)||(r=_e(we({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var Ee=U((q,z)=>{(function(e,t){typeof q=="object"&&typeof z!="undefined"?z.exports=t():typeof define=="function"&&define.amd?define(t):e.typeDetect=t()})(q,function(){"use strict";var e=typeof Promise=="function",t=typeof self=="object"?self:global,r=typeof Symbol!="undefined",n=typeof Map!="undefined",i=typeof Set!="undefined",u=typeof WeakMap!="undefined",f=typeof WeakSet!="undefined",l=typeof DataView!="undefined",o=r&&typeof Symbol.iterator!="undefined",a=r&&typeof Symbol.toStringTag!="undefined",s=i&&typeof Set.prototype.entries=="function",c=n&&typeof Map.prototype.entries=="function",g=s&&Object.getPrototypeOf(new Set().entries()),h=c&&Object.getPrototypeOf(new Map().entries()),_=o&&typeof Array.prototype[Symbol.iterator]=="function",Ot=_&&Object.getPrototypeOf([][Symbol.iterator]()),de=o&&typeof String.prototype[Symbol.iterator]=="function",vt=de&&Object.getPrototypeOf(""[Symbol.iterator]()),St=8,wt=-1;function _t(y){var be=typeof y;if(be!=="object")return be;if(y===null)return"null";if(y===t)return"global";if(Array.isArray(y)&&(a===!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 me=a&&y[Symbol.toStringTag];if(typeof me=="string")return me;var d=Object.getPrototypeOf(y);return d===RegExp.prototype?"RegExp":d===Date.prototype?"Date":e&&d===Promise.prototype?"Promise":i&&d===Set.prototype?"Set":n&&d===Map.prototype?"Map":f&&d===WeakSet.prototype?"WeakSet":u&&d===WeakMap.prototype?"WeakMap":l&&d===DataView.prototype?"DataView":n&&d===h?"Map Iterator":i&&d===g?"Set Iterator":_&&d===Ot?"Array Iterator":de&&d===vt?"String Iterator":d===null?"Object":Object.prototype.toString.call(y).slice(St,wt)}return _t})});var pt=U((I,V)=>{var Ct=200,$e="__lodash_hash_undefined__",je=9007199254740991,Q="[object Arguments]",Pt="[object Array]",Ae="[object Boolean]",Te="[object Date]",Wt="[object Error]",X="[object Function]",xe="[object GeneratorFunction]",k="[object Map]",De="[object Number]",Y="[object Object]",Ve="[object Promise]",Me="[object RegExp]",L="[object Set]",Ce="[object String]",Pe="[object Symbol]",Z="[object WeakMap]",We="[object ArrayBuffer]",J="[object DataView]",Ie="[object Float32Array]",Ne="[object Float64Array]",ke="[object Int8Array]",Le="[object Int16Array]",Je="[object Int32Array]",Ke="[object Uint8Array]",Fe="[object Uint8ClampedArray]",He="[object Uint16Array]",Re="[object Uint32Array]",It=/[\\^$.*+?()[\]{}|]/g,Nt=/\w*$/,kt=/^\[object .+?Constructor\]$/,Lt=/^(?:0|[1-9]\d*)$/,p={};p[Q]=p[Pt]=p[We]=p[J]=p[Ae]=p[Te]=p[Ie]=p[Ne]=p[ke]=p[Le]=p[Je]=p[k]=p[De]=p[Y]=p[Me]=p[L]=p[Ce]=p[Pe]=p[Ke]=p[Fe]=p[He]=p[Re]=!0;p[Wt]=p[X]=p[Z]=!1;var Jt=typeof global=="object"&&global&&global.Object===Object&&global,Kt=typeof self=="object"&&self&&self.Object===Object&&self,O=Jt||Kt||Function("return this")(),Be=typeof I=="object"&&I&&!I.nodeType&&I,Ge=Be&&typeof V=="object"&&V&&!V.nodeType&&V,Ft=Ge&&Ge.exports===Be;function Ht(e,t){return e.set(t[0],t[1]),e}function Rt(e,t){return e.add(t),e}function Bt(e,t){for(var r=-1,n=e?e.length:0;++r<n&&t(e[r],r,e)!==!1;);return e}function Gt(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function Ue(e,t,r,n){var i=-1,u=e?e.length:0;for(n&&u&&(r=e[++i]);++i<u;)r=t(r,e[i],i,e);return r}function Ut(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function qt(e,t){return e==null?void 0:e[t]}function qe(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function ze(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n]}),r}function ee(e,t){return function(r){return e(t(r))}}function Qe(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n}),r}var zt=Array.prototype,Qt=Function.prototype,K=Object.prototype,te=O["__core-js_shared__"],Xe=function(){var e=/[^.]+$/.exec(te&&te.keys&&te.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ye=Qt.toString,S=K.hasOwnProperty,F=K.toString,Xt=RegExp("^"+Ye.call(S).replace(It,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ze=Ft?O.Buffer:void 0,et=O.Symbol,tt=O.Uint8Array,Yt=ee(Object.getPrototypeOf,Object),Zt=Object.create,er=K.propertyIsEnumerable,tr=zt.splice,rt=Object.getOwnPropertySymbols,rr=Ze?Ze.isBuffer:void 0,nr=ee(Object.keys,Object),re=D(O,"DataView"),P=D(O,"Map"),ne=D(O,"Promise"),oe=D(O,"Set"),ae=D(O,"WeakMap"),W=D(Object,"create"),or=j(re),ar=j(P),ir=j(ne),sr=j(oe),cr=j(ae),nt=et?et.prototype:void 0,ot=nt?nt.valueOf:void 0;function E(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function ur(){this.__data__=W?W(null):{}}function lr(e){return this.has(e)&&delete this.__data__[e]}function fr(e){var t=this.__data__;if(W){var r=t[e];return r===$e?void 0:r}return S.call(t,e)?t[e]:void 0}function pr(e){var t=this.__data__;return W?t[e]!==void 0:S.call(t,e)}function yr(e,t){var r=this.__data__;return r[e]=W&&t===void 0?$e:t,this}E.prototype.clear=ur;E.prototype.delete=lr;E.prototype.get=fr;E.prototype.has=pr;E.prototype.set=yr;function v(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function gr(){this.__data__=[]}function hr(e){var t=this.__data__,r=H(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():tr.call(t,r,1),!0}function dr(e){var t=this.__data__,r=H(t,e);return r<0?void 0:t[r][1]}function br(e){return H(this.__data__,e)>-1}function mr(e,t){var r=this.__data__,n=H(r,e);return n<0?r.push([e,t]):r[n][1]=t,this}v.prototype.clear=gr;v.prototype.delete=hr;v.prototype.get=dr;v.prototype.has=br;v.prototype.set=mr;function T(e){var t=-1,r=e?e.length:0;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Or(){this.__data__={hash:new E,map:new(P||v),string:new E}}function vr(e){return R(this,e).delete(e)}function Sr(e){return R(this,e).get(e)}function wr(e){return R(this,e).has(e)}function _r(e,t){return R(this,e).set(e,t),this}T.prototype.clear=Or;T.prototype.delete=vr;T.prototype.get=Sr;T.prototype.has=wr;T.prototype.set=_r;function x(e){this.__data__=new v(e)}function Er(){this.__data__=new v}function $r(e){return this.__data__.delete(e)}function jr(e){return this.__data__.get(e)}function Ar(e){return this.__data__.has(e)}function Tr(e,t){var r=this.__data__;if(r instanceof v){var n=r.__data__;if(!P||n.length<Ct-1)return n.push([e,t]),this;r=this.__data__=new T(n)}return r.set(e,t),this}x.prototype.clear=Er;x.prototype.delete=$r;x.prototype.get=jr;x.prototype.has=Ar;x.prototype.set=Tr;function xr(e,t){var r=ce(e)||Zr(e)?Ut(e.length,String):[],n=r.length,i=!!n;for(var u in e)(t||S.call(e,u))&&!(i&&(u=="length"||zr(u,n)))&&r.push(u);return r}function at(e,t,r){var n=e[t];(!(S.call(e,t)&&ut(n,r))||r===void 0&&!(t in e))&&(e[t]=r)}function H(e,t){for(var r=e.length;r--;)if(ut(e[r][0],t))return r;return-1}function Dr(e,t){return e&&it(t,ue(t),e)}function ie(e,t,r,n,i,u,f){var l;if(n&&(l=u?n(e,i,u,f):n(e)),l!==void 0)return l;if(!B(e))return e;var o=ce(e);if(o){if(l=Gr(e),!t)return Hr(e,l)}else{var a=$(e),s=a==X||a==xe;if(tn(e))return Ir(e,t);if(a==Y||a==Q||s&&!u){if(qe(e))return u?e:{};if(l=Ur(s?{}:e),!t)return Rr(e,Dr(l,e))}else{if(!p[a])return u?e:{};l=qr(e,a,ie,t)}}f||(f=new x);var c=f.get(e);if(c)return c;if(f.set(e,l),!o)var g=r?Br(e):ue(e);return Bt(g||e,function(h,_){g&&(_=h,h=e[_]),at(l,_,ie(h,t,r,n,_,e,f))}),l}function Vr(e){return B(e)?Zt(e):{}}function Mr(e,t,r){var n=t(e);return ce(e)?n:Gt(n,r(e))}function Cr(e){return F.call(e)}function Pr(e){if(!B(e)||Xr(e))return!1;var t=ft(e)||qe(e)?Xt:kt;return t.test(j(e))}function Wr(e){if(!ct(e))return nr(e);var t=[];for(var r in Object(e))S.call(e,r)&&r!="constructor"&&t.push(r);return t}function Ir(e,t){if(t)return e.slice();var r=new e.constructor(e.length);return e.copy(r),r}function se(e){var t=new e.constructor(e.byteLength);return new tt(t).set(new tt(e)),t}function Nr(e,t){var r=t?se(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}function kr(e,t,r){var n=t?r(ze(e),!0):ze(e);return Ue(n,Ht,new e.constructor)}function Lr(e){var t=new e.constructor(e.source,Nt.exec(e));return t.lastIndex=e.lastIndex,t}function Jr(e,t,r){var n=t?r(Qe(e),!0):Qe(e);return Ue(n,Rt,new e.constructor)}function Kr(e){return ot?Object(ot.call(e)):{}}function Fr(e,t){var r=t?se(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Hr(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}function it(e,t,r,n){r||(r={});for(var i=-1,u=t.length;++i<u;){var f=t[i],l=n?n(r[f],e[f],f,r,e):void 0;at(r,f,l===void 0?e[f]:l)}return r}function Rr(e,t){return it(e,st(e),t)}function Br(e){return Mr(e,ue,st)}function R(e,t){var r=e.__data__;return Qr(t)?r[typeof t=="string"?"string":"hash"]:r.map}function D(e,t){var r=qt(e,t);return Pr(r)?r:void 0}var st=rt?ee(rt,Object):on,$=Cr;(re&&$(new re(new ArrayBuffer(1)))!=J||P&&$(new P)!=k||ne&&$(ne.resolve())!=Ve||oe&&$(new oe)!=L||ae&&$(new ae)!=Z)&&($=function(e){var t=F.call(e),r=t==Y?e.constructor:void 0,n=r?j(r):void 0;if(n)switch(n){case or:return J;case ar:return k;case ir:return Ve;case sr:return L;case cr:return Z}return t});function Gr(e){var t=e.length,r=e.constructor(t);return t&&typeof e[0]=="string"&&S.call(e,"index")&&(r.index=e.index,r.input=e.input),r}function Ur(e){return typeof e.constructor=="function"&&!ct(e)?Vr(Yt(e)):{}}function qr(e,t,r,n){var i=e.constructor;switch(t){case We:return se(e);case Ae:case Te:return new i(+e);case J:return Nr(e,n);case Ie:case Ne:case ke:case Le:case Je:case Ke:case Fe:case He:case Re:return Fr(e,n);case k:return kr(e,n,r);case De:case Ce:return new i(e);case Me:return Lr(e);case L:return Jr(e,n,r);case Pe:return Kr(e)}}function zr(e,t){return t=t==null?je:t,!!t&&(typeof e=="number"||Lt.test(e))&&e>-1&&e%1==0&&e<t}function Qr(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function Xr(e){return!!Xe&&Xe in e}function ct(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||K;return e===r}function j(e){if(e!=null){try{return Ye.call(e)}catch(t){}try{return e+""}catch(t){}}return""}function Yr(e){return ie(e,!0,!0)}function ut(e,t){return e===t||e!==e&&t!==t}function Zr(e){return en(e)&&S.call(e,"callee")&&(!er.call(e,"callee")||F.call(e)==Q)}var ce=Array.isArray;function lt(e){return e!=null&&rn(e.length)&&!ft(e)}function en(e){return nn(e)&<(e)}var tn=rr||an;function ft(e){var t=B(e)?F.call(e):"";return t==X||t==xe}function rn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=je}function B(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function nn(e){return!!e&&typeof e=="object"}function ue(e){return lt(e)?xr(e):Wr(e)}function on(){return[]}function an(){return!1}V.exports=Yr});var le=U((_n,ht)=>{var sn="[object Object]";function cn(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function un(e,t){return function(r){return e(t(r))}}var ln=Function.prototype,yt=Object.prototype,gt=ln.toString,fn=yt.hasOwnProperty,pn=gt.call(Object),yn=yt.toString,gn=un(Object.getPrototypeOf,Object);function hn(e){return!!e&&typeof e=="object"}function dn(e){if(!hn(e)||yn.call(e)!=sn||cn(e))return!1;var t=gn(e);if(t===null)return!0;var r=fn.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&>.call(r)==pn}ht.exports=dn});var Sn={};Vt(Sn,{compare:()=>he});var A=N(Ee(),1);var G=N(pt(),1),dt=N(le(),1);function bn(e){if(e.includes(".")){let t=e.lastIndexOf(".");if(!e.slice(0,t).includes("."))return e.slice(0,t);for(let r=t-1;r--;)if(e[r]===".")return e.slice(r+1,t)}return null}var fe=bn;function bt(e,t){let r={now:!1};function n(i,u,f,l){let o=(0,G.default)(i),a,s=m({depth:-1,path:""},f);if(s.depth+=1,Array.isArray(o))for(let c=0,g=o.length;c<g&&!l.now;c++){let h=s.path?`${s.path}.${c}`:`${c}`;o[c]!==void 0?(s.parent=(0,G.default)(o),s.parentType="array",s.parentKey=fe(h),a=n(u(o[c],void 0,C(m({},s),{path:h}),l),u,C(m({},s),{path:h}),l),Number.isNaN(a)&&c<o.length?(o.splice(c,1),c-=1):o[c]=a):o.splice(c,1)}else if((0,dt.default)(o))for(let c in o){if(l.now&&c!=null)break;let g=s.path?`${s.path}.${c}`:c;s.depth===0&&c!=null&&(s.topmostKey=c),s.parent=(0,G.default)(o),s.parentType="object",s.parentKey=fe(g),a=n(u(c,o[c],C(m({},s),{path:g}),l),u,C(m({},s),{path:g}),l),Number.isNaN(a)?delete o[c]:o[c]=a}return o}return n(e,t,{},r)}function b(e){if(typeof e=="string")return!e.trim();if(!["object","string"].includes(typeof e)||!e)return!1;let t=!0;return e=bt(e,(r,n,i,u)=>{let f=n!==void 0?n:r;return typeof f=="string"&&f.trim()&&(t=!1,u.now=!0),f}),t}var w=N(le(),1);function pe(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var ye=new Map,mt=(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(r=>{if(typeof r!="string"){if(typeof r=="undefined")return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof r}' in the array`)}return!0})},mn=(e,t)=>{t=m({caseSensitive:!1},t);let r=e+JSON.stringify(t);if(ye.has(r))return ye.get(r);let n=e[0]==="!";n&&(e=e.slice(1)),e=pe(e).replace(/\\\*/g,"[\\s\\S]*");let i=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return i.negated=n,ye.set(r,i),i},On=(e,t,r,n)=>{if(e=mt(e,"inputs"),t=mt(t,"patterns"),t.length===0)return[];t=t.map(f=>mn(f,r));let{allPatterns:i}=r||{},u=[];for(let f of e){let l,o=[...t].fill(!1);for(let[a,s]of t.entries())if(s.test(f)&&(o[a]=!0,l=!s.negated,!l))break;if(!(l===!1||l===void 0&&t.some(a=>!a.negated)||i&&o.some((a,s)=>!a&&!t[s].negated))&&(u.push(f),n))break}return u};function ge(e,t,r){return On(e,t,r,!0).length>0}function vn(e){return(0,w.default)(e)?!Object.keys(e).length:Array.isArray(e)||typeof e=="string"?!e.length:!1}function he(e,t,r){let n,i,u,f=0,o=m(m({},{hungryForWhitespace:!1,matchStrictly:!1,verboseWhenMismatches:!1,useWildcards:!1}),r);if(o.hungryForWhitespace&&o.matchStrictly&&(0,w.default)(e)&&b(e)&&(0,w.default)(t)&&!Object.keys(t).length)return!0;if((!o.hungryForWhitespace||o.hungryForWhitespace&&!b(e)&&b(t))&&(0,w.default)(e)&&Object.keys(e).length!==0&&(0,w.default)(t)&&Object.keys(t).length===0||(0,A.default)(e)!==(0,A.default)(t)&&(!o.hungryForWhitespace||o.hungryForWhitespace&&!b(e)))return!1;if(typeof e=="string"&&typeof t=="string")return o.hungryForWhitespace&&b(e)&&b(t)?!0:o.verboseWhenMismatches?e===t?!0:`Given string ${t} is not matched! We have ${e} on the other end.`:o.useWildcards?ge(e,t,{caseSensitive:!0}):e===t;if(Array.isArray(e)&&Array.isArray(t)){if(o.hungryForWhitespace&&b(t)&&(!o.matchStrictly||o.matchStrictly&&e.length===t.length))return!0;if(!o.hungryForWhitespace&&t.length>e.length||o.matchStrictly&&t.length!==e.length)return o.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:o.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 a=0,s=t.length;a<s;a++){u=!1;for(let c=f,g=e.length;c<g;c++)if(f+=1,he(e[c],t[a],o)===!0){u=!0;break}if(!u)return o.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((0,w.default)(e)&&(0,w.default)(t)){if(n=new Set(Object.keys(t)),i=new Set(Object.keys(e)),o.matchStrictly&&n.size!==i.size){if(!o.verboseWhenMismatches)return!1;let a=new Set([...n].filter(h=>!i.has(h))),s=a.size?` First object has unique keys: ${JSON.stringify(a,null,4)}.`:"",c=new Set([...i].filter(h=>!n.has(h))),g=c.size?` Second object has unique keys:
|
|
11
|
+
${JSON.stringify(c,null,4)}.`:"";return`When matching strictly, we found that both objects have different amount of keys.${s}${g}`}for(let a of n){if(!Object.prototype.hasOwnProperty.call(e,a))return!o.useWildcards||o.useWildcards&&!a.includes("*")?o.verboseWhenMismatches?`The given object has key "${a}" which the other-one does not have.`:!1:Object.keys(e).some(s=>ge(s,a,{caseSensitive:!0}))?!0:o.verboseWhenMismatches?`The given object has key "${a}" which the other-one does not have.`:!1;if(e[a]!=null&&(0,A.default)(e[a])!==(0,A.default)(t[a])){if(!(b(e[a])&&b(t[a])&&o.hungryForWhitespace))return o.verboseWhenMismatches?`The given key ${a} is of a different type on both objects. On the first-one, it's ${(0,A.default)(t[a])}, on the second-one, it's ${(0,A.default)(e[a])}`:!1}else if(he(e[a],t[a],o)!==!0)return o.verboseWhenMismatches?`The given piece ${JSON.stringify(t[a],null,4)} and ${JSON.stringify(e[a],null,4)} don't match.`:!1}}else return o.hungryForWhitespace&&b(e)&&b(t)&&(!o.matchStrictly||o.matchStrictly&&vn(t))?!0:e===t;return!0}return Mt(Sn);})();
|
|
11
12
|
/**
|
|
12
|
-
* @name ast-
|
|
13
|
-
* @fileoverview
|
|
14
|
-
* @version
|
|
13
|
+
* @name ast-contains-only-empty-space
|
|
14
|
+
* @fileoverview Does AST contain only empty space?
|
|
15
|
+
* @version 3.0.12
|
|
15
16
|
* @author Roy Revelt, Codsen Ltd
|
|
16
17
|
* @license MIT
|
|
17
|
-
* {@link https://codsen.com/os/ast-
|
|
18
|
-
*/
|
|
18
|
+
* {@link https://codsen.com/os/ast-contains-only-empty-space/}
|
|
19
|
+
*/
|
|
19
20
|
/**
|
|
20
21
|
* @name ast-monkey-traverse
|
|
21
22
|
* @fileoverview Utility library to traverse AST
|
|
22
|
-
* @version 3.0.
|
|
23
|
+
* @version 3.0.12
|
|
23
24
|
* @author Roy Revelt, Codsen Ltd
|
|
24
25
|
* @license MIT
|
|
25
26
|
* {@link https://codsen.com/os/ast-monkey-traverse/}
|
|
26
27
|
*/
|
|
27
28
|
/**
|
|
28
|
-
* @name ast-
|
|
29
|
-
* @fileoverview
|
|
30
|
-
* @version
|
|
29
|
+
* @name ast-monkey-util
|
|
30
|
+
* @fileoverview Utility library of AST helper functions
|
|
31
|
+
* @version 2.0.12
|
|
31
32
|
* @author Roy Revelt, Codsen Ltd
|
|
32
33
|
* @license MIT
|
|
33
|
-
* {@link https://codsen.com/os/ast-
|
|
34
|
+
* {@link https://codsen.com/os/ast-monkey-util/}
|
|
34
35
|
*/
|
|
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/examples/_quickTake.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ast-compare",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12",
|
|
4
4
|
"description": "Compare anything: AST, objects, arrays, strings and nested thereof",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -40,99 +40,48 @@
|
|
|
40
40
|
},
|
|
41
41
|
"types": "types/index.d.ts",
|
|
42
42
|
"scripts": {
|
|
43
|
-
"build": "
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"prettier": "
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"test": "npm run test:ci && npm run perf",
|
|
59
|
-
"test:ci": "npm run unittest && npm run test:examples && npm run format",
|
|
60
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
61
|
-
"tsc": "tsc",
|
|
62
|
-
"unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
|
|
43
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
44
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
45
|
+
"devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
46
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
47
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
48
|
+
"lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
49
|
+
"letspublish": "yarn publish || :",
|
|
50
|
+
"lint": "eslint . --fix",
|
|
51
|
+
"perf": "node perf/check.js",
|
|
52
|
+
"prepare": "echo 'ready'",
|
|
53
|
+
"prettier": "prettier",
|
|
54
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
55
|
+
"pretest": "yarn run lect && yarn run build",
|
|
56
|
+
"test": "yarn run devtest",
|
|
57
|
+
"unit": "uvu test"
|
|
63
58
|
},
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
61
|
+
},
|
|
62
|
+
"c8": {
|
|
63
|
+
"check-coverage": true,
|
|
64
|
+
"exclude": [
|
|
65
|
+
"**/test/**/*.*"
|
|
70
66
|
],
|
|
71
|
-
"
|
|
67
|
+
"lines": 100
|
|
72
68
|
},
|
|
73
69
|
"lect": {
|
|
74
70
|
"licence": {
|
|
75
71
|
"extras": [
|
|
76
72
|
""
|
|
77
73
|
]
|
|
78
|
-
},
|
|
79
|
-
"req": "{ compare }",
|
|
80
|
-
"various": {
|
|
81
|
-
"devDependencies": [
|
|
82
|
-
"@types/lodash.isplainobject",
|
|
83
|
-
"@types/type-detect",
|
|
84
|
-
"type-fest"
|
|
85
|
-
]
|
|
86
74
|
}
|
|
87
75
|
},
|
|
88
76
|
"dependencies": {
|
|
89
|
-
"
|
|
90
|
-
"ast-contains-only-empty-space": "^3.0.6",
|
|
77
|
+
"ast-contains-only-empty-space": "^3.0.12",
|
|
91
78
|
"lodash.isplainobject": "^4.0.6",
|
|
92
79
|
"matcher": "^5.0.0",
|
|
93
80
|
"type-detect": "^4.0.8"
|
|
94
81
|
},
|
|
95
82
|
"devDependencies": {
|
|
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",
|
|
108
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
109
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
110
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
111
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
112
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
113
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
114
83
|
"@types/lodash.isplainobject": "^4.0.6",
|
|
115
|
-
"@types/node": "^16.11.9",
|
|
116
|
-
"@types/tap": "^15.0.5",
|
|
117
84
|
"@types/type-detect": "^4.0.1",
|
|
118
|
-
"
|
|
119
|
-
"@typescript-eslint/parser": "^5.4.0",
|
|
120
|
-
"core-js": "^3.19.1",
|
|
121
|
-
"cross-env": "^7.0.3",
|
|
122
|
-
"eslint": "^8.3.0",
|
|
123
|
-
"lect": "^0.18.6",
|
|
124
|
-
"rollup": "^2.60.0",
|
|
125
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
126
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
127
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
128
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
129
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
130
|
-
"tap": "^15.1.2",
|
|
131
|
-
"tslib": "^2.3.1",
|
|
132
|
-
"type-fest": "^2.5.4",
|
|
133
|
-
"typescript": "^4.5.2"
|
|
134
|
-
},
|
|
135
|
-
"engines": {
|
|
136
|
-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
85
|
+
"type-fest": "^2.10.0"
|
|
137
86
|
}
|
|
138
87
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
declare type JsonValue =
|
|
1
|
+
declare type JsonValue =
|
|
2
|
+
| string
|
|
3
|
+
| number
|
|
4
|
+
| boolean
|
|
5
|
+
| null
|
|
6
|
+
| JsonObject
|
|
7
|
+
| JsonArray;
|
|
2
8
|
declare type JsonObject = {
|
|
3
|
-
|
|
9
|
+
[Key in string]?: JsonValue;
|
|
4
10
|
};
|
|
5
|
-
declare type JsonArray =
|
|
11
|
+
declare type JsonArray = JsonValue[];
|
|
6
12
|
interface Opts {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
hungryForWhitespace?: boolean;
|
|
14
|
+
matchStrictly?: boolean;
|
|
15
|
+
verboseWhenMismatches?: boolean;
|
|
16
|
+
useWildcards?: boolean;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Compare anything: AST, objects, arrays, strings and nested thereof
|
|
14
20
|
*/
|
|
15
|
-
declare function compare(
|
|
21
|
+
declare function compare(
|
|
22
|
+
b: JsonValue,
|
|
23
|
+
s: JsonValue,
|
|
24
|
+
originalOpts?: Opts
|
|
25
|
+
): boolean | string;
|
|
16
26
|
|
|
17
27
|
export { compare };
|
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport { compare } from \"ast-compare\";\n\n// Find out, does an object/array/string/nested-mix is a subset or equal to another input:\nassert.equal(\n compare(\n {\n a: {\n b: \"d\",\n c: [],\n e: \"f\",\n g: \"h\",\n },\n },\n {\n a: {\n b: \"d\",\n c: [],\n },\n }\n ),\n true\n);"},"compare-arrays.js":{"title":"Compare Arrays","content":"import { strict as assert } from \"assert\";\nimport { compare } from \"ast-compare\";\n\nassert.equal(compare([\"a\", \"b\", \"c\"], [\"a\", \"b\"]), true);\n// true, because second is a subset of first\n\nassert.equal(compare([\"a\", \"b\", \"c\"], [\"b\", \"a\"]), false);\n// => false, because order is wrong\n\nassert.equal(compare([\"a\", \"b\"], [\"a\", \"b\", \"c\"]), false);\n// => false, because second is not a subset of first (it's opposite)\n\nassert.equal(\n compare([{ a: \"b\" }, { c: \"d\" }, { e: \"f\" }], [{ a: \"b\" }, { c: \"d\" }]),\n true\n);\n// => plain objects nested in arrays"},"compare-objects.js":{"title":"Compare Plain Objects","content":"import { strict as assert } from \"assert\";\nimport { compare } from \"ast-compare\";\n\n// Find out, does an object/array/string/nested-mix is a subset or equal to another input:\nassert.equal(compare({ a: \"1\", b: \"2\", c: \"3\" }, { a: \"1\", b: \"2\" }), true);\n// true, because second (smallObj) is subset of (or equal) first (bigObj).\n\nassert.equal(compare({ a: \"1\", b: \"2\" }, { a: \"1\", b: \"2\", c: \"3\" }), false);\n// => false, because second (smallObj) is not a subset (or equal) to first (bigObj)."},"compare-strings.js":{"title":"Compare Strings","content":"import { strict as assert } from \"assert\";\nimport { compare } from \"ast-compare\";\n\nassert.equal(compare(\"a\\nb\", \"a\\nb\"), true);\n\nassert.equal(compare(\"a\", \"b\"), false);"},"opts-hungryForWhitespace.js":{"title":"`opts.hungryForWhitespace`","content":"import { strict as assert } from \"assert\";\nimport { compare } from \"ast-compare\";\n\n// by default, key values will be strictly matched using `===`\nassert.equal(\n compare(\n { a: \"\\n\\n\\n\", b: \"\\t\\t\\t\", c: \"whatever\" },\n { a: \"\\r\\r\\r\", b: \" \" },\n {\n hungryForWhitespace: false,\n }\n ),\n false\n);\n\n// whitespace is matched leniently with the following option:\nassert.equal(\n compare(\n { a: \"\\n\\n\\n\", b: \"\\t\\t\\t\", c: \"whatever\" },\n { a: \"\\r\\r\\r\", b: \" \" },\n {\n hungryForWhitespace: true,\n }\n ),\n true\n);\n\n// the fun doesn't stop here, any \"empty\" structures will be\n// reported as matching:\nassert.equal(\n compare(\n { a: { z: \"\\n\\n\\n\" }, b: [\"\\t\\t\\t\"], c: \"whatever\" },\n { a: [[[[[\"\\r\\r\\r\"]]]]], b: { c: { d: \" \" } } },\n {\n hungryForWhitespace: true, // <--- !\n }\n ),\n true // <--- !!!\n);\n// \"empty\" thing is:\n// - string that trims to zero-length\n// - array with zero or more whitespace strings only\n// - plain object with zero or more keys with \"empty\" values\n// (empty arrays, empty plain objects or empty strings)"},"opts-verboseWhenMismatches.js":{"title":"`opts.verboseWhenMismatches`","content":"import { strict as assert } from \"assert\";\nimport { compare } from \"ast-compare\";\n\n// by default, returns a boolean without explanation\nassert.equal(\n compare(\n { a: \"1\", b: \"2\" },\n { a: \"1\", b: \"2\", c: \"3\" },\n {\n verboseWhenMismatches: false, // <---\n }\n ),\n false\n);\n\nassert.equal(\n compare(\n { a: \"1\", b: \"2\" },\n { a: \"1\", b: \"2\", c: \"3\" },\n {\n verboseWhenMismatches: true, // <---\n }\n ),\n 'The given object has key \"c\" which the other-one does not have.'\n);\n\n// when opts.verboseWhenMismatches is enabled, a negative result is\n// string (explanation). A positive result is boolean \"true\".\nassert.equal(\n compare(\n { a: \"1\", b: \"2\" },\n { a: \"1\", b: \"2\" },\n {\n verboseWhenMismatches: true, // <---\n }\n ),\n true\n);"}}
|