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.
Files changed (66) hide show
  1. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/code/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
  2. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/code/cache/cb395dc6899b78eb42b4fab9df67376a0a00bf80 +1 -0
  3. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/code/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
  4. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/semanticDiagnostics/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
  5. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/semanticDiagnostics/cache/cb395dc6899b78eb42b4fab9df67376a0a00bf80 +1 -0
  6. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/semanticDiagnostics/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
  7. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/syntacticDiagnostics/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
  8. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/syntacticDiagnostics/cache/cb395dc6899b78eb42b4fab9df67376a0a00bf80 +1 -0
  9. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/syntacticDiagnostics/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
  10. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/types/cache/c0f16c9111806a91c6ae4b5d0b138e4841adf7c9 +0 -0
  11. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/types/cache/c9f40676a1b140ebc96dde967251686b673a9961 +0 -0
  12. package/.rpt2_cache/rpt2_3c5f4e5db6faf852c13e3cd5e0db7a72d0e60a69/types/cache/e578d3be8d82631bd5cd8272d6aa5a54ba064304 +0 -0
  13. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/code/cache/0ab301188498506f5c998a00679f29b8929634e4 +1 -0
  14. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/code/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
  15. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/code/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
  16. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/semanticDiagnostics/cache/0ab301188498506f5c998a00679f29b8929634e4 +1 -0
  17. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/semanticDiagnostics/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
  18. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/semanticDiagnostics/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
  19. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/syntacticDiagnostics/cache/0ab301188498506f5c998a00679f29b8929634e4 +1 -0
  20. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/syntacticDiagnostics/cache/1d20cee756560ed06433a2e7dba9165f54487f2a +1 -0
  21. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/syntacticDiagnostics/cache/d800d7a0e39da81c91ab9c5059068c29ebc83792 +1 -0
  22. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/types/cache/6982fa2ac1e62f4aebb1debc73977393caa0d5a4 +0 -0
  23. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/types/cache/c0f16c9111806a91c6ae4b5d0b138e4841adf7c9 +0 -0
  24. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/types/cache/c9f40676a1b140ebc96dde967251686b673a9961 +0 -0
  25. package/.rpt2_cache/rpt2_6a9ad0d85cd0ed74f9b918d742c78fdbe81d2201/types/cache/e578d3be8d82631bd5cd8272d6aa5a54ba064304 +0 -0
  26. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/code/cache/82edcf6c99dc3d5802a5a8d3dbfc69f1048b520f +1 -0
  27. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/code/cache/eb02971c7d2972b89cd15754372a7b9a0b328a30 +1 -0
  28. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/code/cache/f6056671db45d89ddf3a27b7cf6d454993cec47b +1 -0
  29. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/semanticDiagnostics/cache/82edcf6c99dc3d5802a5a8d3dbfc69f1048b520f +1 -0
  30. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/semanticDiagnostics/cache/eb02971c7d2972b89cd15754372a7b9a0b328a30 +1 -0
  31. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/semanticDiagnostics/cache/f6056671db45d89ddf3a27b7cf6d454993cec47b +1 -0
  32. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/syntacticDiagnostics/cache/82edcf6c99dc3d5802a5a8d3dbfc69f1048b520f +1 -0
  33. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/syntacticDiagnostics/cache/eb02971c7d2972b89cd15754372a7b9a0b328a30 +1 -0
  34. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/syntacticDiagnostics/cache/f6056671db45d89ddf3a27b7cf6d454993cec47b +1 -0
  35. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/types/cache/c0f16c9111806a91c6ae4b5d0b138e4841adf7c9 +0 -0
  36. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/types/cache/c9f40676a1b140ebc96dde967251686b673a9961 +0 -0
  37. package/.rpt2_cache/rpt2_cbc4c616fc0ab8863b2f9b3be2cc7ae6306d679d/types/cache/e578d3be8d82631bd5cd8272d6aa5a54ba064304 +0 -0
  38. package/BUILD.md +37 -0
  39. package/CHANGELOG.md +23 -0
  40. package/README.md +65 -84
  41. package/dist/fast-equals.cjs.js +415 -446
  42. package/dist/fast-equals.cjs.js.map +1 -1
  43. package/dist/fast-equals.esm.js +415 -446
  44. package/dist/fast-equals.esm.js.map +1 -1
  45. package/dist/fast-equals.js +415 -446
  46. package/dist/fast-equals.js.map +1 -1
  47. package/dist/fast-equals.min.js +1 -1
  48. package/dist/fast-equals.mjs +418 -0
  49. package/dist/fast-equals.mjs.map +1 -0
  50. package/index.d.ts +15 -14
  51. package/package.json +31 -47
  52. package/es/comparator.js +0 -86
  53. package/es/constants.js +0 -14
  54. package/es/index.js +0 -19
  55. package/es/utils.js +0 -333
  56. package/es-to-mjs.js +0 -14
  57. package/lib/comparator.js +0 -94
  58. package/lib/constants.js +0 -22
  59. package/lib/index.js +0 -36
  60. package/lib/utils.js +0 -386
  61. package/mjs/comparator.mjs +0 -86
  62. package/mjs/constants.mjs +0 -14
  63. package/mjs/index.mjs +0 -19
  64. package/mjs/utils.mjs +0 -333
  65. package/rollup.config.js +0 -55
  66. package/yarn-error.log +0 -8175
