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