fast-equals 1.6.3 → 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/.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 +23 -0
- package/README.md +65 -84
- package/dist/fast-equals.cjs.js +415 -446
- package/dist/fast-equals.cjs.js.map +1 -1
- package/dist/fast-equals.esm.js +415 -446
- package/dist/fast-equals.esm.js.map +1 -1
- package/dist/fast-equals.js +415 -446
- 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 +31 -47
- package/es/comparator.js +0 -86
- package/es/constants.js +0 -14
- package/es/index.js +0 -19
- package/es/utils.js +0 -333
- package/es-to-mjs.js +0 -14
- package/lib/comparator.js +0 -94
- package/lib/constants.js +0 -22
- package/lib/index.js +0 -36
- package/lib/utils.js +0 -386
- package/mjs/comparator.mjs +0 -86
- package/mjs/constants.mjs +0 -14
- package/mjs/index.mjs +0 -19
- package/mjs/utils.mjs +0 -333
- package/rollup.config.js +0 -55
- package/yarn-error.log +0 -8175
package/lib/constants.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.HAS_WEAKSET_SUPPORT = exports.HAS_SET_SUPPORT = exports.HAS_MAP_SUPPORT = void 0;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @constant {boolean} HAS_MAP_SUPPORT
|
|
8
|
-
*/
|
|
9
|
-
var HAS_MAP_SUPPORT = typeof Map === 'function';
|
|
10
|
-
/**
|
|
11
|
-
* @constant {boolean} HAS_SET_SUPPORT
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
exports.HAS_MAP_SUPPORT = HAS_MAP_SUPPORT;
|
|
15
|
-
var HAS_SET_SUPPORT = typeof Set === 'function';
|
|
16
|
-
/**
|
|
17
|
-
* @constant {boolean} HAS_WEAKSET_SUPPORT
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
exports.HAS_SET_SUPPORT = HAS_SET_SUPPORT;
|
|
21
|
-
var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
|
|
22
|
-
exports.HAS_WEAKSET_SUPPORT = HAS_WEAKSET_SUPPORT;
|
package/lib/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports["default"] = exports.shallowEqual = exports.deepEqual = exports.circularShallowEqual = exports.circularDeepEqual = void 0;
|
|
5
|
-
|
|
6
|
-
var _comparator = _interopRequireDefault(require("./comparator"));
|
|
7
|
-
|
|
8
|
-
exports.createCustomEqual = _comparator["default"];
|
|
9
|
-
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
|
|
12
|
-
exports.sameValueZeroEqual = _utils.sameValueZeroEqual;
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
// comparator
|
|
17
|
-
// utils
|
|
18
|
-
var circularDeepEqual = (0, _comparator["default"])((0, _utils.createCircularEqual)());
|
|
19
|
-
exports.circularDeepEqual = circularDeepEqual;
|
|
20
|
-
var circularShallowEqual = (0, _comparator["default"])((0, _utils.createCircularEqual)(_utils.sameValueZeroEqual));
|
|
21
|
-
exports.circularShallowEqual = circularShallowEqual;
|
|
22
|
-
var deepEqual = (0, _comparator["default"])();
|
|
23
|
-
exports.deepEqual = deepEqual;
|
|
24
|
-
var shallowEqual = (0, _comparator["default"])(function () {
|
|
25
|
-
return _utils.sameValueZeroEqual;
|
|
26
|
-
});
|
|
27
|
-
exports.shallowEqual = shallowEqual;
|
|
28
|
-
var _default = {
|
|
29
|
-
circularDeep: circularDeepEqual,
|
|
30
|
-
circularShallow: circularShallowEqual,
|
|
31
|
-
createCustom: _comparator["default"],
|
|
32
|
-
deep: deepEqual,
|
|
33
|
-
sameValueZero: _utils.sameValueZeroEqual,
|
|
34
|
-
shallow: shallowEqual
|
|
35
|
-
};
|
|
36
|
-
exports["default"] = _default;
|
package/lib/utils.js
DELETED
|
@@ -1,386 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
exports.__esModule = true;
|
|
4
|
-
exports.areSetsEqual = exports.areRegExpsEqual = exports.areObjectsEqual = exports.areMapsEqual = exports.areArraysEqual = exports.toValues = exports.toPairs = exports.createCircularEqual = exports.getNewCache = exports.isReactElement = exports.isPromiseLike = exports.isPlainObject = exports.sameValueZeroEqual = exports.hasValue = exports.hasPair = exports.addObjectToCache = void 0;
|
|
5
|
-
|
|
6
|
-
var _constants = require("./constants");
|
|
7
|
-
|
|
8
|
-
// constants
|
|
9
|
-
var keys = Object.keys;
|
|
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
|
-
|
|
21
|
-
var addObjectToCache = function addObjectToCache(object, cache) {
|
|
22
|
-
return object && typeof object === 'object' && cache.add(object);
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
-
* @param {Array<Array<any>>} pairs the pairs to check in
|
|
27
|
-
* @param {Array<any>} pairToMatch the pair to check if exists
|
|
28
|
-
* @param {function} isEqual the equality comparator
|
|
29
|
-
* @param {any} meta the meta item to pass through
|
|
30
|
-
* @returns {boolean} does the pair exist in the pairs
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
exports.addObjectToCache = addObjectToCache;
|
|
35
|
-
|
|
36
|
-
var hasPair = function hasPair(pairs, pairToMatch, isEqual, meta) {
|
|
37
|
-
var pair;
|
|
38
|
-
|
|
39
|
-
for (var index = 0; index < pairs.length; index++) {
|
|
40
|
-
pair = pairs[index];
|
|
41
|
-
|
|
42
|
-
if (isEqual(pair[0], pairToMatch[0], meta) && isEqual(pair[1], pairToMatch[1], meta)) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return false;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* @function hasValue
|
|
51
|
-
*
|
|
52
|
-
* @description
|
|
53
|
-
* does the values include the vakye passed
|
|
54
|
-
*
|
|
55
|
-
* @param {Array<any>} values the values to check in
|
|
56
|
-
* @param {any} item the value to locate
|
|
57
|
-
* @param {function} isEqual the equality comparator
|
|
58
|
-
* @param {any} meta the meta item to pass through
|
|
59
|
-
* @returns {boolean} does the value exist in the values
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
exports.hasPair = hasPair;
|
|
64
|
-
|
|
65
|
-
var hasValue = function hasValue(values, item, isEqual, meta) {
|
|
66
|
-
for (var index = 0; index < values.length; index++) {
|
|
67
|
-
if (isEqual(values[index], item, meta)) {
|
|
68
|
-
return true;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return false;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* @function sameValueZeroEqual
|
|
76
|
-
*
|
|
77
|
-
* @description
|
|
78
|
-
* are the objects passed strictly equal or both NaN
|
|
79
|
-
*
|
|
80
|
-
* @param {any} objectA the object to compare against
|
|
81
|
-
* @param {any} objectB the object to test
|
|
82
|
-
* @returns {boolean} are the objects equal by the SameValueZero principle
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
exports.hasValue = hasValue;
|
|
87
|
-
|
|
88
|
-
var sameValueZeroEqual = function sameValueZeroEqual(objectA, objectB) {
|
|
89
|
-
return objectA === objectB || objectA !== objectA && objectB !== objectB;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* @function isPlainObject
|
|
93
|
-
*
|
|
94
|
-
* @description
|
|
95
|
-
* is the object a plain object
|
|
96
|
-
*
|
|
97
|
-
* @param {any} object the object to test
|
|
98
|
-
* @returns {boolean} is the object a plain object
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
exports.sameValueZeroEqual = sameValueZeroEqual;
|
|
103
|
-
|
|
104
|
-
var isPlainObject = function isPlainObject(object) {
|
|
105
|
-
return object.constructor === Object;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* @function isPromiseLike
|
|
109
|
-
*
|
|
110
|
-
* @description
|
|
111
|
-
* is the object promise-like (thenable)
|
|
112
|
-
*
|
|
113
|
-
* @param {any} object the object to test
|
|
114
|
-
* @returns {boolean} is the object promise-like
|
|
115
|
-
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
exports.isPlainObject = isPlainObject;
|
|
119
|
-
|
|
120
|
-
var isPromiseLike = function isPromiseLike(object) {
|
|
121
|
-
return typeof object.then === 'function';
|
|
122
|
-
};
|
|
123
|
-
/**
|
|
124
|
-
* @function isReactElement
|
|
125
|
-
*
|
|
126
|
-
* @description
|
|
127
|
-
* is the object passed a react element
|
|
128
|
-
*
|
|
129
|
-
* @param {any} object the object to test
|
|
130
|
-
* @returns {boolean} is the object a react element
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
exports.isPromiseLike = isPromiseLike;
|
|
135
|
-
|
|
136
|
-
var isReactElement = function isReactElement(object) {
|
|
137
|
-
return !!(object.$$typeof && object._store);
|
|
138
|
-
};
|
|
139
|
-
/**
|
|
140
|
-
* @function getNewCache
|
|
141
|
-
*
|
|
142
|
-
* @description
|
|
143
|
-
* get a new cache object to prevent circular references
|
|
144
|
-
*
|
|
145
|
-
* @returns {Object|Weakset} the new cache object
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
exports.isReactElement = isReactElement;
|
|
150
|
-
|
|
151
|
-
var getNewCache = function getNewCache() {
|
|
152
|
-
return _constants.HAS_WEAKSET_SUPPORT ? new WeakSet() : Object.create({
|
|
153
|
-
_values: [],
|
|
154
|
-
add: function add(value) {
|
|
155
|
-
this._values.push(value);
|
|
156
|
-
},
|
|
157
|
-
has: function has(value) {
|
|
158
|
-
return !!~this._values.indexOf(value);
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* @function createCircularEqual
|
|
164
|
-
*
|
|
165
|
-
* @description
|
|
166
|
-
* create a custom isEqual handler specific to circular objects
|
|
167
|
-
*
|
|
168
|
-
* @param {funtion} [isEqual] the isEqual comparator to use instead of isDeepEqual
|
|
169
|
-
* @returns {function(any, any): boolean}
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
exports.getNewCache = getNewCache;
|
|
174
|
-
|
|
175
|
-
var createCircularEqual = function createCircularEqual(isEqual) {
|
|
176
|
-
return function (isDeepEqual) {
|
|
177
|
-
var comparator = isEqual || isDeepEqual;
|
|
178
|
-
return function (objectA, objectB, cache) {
|
|
179
|
-
if (cache === void 0) {
|
|
180
|
-
cache = getNewCache();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
var cacheHasA = cache.has(objectA);
|
|
184
|
-
var cacheHasB = cache.has(objectB);
|
|
185
|
-
|
|
186
|
-
if (cacheHasA || cacheHasB) {
|
|
187
|
-
return cacheHasA && cacheHasB;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
addObjectToCache(objectA, cache);
|
|
191
|
-
addObjectToCache(objectB, cache);
|
|
192
|
-
return comparator(objectA, objectB, cache);
|
|
193
|
-
};
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
/**
|
|
197
|
-
* @function toPairs
|
|
198
|
-
*
|
|
199
|
-
* @param {Map} map the map to convert to [key, value] pairs (entries)
|
|
200
|
-
* @returns {Array<Array<*>>} the [key, value] pairs
|
|
201
|
-
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
exports.createCircularEqual = createCircularEqual;
|
|
205
|
-
|
|
206
|
-
var toPairs = function toPairs(map) {
|
|
207
|
-
var pairs = [];
|
|
208
|
-
map.forEach(function (value, key) {
|
|
209
|
-
return pairs.push([key, value]);
|
|
210
|
-
});
|
|
211
|
-
return pairs;
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* @function toValues
|
|
215
|
-
*
|
|
216
|
-
* @param {Set} set the set to convert to values
|
|
217
|
-
* @returns {Array<*>} the values
|
|
218
|
-
*/
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
exports.toPairs = toPairs;
|
|
222
|
-
|
|
223
|
-
var toValues = function toValues(set) {
|
|
224
|
-
var values = [];
|
|
225
|
-
set.forEach(function (value) {
|
|
226
|
-
return values.push(value);
|
|
227
|
-
});
|
|
228
|
-
return values;
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* @function areArraysEqual
|
|
232
|
-
*
|
|
233
|
-
* @description
|
|
234
|
-
* are the arrays equal in value
|
|
235
|
-
*
|
|
236
|
-
* @param {Array<any>} arrayA the array to test
|
|
237
|
-
* @param {Array<any>} arrayB the array to test against
|
|
238
|
-
* @param {function} isEqual the comparator to determine equality
|
|
239
|
-
* @param {any} meta the meta object to pass through
|
|
240
|
-
* @returns {boolean} are the arrays equal
|
|
241
|
-
*/
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
exports.toValues = toValues;
|
|
245
|
-
|
|
246
|
-
var areArraysEqual = function areArraysEqual(arrayA, arrayB, isEqual, meta) {
|
|
247
|
-
if (arrayA.length !== arrayB.length) {
|
|
248
|
-
return false;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
for (var index = 0; index < arrayA.length; index++) {
|
|
252
|
-
if (!isEqual(arrayA[index], arrayB[index], meta)) {
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return true;
|
|
258
|
-
};
|
|
259
|
-
/**
|
|
260
|
-
* @function areMapsEqual
|
|
261
|
-
*
|
|
262
|
-
* @description
|
|
263
|
-
* are the maps equal in value
|
|
264
|
-
*
|
|
265
|
-
* @param {Map} mapA the map to test
|
|
266
|
-
* @param {Map} mapB the map to test against
|
|
267
|
-
* @param {function} isEqual the comparator to determine equality
|
|
268
|
-
* @param {any} meta the meta map to pass through
|
|
269
|
-
* @returns {boolean} are the maps equal
|
|
270
|
-
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
exports.areArraysEqual = areArraysEqual;
|
|
274
|
-
|
|
275
|
-
var areMapsEqual = function areMapsEqual(mapA, mapB, isEqual, meta) {
|
|
276
|
-
if (mapA.size !== mapB.size) {
|
|
277
|
-
return false;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
var pairsA = toPairs(mapA);
|
|
281
|
-
var pairsB = toPairs(mapB);
|
|
282
|
-
|
|
283
|
-
for (var index = 0; index < pairsA.length; index++) {
|
|
284
|
-
if (!hasPair(pairsB, pairsA[index], isEqual, meta) || !hasPair(pairsA, pairsB[index], isEqual, meta)) {
|
|
285
|
-
return false;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
return true;
|
|
290
|
-
};
|
|
291
|
-
/**
|
|
292
|
-
* @function areObjectsEqual
|
|
293
|
-
*
|
|
294
|
-
* @description
|
|
295
|
-
* are the objects equal in value
|
|
296
|
-
*
|
|
297
|
-
* @param {Object} objectA the object to test
|
|
298
|
-
* @param {Object} objectB the object to test against
|
|
299
|
-
* @param {function} isEqual the comparator to determine equality
|
|
300
|
-
* @param {any} meta the meta object to pass through
|
|
301
|
-
* @returns {boolean} are the objects equal
|
|
302
|
-
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
exports.areMapsEqual = areMapsEqual;
|
|
306
|
-
|
|
307
|
-
var areObjectsEqual = function areObjectsEqual(objectA, objectB, isEqual, meta) {
|
|
308
|
-
var keysA = keys(objectA);
|
|
309
|
-
var keysB = keys(objectB);
|
|
310
|
-
|
|
311
|
-
if (keysA.length !== keysB.length) {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
var key;
|
|
316
|
-
|
|
317
|
-
for (var index = 0; index < keysA.length; index++) {
|
|
318
|
-
key = keysA[index];
|
|
319
|
-
|
|
320
|
-
if (!hasValue(keysB, key, sameValueZeroEqual)) {
|
|
321
|
-
return false;
|
|
322
|
-
} // if a react element, ignore the "_owner" key because its not necessary for equality comparisons
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (key === '_owner' && isReactElement(objectA) && isReactElement(objectB)) {
|
|
326
|
-
continue;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (!isEqual(objectA[key], objectB[key], meta)) {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
return true;
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* @function areRegExpsEqual
|
|
338
|
-
*
|
|
339
|
-
* @description
|
|
340
|
-
* are the regExps equal in value
|
|
341
|
-
*
|
|
342
|
-
* @param {RegExp} regExpA the regExp to test
|
|
343
|
-
* @param {RegExp} regExpB the regExp to test agains
|
|
344
|
-
* @returns {boolean} are the regExps equal
|
|
345
|
-
*/
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
exports.areObjectsEqual = areObjectsEqual;
|
|
349
|
-
|
|
350
|
-
var areRegExpsEqual = function areRegExpsEqual(regExpA, regExpB) {
|
|
351
|
-
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;
|
|
352
|
-
};
|
|
353
|
-
/**
|
|
354
|
-
* @function areSetsEqual
|
|
355
|
-
*
|
|
356
|
-
* @description
|
|
357
|
-
* are the sets equal in value
|
|
358
|
-
*
|
|
359
|
-
* @param {Set} setA the set to test
|
|
360
|
-
* @param {Set} setB the set to test against
|
|
361
|
-
* @param {function} isEqual the comparator to determine equality
|
|
362
|
-
* @param {any} meta the meta set to pass through
|
|
363
|
-
* @returns {boolean} are the sets equal
|
|
364
|
-
*/
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
exports.areRegExpsEqual = areRegExpsEqual;
|
|
368
|
-
|
|
369
|
-
var areSetsEqual = function areSetsEqual(setA, setB, isEqual, meta) {
|
|
370
|
-
if (setA.size !== setB.size) {
|
|
371
|
-
return false;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
var valuesA = toValues(setA);
|
|
375
|
-
var valuesB = toValues(setB);
|
|
376
|
-
|
|
377
|
-
for (var index = 0; index < valuesA.length; index++) {
|
|
378
|
-
if (!hasValue(valuesB, valuesA[index], isEqual, meta) || !hasValue(valuesA, valuesB[index], isEqual, meta)) {
|
|
379
|
-
return false;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
return true;
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
exports.areSetsEqual = areSetsEqual;
|
package/mjs/comparator.mjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// constants
|
|
2
|
-
import { HAS_MAP_SUPPORT, HAS_SET_SUPPORT } from './constants'; // utils
|
|
3
|
-
|
|
4
|
-
import { areArraysEqual, areMapsEqual, areObjectsEqual, areRegExpsEqual, areSetsEqual, isPlainObject, isPromiseLike, sameValueZeroEqual } from './utils';
|
|
5
|
-
var isArray = Array.isArray;
|
|
6
|
-
|
|
7
|
-
var createComparator = function createComparator(createIsEqual) {
|
|
8
|
-
// eslint-disable-next-line no-use-before-define
|
|
9
|
-
var isEqual = typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
|
|
10
|
-
/**
|
|
11
|
-
* @function comparator
|
|
12
|
-
*
|
|
13
|
-
* @description
|
|
14
|
-
* compare the value of the two objects and return true if they are equivalent in values
|
|
15
|
-
*
|
|
16
|
-
* @param {any} objectA the object to test against
|
|
17
|
-
* @param {any} objectB the object to test
|
|
18
|
-
* @param {any} [meta] an optional meta object that is passed through to all equality test calls
|
|
19
|
-
* @returns {boolean} are objectA and objectB equivalent in value
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
function comparator(objectA, objectB, meta) {
|
|
23
|
-
if (sameValueZeroEqual(objectA, objectB)) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var typeOfA = typeof objectA;
|
|
28
|
-
|
|
29
|
-
if (typeOfA !== typeof objectB || typeOfA !== 'object' || !objectA || !objectB) {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (isPlainObject(objectA) && isPlainObject(objectB)) {
|
|
34
|
-
return areObjectsEqual(objectA, objectB, isEqual, meta);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var arrayA = isArray(objectA);
|
|
38
|
-
var arrayB = isArray(objectB);
|
|
39
|
-
|
|
40
|
-
if (arrayA || arrayB) {
|
|
41
|
-
return arrayA === arrayB && areArraysEqual(objectA, objectB, isEqual, meta);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
var dateA = objectA instanceof Date;
|
|
45
|
-
var dateB = objectB instanceof Date;
|
|
46
|
-
|
|
47
|
-
if (dateA || dateB) {
|
|
48
|
-
return dateA === dateB && sameValueZeroEqual(objectA.getTime(), objectB.getTime());
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
var regexpA = objectA instanceof RegExp;
|
|
52
|
-
var regexpB = objectB instanceof RegExp;
|
|
53
|
-
|
|
54
|
-
if (regexpA || regexpB) {
|
|
55
|
-
return regexpA === regexpB && areRegExpsEqual(objectA, objectB);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (isPromiseLike(objectA) || isPromiseLike(objectB)) {
|
|
59
|
-
return objectA === objectB;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (HAS_MAP_SUPPORT) {
|
|
63
|
-
var mapA = objectA instanceof Map;
|
|
64
|
-
var mapB = objectB instanceof Map;
|
|
65
|
-
|
|
66
|
-
if (mapA || mapB) {
|
|
67
|
-
return mapA === mapB && areMapsEqual(objectA, objectB, isEqual, meta);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (HAS_SET_SUPPORT) {
|
|
72
|
-
var setA = objectA instanceof Set;
|
|
73
|
-
var setB = objectB instanceof Set;
|
|
74
|
-
|
|
75
|
-
if (setA || setB) {
|
|
76
|
-
return setA === setB && areSetsEqual(objectA, objectB, isEqual, meta);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return areObjectsEqual(objectA, objectB, isEqual, meta);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return comparator;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
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
|
-
* @constant {boolean} HAS_SET_SUPPORT
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export var HAS_SET_SUPPORT = typeof Set === 'function';
|
|
10
|
-
/**
|
|
11
|
-
* @constant {boolean} HAS_WEAKSET_SUPPORT
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export var HAS_WEAKSET_SUPPORT = typeof WeakSet === 'function';
|
package/mjs/index.mjs
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// comparator
|
|
2
|
-
import createCustomEqual from './comparator'; // utils
|
|
3
|
-
|
|
4
|
-
import { createCircularEqual, sameValueZeroEqual } from './utils';
|
|
5
|
-
export { createCustomEqual, sameValueZeroEqual };
|
|
6
|
-
export var circularDeepEqual = createCustomEqual(createCircularEqual());
|
|
7
|
-
export var circularShallowEqual = createCustomEqual(createCircularEqual(sameValueZeroEqual));
|
|
8
|
-
export var deepEqual = createCustomEqual();
|
|
9
|
-
export var shallowEqual = createCustomEqual(function () {
|
|
10
|
-
return sameValueZeroEqual;
|
|
11
|
-
});
|
|
12
|
-
export default {
|
|
13
|
-
circularDeep: circularDeepEqual,
|
|
14
|
-
circularShallow: circularShallowEqual,
|
|
15
|
-
createCustom: createCustomEqual,
|
|
16
|
-
deep: deepEqual,
|
|
17
|
-
sameValueZero: sameValueZeroEqual,
|
|
18
|
-
shallow: shallowEqual
|
|
19
|
-
};
|