fast-equals 1.6.0 → 2.0.0
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/.release-it.beta.json +13 -0
- package/.release-it.json +9 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/code/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/code/cache/cb395dc6899b78eb42b4fab9df67376a0a00bf80 +1 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/code/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/semanticDiagnostics/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/semanticDiagnostics/cache/cb395dc6899b78eb42b4fab9df67376a0a00bf80 +1 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/semanticDiagnostics/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/syntacticDiagnostics/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/syntacticDiagnostics/cache/cb395dc6899b78eb42b4fab9df67376a0a00bf80 +1 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/syntacticDiagnostics/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/types/cache/c0f16c9111806a91c6ae4b5d0b138e4841adf7c9 +0 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/types/cache/c9f40676a1b140ebc96dde967251686b673a9961 +0 -0
- package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/types/cache/e578d3be8d82631bd5cd8272d6aa5a54ba064304 +0 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/code/cache/0ab301188498506f5c998a00679f29b8929634e4 +1 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/code/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/code/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/semanticDiagnostics/cache/0ab301188498506f5c998a00679f29b8929634e4 +1 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/semanticDiagnostics/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/semanticDiagnostics/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/syntacticDiagnostics/cache/0ab301188498506f5c998a00679f29b8929634e4 +1 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/syntacticDiagnostics/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/syntacticDiagnostics/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/types/cache/6982fa2ac1e62f4aebb1debc73977393caa0d5a4 +0 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/types/cache/c0f16c9111806a91c6ae4b5d0b138e4841adf7c9 +0 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/types/cache/c9f40676a1b140ebc96dde967251686b673a9961 +0 -0
- package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/types/cache/e578d3be8d82631bd5cd8272d6aa5a54ba064304 +0 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/code/cache/82edcf6c99dc3d5802a5a8d3dbfc69f1048b520f +1 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/code/cache/eb02971c7d2972b89cd15754372a7b9a0b328a30 +1 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/code/cache/f6056671db45d89ddf3a27b7cf6d454993cec47b +1 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/semanticDiagnostics/cache/82edcf6c99dc3d5802a5a8d3dbfc69f1048b520f +1 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/semanticDiagnostics/cache/eb02971c7d2972b89cd15754372a7b9a0b328a30 +1 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/semanticDiagnostics/cache/f6056671db45d89ddf3a27b7cf6d454993cec47b +1 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/syntacticDiagnostics/cache/82edcf6c99dc3d5802a5a8d3dbfc69f1048b520f +1 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/syntacticDiagnostics/cache/eb02971c7d2972b89cd15754372a7b9a0b328a30 +1 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/syntacticDiagnostics/cache/f6056671db45d89ddf3a27b7cf6d454993cec47b +1 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/types/cache/c0f16c9111806a91c6ae4b5d0b138e4841adf7c9 +0 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/types/cache/c9f40676a1b140ebc96dde967251686b673a9961 +0 -0
- package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/types/cache/e578d3be8d82631bd5cd8272d6aa5a54ba064304 +0 -0
- package/BUILD.md +37 -0
- package/CHANGELOG.md +39 -0
- package/README.md +69 -88
- package/dist/fast-equals.cjs.js +427 -0
- package/dist/fast-equals.cjs.js.map +1 -0
- package/dist/fast-equals.esm.js +418 -0
- package/dist/fast-equals.esm.js.map +1 -0
- package/dist/fast-equals.js +418 -11
- package/dist/fast-equals.js.map +1 -1
- package/dist/fast-equals.min.js +1 -1
- package/dist/fast-equals.mjs +418 -0
- package/dist/fast-equals.mjs.map +1 -0
- package/index.d.ts +15 -14
- package/package.json +52 -65
- package/es/comparator.js +0 -91
- package/es/constants.js +0 -14
- package/es/index.js +0 -23
- package/es/utils.js +0 -295
- package/es-to-mjs.js +0 -14
- package/lib/comparator.js +0 -97
- package/lib/constants.js +0 -17
- package/lib/index.js +0 -34
- package/lib/utils.js +0 -300
- package/mjs/comparator.mjs +0 -91
- package/mjs/constants.mjs +0 -14
- package/mjs/index.mjs +0 -23
- package/mjs/utils.mjs +0 -295
- package/rollup.config.js +0 -44
- package/yarn-error.log +0 -8175
package/lib/utils.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.areRegExpsEqual = exports.areObjectsEqual = exports.createAreIterablesEqual = exports.areArraysEqual = exports.toPairs = exports.createCircularEqual = exports.getNewCache = exports.isReactElement = exports.isPromiseLike = exports.isPlainObject = exports.sameValueZeroEqual = exports.hasItems = exports.hasItem = exports.addObjectToCache = undefined;
|
|
5
|
-
|
|
6
|
-
var _constants = require('./constants');
|
|
7
|
-
|
|
8
|
-
var keys = Object.keys;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @function addObjectToCache
|
|
12
|
-
*
|
|
13
|
-
* @description
|
|
14
|
-
* add object to cache if it is indeed an object
|
|
15
|
-
*
|
|
16
|
-
* @param {any} object the object to potentially add to the cache
|
|
17
|
-
* @param {Object|WeakSet} cache the cache to add to
|
|
18
|
-
* @returns {void}
|
|
19
|
-
*/
|
|
20
|
-
// constants
|
|
21
|
-
var addObjectToCache = exports.addObjectToCache = function addObjectToCache(object, cache) {
|
|
22
|
-
return object && typeof object === 'object' && cache.add(object);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @function hasItem
|
|
27
|
-
*
|
|
28
|
-
* @description
|
|
29
|
-
* does the array include the item passed
|
|
30
|
-
*
|
|
31
|
-
* @param {Array<any>} array the array to check in
|
|
32
|
-
* @param {any} item the item to locate
|
|
33
|
-
* @param {function} isEqual the equality comparator
|
|
34
|
-
* @param {any} meta the meta item to pass through
|
|
35
|
-
* @returns {boolean} does the item exist in the array
|
|
36
|
-
*/
|
|
37
|
-
var hasItem = exports.hasItem = function hasItem(array, item, isEqual, meta) {
|
|
38
|
-
for (var index = 0; index < array.length; index++) {
|
|
39
|
-
if (isEqual(array[index], item, meta)) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return false;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @function hasItems
|
|
49
|
-
*
|
|
50
|
-
* @description
|
|
51
|
-
* are the arrays equal in value, despite being in different order
|
|
52
|
-
*
|
|
53
|
-
* @param {Array<any>} arrayA the first array to test
|
|
54
|
-
* @param {Array<any>} arrayB the second array to test
|
|
55
|
-
* @param {function} isEqual the equality comparator
|
|
56
|
-
* @param {any} meta the meta item to pass through
|
|
57
|
-
* @returns {boolean} are the arrays equal absent order
|
|
58
|
-
*/
|
|
59
|
-
var hasItems = exports.hasItems = function hasItems(arrayA, arrayB, isEqual, meta) {
|
|
60
|
-
if (arrayA.length !== arrayB.length) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
for (var index = 0; index < arrayA.length; index++) {
|
|
65
|
-
if (!hasItem(arrayB, arrayA[index], isEqual, meta)) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return true;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* @function sameValueZeroEqual
|
|
75
|
-
*
|
|
76
|
-
* @description
|
|
77
|
-
* are the objects passed strictly equal or both NaN
|
|
78
|
-
*
|
|
79
|
-
* @param {any} objectA the object to compare against
|
|
80
|
-
* @param {any} objectB the object to test
|
|
81
|
-
* @returns {boolean} are the objects equal by the SameValueZero principle
|
|
82
|
-
*/
|
|
83
|
-
var sameValueZeroEqual = exports.sameValueZeroEqual = function sameValueZeroEqual(objectA, objectB) {
|
|
84
|
-
return objectA === objectB || objectA !== objectA && objectB !== objectB;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @function isPlainObject
|
|
89
|
-
*
|
|
90
|
-
* @description
|
|
91
|
-
* is the object a plain object
|
|
92
|
-
*
|
|
93
|
-
* @param {any} object the object to test
|
|
94
|
-
* @returns {boolean} is the object a plain object
|
|
95
|
-
*/
|
|
96
|
-
var isPlainObject = exports.isPlainObject = function isPlainObject(object) {
|
|
97
|
-
return object.constructor === Object;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @function isPromiseLike
|
|
102
|
-
*
|
|
103
|
-
* @description
|
|
104
|
-
* is the object promise-like (thenable)
|
|
105
|
-
*
|
|
106
|
-
* @param {any} object the object to test
|
|
107
|
-
* @returns {boolean} is the object promise-like
|
|
108
|
-
*/
|
|
109
|
-
var isPromiseLike = exports.isPromiseLike = function isPromiseLike(object) {
|
|
110
|
-
return typeof object.then === 'function';
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* @function isReactElement
|
|
115
|
-
*
|
|
116
|
-
* @description
|
|
117
|
-
* is the object passed a react element
|
|
118
|
-
*
|
|
119
|
-
* @param {any} object the object to test
|
|
120
|
-
* @returns {boolean} is the object a react element
|
|
121
|
-
*/
|
|
122
|
-
var isReactElement = exports.isReactElement = function isReactElement(object) {
|
|
123
|
-
return !!(object.$$typeof && object._store);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @function getNewCache
|
|
128
|
-
*
|
|
129
|
-
* @description
|
|
130
|
-
* get a new cache object to prevent circular references
|
|
131
|
-
*
|
|
132
|
-
* @returns {Object|Weakset} the new cache object
|
|
133
|
-
*/
|
|
134
|
-
var getNewCache = exports.getNewCache = function getNewCache() {
|
|
135
|
-
return _constants.HAS_WEAKSET_SUPPORT ? new WeakSet() : Object.create({
|
|
136
|
-
_values: [],
|
|
137
|
-
add: function add(value) {
|
|
138
|
-
this._values.push(value);
|
|
139
|
-
},
|
|
140
|
-
has: function has(value) {
|
|
141
|
-
return !!~this._values.indexOf(value);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @function createCircularEqual
|
|
148
|
-
*
|
|
149
|
-
* @description
|
|
150
|
-
* create a custom isEqual handler specific to circular objects
|
|
151
|
-
*
|
|
152
|
-
* @param {funtion} [isEqual] the isEqual comparator to use instead of isDeepEqual
|
|
153
|
-
* @returns {function(any, any): boolean}
|
|
154
|
-
*/
|
|
155
|
-
var createCircularEqual = exports.createCircularEqual = function createCircularEqual(isEqual) {
|
|
156
|
-
return function (isDeepEqual) {
|
|
157
|
-
var comparator = isEqual || isDeepEqual;
|
|
158
|
-
|
|
159
|
-
return function (objectA, objectB) {
|
|
160
|
-
var cache = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : getNewCache();
|
|
161
|
-
|
|
162
|
-
var cacheHasA = cache.has(objectA);
|
|
163
|
-
var cacheHasB = cache.has(objectB);
|
|
164
|
-
|
|
165
|
-
if (cacheHasA || cacheHasB) {
|
|
166
|
-
return cacheHasA && cacheHasB;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
addObjectToCache(objectA, cache);
|
|
170
|
-
addObjectToCache(objectB, cache);
|
|
171
|
-
|
|
172
|
-
return comparator(objectA, objectB, cache);
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @function toPairs
|
|
179
|
-
*
|
|
180
|
-
* @param {Map|Set} iterable the iterable to convert to [key, value] pairs (entries)
|
|
181
|
-
* @returns {{keys: Array<*>, values: Array<*>}} the [key, value] pairs
|
|
182
|
-
*/
|
|
183
|
-
var toPairs = exports.toPairs = function toPairs(iterable) {
|
|
184
|
-
var pairs = {
|
|
185
|
-
keys: [],
|
|
186
|
-
values: []
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
iterable.forEach(function (value, key) {
|
|
190
|
-
return pairs.keys.push(key) && pairs.values.push(value);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
return pairs;
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* @function areArraysEqual
|
|
198
|
-
*
|
|
199
|
-
* @description
|
|
200
|
-
* are the arrays equal in value
|
|
201
|
-
*
|
|
202
|
-
* @param {Array<any>} arrayA the array to test
|
|
203
|
-
* @param {Array<any>} arrayB the array to test against
|
|
204
|
-
* @param {function} isEqual the comparator to determine equality
|
|
205
|
-
* @param {any} meta the meta object to pass through
|
|
206
|
-
* @returns {boolean} are the arrays equal
|
|
207
|
-
*/
|
|
208
|
-
var areArraysEqual = exports.areArraysEqual = function areArraysEqual(arrayA, arrayB, isEqual, meta) {
|
|
209
|
-
if (arrayA.length !== arrayB.length) {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
for (var index = 0; index < arrayA.length; index++) {
|
|
214
|
-
if (!isEqual(arrayA[index], arrayB[index], meta)) {
|
|
215
|
-
return false;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return true;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
var createAreIterablesEqual = exports.createAreIterablesEqual = function createAreIterablesEqual(shouldCompareKeys) {
|
|
223
|
-
/**
|
|
224
|
-
* @function areIterablesEqual
|
|
225
|
-
*
|
|
226
|
-
* @description
|
|
227
|
-
* determine if the iterables are equivalent in value
|
|
228
|
-
*
|
|
229
|
-
* @param {Array<Array<any>>} pairsA the pairs to test
|
|
230
|
-
* @param {Array<Array<any>>} pairsB the pairs to test against
|
|
231
|
-
* @param {function} isEqual the comparator to determine equality
|
|
232
|
-
* @param {any} meta the cache possibly being used
|
|
233
|
-
* @returns {boolean} are the objects equal in value
|
|
234
|
-
*/
|
|
235
|
-
var areIterablesEqual = shouldCompareKeys ? function (pairsA, pairsB, isEqual, meta) {
|
|
236
|
-
return hasItems(pairsA.keys, pairsB.keys, isEqual, meta) && hasItems(pairsA.values, pairsB.values, isEqual, meta);
|
|
237
|
-
} : function (pairsA, pairsB, isEqual, meta) {
|
|
238
|
-
return hasItems(pairsA.values, pairsB.values, isEqual, meta);
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
return function (iterableA, iterableB, isEqual, meta) {
|
|
242
|
-
return areIterablesEqual(toPairs(iterableA), toPairs(iterableB), isEqual, meta);
|
|
243
|
-
};
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* @function areArraysEqual
|
|
248
|
-
*
|
|
249
|
-
* @description
|
|
250
|
-
* are the objects equal in value
|
|
251
|
-
*
|
|
252
|
-
* @param {Array<any>} objectA the object to test
|
|
253
|
-
* @param {Array<any>} objectB the object to test against
|
|
254
|
-
* @param {function} isEqual the comparator to determine equality
|
|
255
|
-
* @param {any} meta the meta object to pass through
|
|
256
|
-
* @returns {boolean} are the objects equal
|
|
257
|
-
*/
|
|
258
|
-
var areObjectsEqual = exports.areObjectsEqual = function areObjectsEqual(objectA, objectB, isEqual, meta) {
|
|
259
|
-
var keysA = keys(objectA);
|
|
260
|
-
var keysB = keys(objectB);
|
|
261
|
-
|
|
262
|
-
if (keysA.length !== keysB.length) {
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
var key = void 0;
|
|
267
|
-
|
|
268
|
-
for (var index = 0; index < keysA.length; index++) {
|
|
269
|
-
key = keysA[index];
|
|
270
|
-
|
|
271
|
-
if (!hasItem(keysB, key, sameValueZeroEqual)) {
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// if a react element, ignore the "_owner" key because its not necessary for equality comparisons
|
|
276
|
-
if (key === '_owner' && isReactElement(objectA) && isReactElement(objectB)) {
|
|
277
|
-
continue;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (!isEqual(objectA[key], objectB[key], meta)) {
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
return true;
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @function areRegExpsEqual
|
|
290
|
-
*
|
|
291
|
-
* @description
|
|
292
|
-
* are the regExps equal in value
|
|
293
|
-
*
|
|
294
|
-
* @param {RegExp} regExpA the regExp to test
|
|
295
|
-
* @param {RegExp} regExpB the regExp to test agains
|
|
296
|
-
* @returns {boolean} are the regExps equal
|
|
297
|
-
*/
|
|
298
|
-
var areRegExpsEqual = exports.areRegExpsEqual = function areRegExpsEqual(regExpA, regExpB) {
|
|
299
|
-
return regExpA.source === regExpB.source && regExpA.global === regExpB.global && regExpA.ignoreCase === regExpB.ignoreCase && regExpA.multiline === regExpB.multiline && regExpA.unicode === regExpB.unicode && regExpA.sticky === regExpB.sticky && regExpA.lastIndex === regExpB.lastIndex;
|
|
300
|
-
};
|
package/mjs/comparator.mjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// constants
|
|
2
|
-
import { HAS_MAP_SUPPORT, HAS_SET_SUPPORT } from './constants';
|
|
3
|
-
|
|
4
|
-
// utils
|
|
5
|
-
import { areArraysEqual, areObjectsEqual, areRegExpsEqual, createAreIterablesEqual, isPlainObject, isPromiseLike, isReactElement, sameValueZeroEqual } from './utils';
|
|
6
|
-
|
|
7
|
-
var isArray = Array.isArray;
|
|
8
|
-
|
|
9
|
-
var areMapsEqual = createAreIterablesEqual(true);
|
|
10
|
-
var areSetsEqual = createAreIterablesEqual(false);
|
|
11
|
-
|
|
12
|
-
var createComparator = function createComparator(createIsEqual) {
|
|
13
|
-
// eslint-disable-next-line no-use-before-define
|
|
14
|
-
var isEqual = typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @function comparator
|
|
18
|
-
*
|
|
19
|
-
* @description
|
|
20
|
-
* compare the value of the two objects and return true if they are equivalent in values
|
|
21
|
-
*
|
|
22
|
-
* @param {any} objectA the object to test against
|
|
23
|
-
* @param {any} objectB the object to test
|
|
24
|
-
* @param {any} [meta] an optional meta object that is passed through to all equality test calls
|
|
25
|
-
* @returns {boolean} are objectA and objectB equivalent in value
|
|
26
|
-
*/
|
|
27
|
-
function comparator(objectA, objectB, meta) {
|
|
28
|
-
if (sameValueZeroEqual(objectA, objectB)) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
var typeOfA = typeof objectA;
|
|
33
|
-
|
|
34
|
-
if (typeOfA !== typeof objectB || typeOfA !== 'object' || !objectA || !objectB) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (isPlainObject(objectA) && isPlainObject(objectB)) {
|
|
39
|
-
return areObjectsEqual(objectA, objectB, isEqual, meta);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
var arrayA = isArray(objectA);
|
|
43
|
-
var arrayB = isArray(objectB);
|
|
44
|
-
|
|
45
|
-
if (arrayA || arrayB) {
|
|
46
|
-
return arrayA === arrayB && areArraysEqual(objectA, objectB, isEqual, meta);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
var dateA = objectA instanceof Date;
|
|
50
|
-
var dateB = objectB instanceof Date;
|
|
51
|
-
|
|
52
|
-
if (dateA || dateB) {
|
|
53
|
-
return dateA === dateB && sameValueZeroEqual(objectA.getTime(), objectB.getTime());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var regexpA = objectA instanceof RegExp;
|
|
57
|
-
var regexpB = objectB instanceof RegExp;
|
|
58
|
-
|
|
59
|
-
if (regexpA || regexpB) {
|
|
60
|
-
return regexpA === regexpB && areRegExpsEqual(objectA, objectB);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (isPromiseLike(objectA) || isPromiseLike(objectB)) {
|
|
64
|
-
return objectA === objectB;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (HAS_MAP_SUPPORT) {
|
|
68
|
-
var mapA = objectA instanceof Map;
|
|
69
|
-
var mapB = objectB instanceof Map;
|
|
70
|
-
|
|
71
|
-
if (mapA || mapB) {
|
|
72
|
-
return mapA === mapB && areMapsEqual(objectA, objectB, isEqual, meta);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (HAS_SET_SUPPORT) {
|
|
77
|
-
var setA = objectA instanceof Set;
|
|
78
|
-
var setB = objectB instanceof Set;
|
|
79
|
-
|
|
80
|
-
if (setA || setB) {
|
|
81
|
-
return setA === setB && areSetsEqual(objectA, objectB, isEqual, meta);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return areObjectsEqual(objectA, objectB, isEqual, meta);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return comparator;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export default createComparator;
|
package/mjs/constants.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @constant {boolean} HAS_MAP_SUPPORT
|
|
3
|
-
*/
|
|
4
|
-
export var HAS_MAP_SUPPORT = typeof Map === 'function';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @constant {boolean} HAS_SET_SUPPORT
|
|
8
|
-
*/
|
|
9
|
-
export var HAS_SET_SUPPORT = typeof Set === 'function';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @constant {boolean} HAS_WEAKSET_SUPPORT
|
|
13
|
-
*/
|
|
14
|
-
export var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
|
package/mjs/index.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// comparator
|
|
2
|
-
import createCustomEqual from './comparator';
|
|
3
|
-
|
|
4
|
-
// utils
|
|
5
|
-
import { createCircularEqual, sameValueZeroEqual } from './utils';
|
|
6
|
-
|
|
7
|
-
export { createCustomEqual, sameValueZeroEqual };
|
|
8
|
-
|
|
9
|
-
export var circularDeepEqual = createCustomEqual(createCircularEqual());
|
|
10
|
-
export var circularShallowEqual = createCustomEqual(createCircularEqual(sameValueZeroEqual));
|
|
11
|
-
export var deepEqual = createCustomEqual();
|
|
12
|
-
export var shallowEqual = createCustomEqual(function () {
|
|
13
|
-
return sameValueZeroEqual;
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export default {
|
|
17
|
-
circularDeep: circularDeepEqual,
|
|
18
|
-
circularShallow: circularShallowEqual,
|
|
19
|
-
createCustom: createCustomEqual,
|
|
20
|
-
deep: deepEqual,
|
|
21
|
-
sameValueZero: sameValueZeroEqual,
|
|
22
|
-
shallow: shallowEqual
|
|
23
|
-
};
|