package/package.json CHANGED
@@ -1,58 +1,50 @@
1
1
  {
2
2
  "author": "tony_quetano@planttheidea.com",
3
- "ava": {
4
- "failFast": true,
5
- "files": [
6
- "test/*.js"
7
- ],
8
- "require": [
9
- "@babel/register"
10
- ],
11
- "sources": [
12
- "src/*.js"
13
- ],
14
- "verbose": true
15
- },
16
3
  "browser": "dist/fast-equals.js",
17
4
  "bugs": {
18
5
  "url": "https://github.com/planttheidea/fast-equals/issues"
19
6
  },
20
7
  "description": "A blazing fast equality comparison, either shallow or deep",
21
8
  "devDependencies": {
22
- "@babel/cli": "^7.2.3",
23
- "@babel/core": "^7.0.0",
24
- "@babel/preset-env": "^7.3.1",
25
- "@babel/preset-react": "^7.0.0",
26
- "@babel/register": "^7.0.0",
27
- "ava": "^1.1.0",
28
- "babel-eslint": "^10.0.1",
29
- "babel-loader": "^8.0.5",
30
- "benchee": "^1.0.3",
9
+ "@types/jest": "^24.0.12",
10
+ "@types/lodash": "^4.14.121",
11
+ "@types/node": "^11.13.8",
12
+ "@types/ramda": "^0.26.8",
13
+ "@types/react": "^16.8.3",
14
+ "@typescript-eslint/eslint-plugin": "^1.7.0",
15
+ "@typescript-eslint/parser": "^1.7.0",
16
+ "benchee": "^1.1.0",
31
17
  "cli-table2": "^0.2.0",
32
18
  "decircularize": "^1.0.0",
33
19
  "deep-eql": "^4.0.0",
34
20
  "deep-equal": "^1.0.1",
35
21
  "eslint": "^5.12.1",
36
- "eslint-config-rapid7": "^3.1.0",
37
- "eslint-friendly-formatter": "^4.0.1",
38
- "eslint-loader": "^2.1.1",
22
+ "eslint-config-airbnb": "^17.1.0",
23
+ "eslint-loader": "^2.1.2",
24
+ "eslint-plugin-import": "^2.17.2",
25
+ "eslint-plugin-jsx-a11y": "^6.2.1",
26
+ "eslint-plugin-react": "^7.12.4",
39
27
  "fast-deep-equal": "^2.0.1",
40
28
  "fs-extra": "^7.0.1",
41
29
  "html-webpack-plugin": "^3.2.0",
42
30
  "in-publish": "^2.0.0",
31
+ "jest": "^24.7.1",
43
32
  "lodash": "^4.17.11",
44
33
  "nano-equal": "^2.0.2",
45
- "nyc": "^13.1.0",
34
+ "nyc": "^14.1.0",
46
35
  "optimize-js-plugin": "^0.0.4",
47
- "react": "^16.7.0",
36
+ "react": "^16.8.6",
48
37
  "react-dom": "^16.7.0",
49
38
  "react-fast-compare": "^2.0.4",
50
39
  "rollup": "^1.1.2",
51
- "rollup-plugin-babel": "^4.3.2",
52
40
  "rollup-plugin-node-resolve": "^4.0.0",
53
41
  "rollup-plugin-terser": "^4.0.2",
42
+ "rollup-plugin-typescript2": "^0.21.0",
54
43
  "shallow-equal-fuzzy": "^0.0.2",
55
44
  "sinon": "^7.2.3",
45
+ "ts-jest": "^24.0.2",
46
+ "ts-loader": "^5.4.4",
47
+ "typescript": "^3.4.5",
56
48
  "underscore": "^1.9.1",
57
49
  "webpack": "^4.29.0",
58
50
  "webpack-cli": "^3.2.1",
@@ -75,30 +67,22 @@
75
67
  "url": "git+https://github.com/planttheidea/fast-equals.git"
76
68
  },
77
69
  "scripts": {
78
- "benchmark": "NODE_ENV=production BABEL_ENV=test babel src --out-dir lib --no-comments && node benchmark/index.js",
70
+ "benchmark": "npm run dist && node benchmark/index.js",
79
71
  "build": "NODE_ENV=production rollup -c",
80
- "clean": "npm run clean:es && npm run clean:lib && npm run clean:dist",
81
- "clean:dist": "rimraf dist",
82
- "clean:es": "rimraf es",
83
- "clean:lib": "rimraf lib",
84
- "clean:mjs": "rimraf mjs",
85
- "copy:mjs": "npm run clean:mjs && node ./es-to-mjs.js",
86
- "dev": "NODE_ENV=development webpack-dev-server --colors --progress --config=webpack/webpack.config.dev.js",
87
- "dist": "npm run clean:dist && npm run build",
88
- "lint": "NODE_ENV=test eslint src --max-warnings 0",
89
- "lint:fix": "NODE_ENV=test eslint src --fix",
72
+ "dev": "NODE_ENV=development webpack-dev-server --progress --colors --config=webpack/webpack.config.js",
73
+ "dist": "rimraf dist && npm run build",
74
+ "lint": "eslint src/*.ts",
75
+ "lint:fix": "npm run lint -- --fix",
76
+ "start": "npm run dev",
90
77
  "prepublish": "if in-publish; then npm run prepublish:compile; fi",
91
- "prepublish:compile": "npm run lint && npm run test:coverage && npm run transpile:lib && npm run transpile:es && npm run copy:mjs && npm run dist",
78
+ "prepublish:compile": "npm run lint && npm run test:coverage && npm run dist",
92
79
  "release": "release-it",
93
80
  "release:beta": "release-it --config=.release-it.beta.json",
94
- "start": "npm run dev",
95
- "test": "NODE_PATH=. BABEL_ENV=test ava",
96
- "test:coverage": "nyc npm test",
97
- "test:watch": "npm test -- --watch",
98
- "transpile:es": "npm run clean:es && BABEL_ENV=es babel src --out-dir es",
99
- "transpile:lib": "npm run clean:lib && BABEL_ENV=lib babel src --out-dir lib"
81
+ "test": "NODE_PATH=. jest",
82
+ "test:coverage": "npm test -- --coverage",
83
+ "test:watch": "npm test -- --watch"
100
84
  },
101
85
  "sideEffects": false,
102
86
  "types": "index.d.ts",
103
- "version": "1.6.3"
87
+ "version": "2.0.0"
104
88
  }
package/es/comparator.js 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/es/constants.js 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/es/index.js 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
- };
package/es/utils.js DELETED
@@ -1,333 +0,0 @@
1
- // constants
2
- import { HAS_WEAKSET_SUPPORT } from './constants';
3
- var keys = Object.keys;
4
- /**
5
- * @function addObjectToCache
6
- *
7
- * @description
8
- * add object to cache if it is indeed an object
9
- *
10
- * @param {any} object the object to potentially add to the cache
11
- * @param {Object|WeakSet} cache the cache to add to
12
- * @returns {void}
13
- */
14
-
15
- export var addObjectToCache = function addObjectToCache(object, cache) {
16
- return object && typeof object === 'object' && cache.add(object);
17
- };
18
- /**
19
- *
20
- * @param {Array<Array<any>>} pairs the pairs to check in
21
- * @param {Array<any>} pairToMatch the pair to check if exists
22
- * @param {function} isEqual the equality comparator
23
- * @param {any} meta the meta item to pass through
24
- * @returns {boolean} does the pair exist in the pairs
25
- */
26
-
27
- export var hasPair = function hasPair(pairs, pairToMatch, isEqual, meta) {
28
- var pair;
29
-
30
- for (var index = 0; index < pairs.length; index++) {
31
- pair = pairs[index];
32
-
33
- if (isEqual(pair[0], pairToMatch[0], meta) && isEqual(pair[1], pairToMatch[1], meta)) {
34
- return true;
35
- }
36
- }
37
-
38
- return false;
39
- };
40
- /**
41
- * @function hasValue
42
- *
43
- * @description
44
- * does the values include the vakye passed
45
- *
46
- * @param {Array<any>} values the values to check in
47
- * @param {any} item the value to locate
48
- * @param {function} isEqual the equality comparator
49
- * @param {any} meta the meta item to pass through
50
- * @returns {boolean} does the value exist in the values
51
- */
52
-
53
- export var hasValue = function hasValue(values, item, isEqual, meta) {
54
- for (var index = 0; index < values.length; index++) {
55
- if (isEqual(values[index], item, meta)) {
56
- return true;
57
- }
58
- }
59
-
60
- return false;
61
- };
62
- /**
63
- * @function sameValueZeroEqual
64
- *
65
- * @description
66
- * are the objects passed strictly equal or both NaN
67
- *
68
- * @param {any} objectA the object to compare against
69
- * @param {any} objectB the object to test
70
- * @returns {boolean} are the objects equal by the SameValueZero principle
71
- */
72
-
73
- export var sameValueZeroEqual = function sameValueZeroEqual(objectA, objectB) {
74
- return objectA === objectB || objectA !== objectA && objectB !== objectB;
75
- };
76
- /**
77
- * @function isPlainObject
78
- *
79
- * @description
80
- * is the object a plain object
81
- *
82
- * @param {any} object the object to test
83
- * @returns {boolean} is the object a plain object
84
- */
85
-
86
- export var isPlainObject = function isPlainObject(object) {
87
- return object.constructor === Object;
88
- };
89
- /**
90
- * @function isPromiseLike
91
- *
92
- * @description
93
- * is the object promise-like (thenable)
94
- *
95
- * @param {any} object the object to test
96
- * @returns {boolean} is the object promise-like
97
- */
98
-
99
- export var isPromiseLike = function isPromiseLike(object) {
100
- return typeof object.then === 'function';
101
- };
102
- /**
103
- * @function isReactElement
104
- *
105
- * @description
106
- * is the object passed a react element
107
- *
108
- * @param {any} object the object to test
109
- * @returns {boolean} is the object a react element
110
- */
111
-
112
- export var isReactElement = function isReactElement(object) {
113
- return !!(object.$$typeof && object._store);
114
- };
115
- /**
116
- * @function getNewCache
117
- *
118
- * @description
119
- * get a new cache object to prevent circular references
120
- *
121
- * @returns {Object|Weakset} the new cache object
122
- */
123
-
124
- export var getNewCache = function getNewCache() {
125
- return HAS_WEAKSET_SUPPORT ? new WeakSet() : Object.create({
126
- _values: [],
127
- add: function add(value) {
128
- this._values.push(value);
129
- },
130
- has: function has(value) {
131
- return !!~this._values.indexOf(value);
132
- }
133
- });
134
- };
135
- /**
136
- * @function createCircularEqual
137
- *
138
- * @description
139
- * create a custom isEqual handler specific to circular objects
140
- *
141
- * @param {funtion} [isEqual] the isEqual comparator to use instead of isDeepEqual
142
- * @returns {function(any, any): boolean}
143
- */
144
-
145
- export var createCircularEqual = function createCircularEqual(isEqual) {
146
- return function (isDeepEqual) {
147
- var comparator = isEqual || isDeepEqual;
148
- return function (objectA, objectB, cache) {
149
- if (cache === void 0) {
150
- cache = getNewCache();
151
- }
152
-
153
- var cacheHasA = cache.has(objectA);
154
- var cacheHasB = cache.has(objectB);
155
-
156
- if (cacheHasA || cacheHasB) {
157
- return cacheHasA && cacheHasB;
158
- }
159
-
160
- addObjectToCache(objectA, cache);
161
- addObjectToCache(objectB, cache);
162
- return comparator(objectA, objectB, cache);
163
- };
164
- };
165
- };
166
- /**
167
- * @function toPairs
168
- *
169
- * @param {Map} map the map to convert to [key, value] pairs (entries)
170
- * @returns {Array<Array<*>>} the [key, value] pairs
171
- */
172
-
173
- export var toPairs = function toPairs(map) {
174
- var pairs = [];
175
- map.forEach(function (value, key) {
176
- return pairs.push([key, value]);
177
- });
178
- return pairs;
179
- };
180
- /**
181
- * @function toValues
182
- *
183
- * @param {Set} set the set to convert to values
184
- * @returns {Array<*>} the values
185
- */
186
-
187
- export var toValues = function toValues(set) {
188
- var values = [];
189
- set.forEach(function (value) {
190
- return values.push(value);
191
- });
192
- return values;
193
- };
194
- /**
195
- * @function areArraysEqual
196
- *
197
- * @description
198
- * are the arrays equal in value
199
- *
200
- * @param {Array<any>} arrayA the array to test
201
- * @param {Array<any>} arrayB the array to test against
202
- * @param {function} isEqual the comparator to determine equality
203
- * @param {any} meta the meta object to pass through
204
- * @returns {boolean} are the arrays equal
205
- */
206
-
207
- export var areArraysEqual = function areArraysEqual(arrayA, arrayB, isEqual, meta) {
208
- if (arrayA.length !== arrayB.length) {
209
- return false;
210
- }
211
-
212
- for (var index = 0; index < arrayA.length; index++) {
213
- if (!isEqual(arrayA[index], arrayB[index], meta)) {
214
- return false;
215
- }
216
- }
217
-
218
- return true;
219
- };
220
- /**
221
- * @function areMapsEqual
222
- *
223
- * @description
224
- * are the maps equal in value
225
- *
226
- * @param {Map} mapA the map to test
227
- * @param {Map} mapB the map to test against
228
- * @param {function} isEqual the comparator to determine equality
229
- * @param {any} meta the meta map to pass through
230
- * @returns {boolean} are the maps equal
231
- */
232
-
233
- export var areMapsEqual = function areMapsEqual(mapA, mapB, isEqual, meta) {
234
- if (mapA.size !== mapB.size) {
235
- return false;
236
- }
237
-
238
- var pairsA = toPairs(mapA);
239
- var pairsB = toPairs(mapB);
240
-
241
- for (var index = 0; index < pairsA.length; index++) {
242
- if (!hasPair(pairsB, pairsA[index], isEqual, meta) || !hasPair(pairsA, pairsB[index], isEqual, meta)) {
243
- return false;
244
- }
245
- }
246
-
247
- return true;
248
- };
249
- /**
250
- * @function areObjectsEqual
251
- *
252
- * @description
253
- * are the objects equal in value
254
- *
255
- * @param {Object} objectA the object to test
256
- * @param {Object} objectB the object to test against
257
- * @param {function} isEqual the comparator to determine equality
258
- * @param {any} meta the meta object to pass through
259
- * @returns {boolean} are the objects equal
260
- */
261
-
262
- export var areObjectsEqual = function areObjectsEqual(objectA, objectB, isEqual, meta) {
263
- var keysA = keys(objectA);
264
- var keysB = keys(objectB);
265
-
266
- if (keysA.length !== keysB.length) {
267
- return false;
268
- }
269
-
270
- var key;
271
-
272
- for (var index = 0; index < keysA.length; index++) {
273
- key = keysA[index];
274
-
275
- if (!hasValue(keysB, key, sameValueZeroEqual)) {
276
- return false;
277
- } // if a react element, ignore the "_owner" key because its not necessary for equality comparisons
278
-
279
-
280
- if (key === '_owner' && isReactElement(objectA) && isReactElement(objectB)) {
281
- continue;
282
- }
283
-
284
- if (!isEqual(objectA[key], objectB[key], meta)) {
285
- return false;
286
- }
287
- }
288
-
289
- return true;
290
- };
291
- /**
292
- * @function areRegExpsEqual
293
- *
294
- * @description
295
- * are the regExps equal in value
296
- *
297
- * @param {RegExp} regExpA the regExp to test
298
- * @param {RegExp} regExpB the regExp to test agains
299
- * @returns {boolean} are the regExps equal
300
- */
301
-
302
- export var areRegExpsEqual = function areRegExpsEqual(regExpA, regExpB) {
303
- 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;
304
- };
305
- /**
306
- * @function areSetsEqual
307
- *
308
- * @description
309
- * are the sets equal in value
310
- *
311
- * @param {Set} setA the set to test
312
- * @param {Set} setB the set to test against
313
- * @param {function} isEqual the comparator to determine equality
314
- * @param {any} meta the meta set to pass through
315
- * @returns {boolean} are the sets equal
316
- */
317
-
318
- export var areSetsEqual = function areSetsEqual(setA, setB, isEqual, meta) {
319
- if (setA.size !== setB.size) {
320
- return false;
321
- }
322
-
323
- var valuesA = toValues(setA);
324
- var valuesB = toValues(setB);
325
-
326
- for (var index = 0; index < valuesA.length; index++) {
327
- if (!hasValue(valuesB, valuesA[index], isEqual, meta) || !hasValue(valuesA, valuesB[index], isEqual, meta)) {
328
- return false;
329
- }
330
- }
331
-
332
- return true;
333
- };
package/es-to-mjs.js DELETED
@@ -1,14 +0,0 @@
1
- const fs = require('fs-extra');
2
- const path = require('path');
3
-
4
- const ES_DIRECTORY = path.join(__dirname, 'es');
5
- const MJS_DIRECTORY = path.join(__dirname, 'mjs');
6
-
7
- fs.readdirSync(ES_DIRECTORY).forEach((file) => {
8
- const fullPathJsFilename = path.resolve(ES_DIRECTORY, file);
9
- const fullPathMjsFilename = path.resolve(MJS_DIRECTORY, `${file.slice(0, -3)}.mjs`);
10
-
11
- fs.copySync(fullPathJsFilename, fullPathMjsFilename);
12
-
13
- console.log(`es/${file} -> mjs/${file.slice(0, -3)}.mjs`);
14
- });
package/lib/comparator.js DELETED
@@ -1,94 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports["default"] = void 0;
5
-
6
- var _constants = require("./constants");
7
-
8
- var _utils = require("./utils");
9
-
10
- // constants
11
- // utils
12
- var isArray = Array.isArray;
13
-
14
- var createComparator = function createComparator(createIsEqual) {
15
- // eslint-disable-next-line no-use-before-define
16
- var isEqual = typeof createIsEqual === 'function' ? createIsEqual(comparator) : comparator;
17
- /**
18
- * @function comparator
19
- *
20
- * @description
21
- * compare the value of the two objects and return true if they are equivalent in values
22
- *
23
- * @param {any} objectA the object to test against
24
- * @param {any} objectB the object to test
25
- * @param {any} [meta] an optional meta object that is passed through to all equality test calls
26
- * @returns {boolean} are objectA and objectB equivalent in value
27
- */
28
-
29
- function comparator(objectA, objectB, meta) {
30
- if ((0, _utils.sameValueZeroEqual)(objectA, objectB)) {
31
- return true;
32
- }
33
-
34
- var typeOfA = typeof objectA;
35
-
36
- if (typeOfA !== typeof objectB || typeOfA !== 'object' || !objectA || !objectB) {
37
- return false;
38
- }
39
-
40
- if ((0, _utils.isPlainObject)(objectA) && (0, _utils.isPlainObject)(objectB)) {
41
- return (0, _utils.areObjectsEqual)(objectA, objectB, isEqual, meta);
42
- }
43
-
44
- var arrayA = isArray(objectA);
45
- var arrayB = isArray(objectB);
46
-
47
- if (arrayA || arrayB) {
48
- return arrayA === arrayB && (0, _utils.areArraysEqual)(objectA, objectB, isEqual, meta);
49
- }
50
-
51
- var dateA = objectA instanceof Date;
52
- var dateB = objectB instanceof Date;
53
-
54
- if (dateA || dateB) {
55
- return dateA === dateB && (0, _utils.sameValueZeroEqual)(objectA.getTime(), objectB.getTime());
56
- }
57
-
58
- var regexpA = objectA instanceof RegExp;
59
- var regexpB = objectB instanceof RegExp;
60
-
61
- if (regexpA || regexpB) {
62
- return regexpA === regexpB && (0, _utils.areRegExpsEqual)(objectA, objectB);
63
- }
64
-
65
- if ((0, _utils.isPromiseLike)(objectA) || (0, _utils.isPromiseLike)(objectB)) {
66
- return objectA === objectB;
67
- }
68
-
69
- if (_constants.HAS_MAP_SUPPORT) {
70
- var mapA = objectA instanceof Map;
71
- var mapB = objectB instanceof Map;
72
-
73
- if (mapA || mapB) {
74
- return mapA === mapB && (0, _utils.areMapsEqual)(objectA, objectB, isEqual, meta);
75
- }
76
- }
77
-
78
- if (_constants.HAS_SET_SUPPORT) {
79
- var setA = objectA instanceof Set;
80
- var setB = objectB instanceof Set;
81
-
82
- if (setA || setB) {
83
- return setA === setB && (0, _utils.areSetsEqual)(objectA, objectB, isEqual, meta);
84
- }
85
- }
86
-
87
- return (0, _utils.areObjectsEqual)(objectA, objectB, isEqual, meta);
88
- }
89
-
90
- return comparator;
91
- };
92
-
93
- var _default = createComparator;
94
- exports["default"] = _default;