{"author":{"name":"tony_quetano@planttheidea.com"},"ava":{"babel":"inherit","failFast":true,"files":["test/*.js"],"require":["babel-register"],"source":["src/*.js"],"verbose":true},"bugs":{"url":"https://github.com/planttheidea/fast-equals/issues"},"description":"A blazing fast equality comparison, either shallow or deep","devDependencies":{"ava":"^0.25.0","babel-cli":"^6.26.0","babel-eslint":"^8.2.6","babel-loader":"^7.1.5","babel-preset-env":"^1.7.0","babel-preset-minify":"^0.4.3","babel-preset-react":"^6.24.1","babel-preset-stage-2":"^6.24.1","babel-register":"^6.26.0","benchmark":"^2.1.4","decircularize":"^1.0.0","deep-eql":"^3.0.1","deep-equal":"^1.0.1","eslint":"^5.3.0","eslint-config-rapid7":"^3.0.4","eslint-friendly-formatter":"^4.0.1","eslint-loader":"^2.1.0","fast-deep-equal":"^2.0.1","fs-extra":"^7.0.0","html-webpack-plugin":"^3.2.0","in-publish":"^2.0.0","lodash":"^4.17.10","nano-equal":"^2.0.2","nyc":"^12.0.2","optimize-js-plugin":"^0.0.4","react":"^16.4.2","react-dom":"^16.4.2","react-fast-compare":"^2.0.1","rollup":"^0.64.1","rollup-plugin-babel":"^3.0.7","rollup-plugin-node-resolve":"^3.3.0","rollup-plugin-uglify":"^4.0.0","shallow-equal-fuzzy":"^0.0.2","sinon":"^6.1.5","underscore":"^1.9.1","webpack":"^4.16.5","webpack-cli":"^3.1.0","webpack-dev-server":"^3.1.5"},"homepage":"https://github.com/planttheidea/fast-equals#readme","keywords":["fast","equal","equals","deep-equal","equivalent"],"license":"MIT","main":"lib/index.js","types":"index.d.ts","module":"es/index.js","name":"fast-equals","repository":{"type":"git","url":"git+https://github.com/planttheidea/fast-equals.git"},"scripts":{"benchmark":"NODE_ENV=production BABEL_ENV=test babel src --out-dir lib --no-comments && node benchmark/index.js","build":"NODE_ENV=production rollup -c","clean":"npm run clean:es && npm run clean:lib && npm run clean:dist","clean:dist":"rimraf dist","clean:es":"rimraf es","clean:lib":"rimraf lib","clean:mjs":"rimraf mjs","copy:mjs":"npm run clean:mjs && node ./es-to-mjs.js","dev":"NODE_ENV=development webpack-dev-server --colors --progress --config=webpack/webpack.config.dev.js","dist":"npm run clean:dist && npm run build","lint":"NODE_ENV=test eslint src --max-warnings 0","lint:fix":"NODE_ENV=test eslint src --fix","prepublish":"if in-publish; then npm run prepublish:compile; fi","prepublish:compile":"npm run lint && npm run test:coverage && npm run transpile:lib && npm run transpile:es && npm run copy:mjs && npm run dist","start":"npm run dev","test":"NODE_PATH=. BABEL_ENV=test ava","test:coverage":"nyc npm test","test:watch":"npm test -- --watch","transpile:es":"npm run clean:es && BABEL_ENV=es babel src --out-dir es","transpile:lib":"npm run clean:lib && BABEL_ENV=lib babel src --out-dir lib"},"version":"1.6.0","gitHead":"b53113c7af5d84ec009f422fbfdeb48403b337ea","_id":"fast-equals@1.6.0","_npmVersion":"6.3.0","_nodeVersion":"8.11.3","_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"dist":{"integrity":"sha512-6GjIQ6KR7Q/TzDJpXv2/AEUULEQoP1LQSgLE23DysxFmZUtNDVAoqJzqgwieJdGrZ0aptKoaansRNpssRzqiEQ==","shasum":"171c5dbcae34761b337d839105a11c5e91a4fe3b","tarball":"http://registry-npm.ywwl.com/fast-equals/download/fast-equals-1.6.0.tgz","fileCount":23,"unpackedSize":383298,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbbMQwCRA9TVsSAnZWagAA88IQAIDaYJYvksQsJViDSAIG\nLNHoLj3vLGKFKXmXEBXCeFleXU89RavnsnNiQfpasqUAqvDjmn49p37sJLd0\nGa8Na/GdUpLid0G1/ld/eywEk8wrqyhcpwXNnusbtdJ3BCSDxpVoZaQO/HIs\nL064OqMH/FfiVAs0R30XHwjMV0n8eCWf8vzXA9QvVSdPsvv0q4kyNuZKEnl6\neXqS8ZxuDrBkr/adYkHOdpr4gT2L5KwjBgKO2B3iV6+8dmITAfi3BY3xLZ2b\nY2/Y1E0unNc6ZIwMECl6cFvsT+hUJKAm/E/DNkXC6ct2Lo3T+2vCEB5lIa10\nz9FhKSKShwBsvyk/Y8p80yZfG8ewdM2H9OdOarymPJlTyA9pg2Bqi60QEI41\nLCEE470QHRp0p0VNTrDQ4KEXuPR57gkClg/ArlN2SyAHBh5ZSKqSSrwZre5G\nuxfiIOC8IEcHw9GBTDhqSOeZTGvY5SBWaa7rHmYKhXR6ml7+XQUQ0QSWchJg\nHh7MKviwb3dwSZX1dwdYMS8QiF3iPgta8/ytl1UTNgXkyL4fTHIt4JDS9gA9\ncY6HyKkWfqnX19NBA/2vu16N2GUPPhVQ5vJGVykD1WqDKjEGjFT3pIWvHd3h\n3YcGZWzTXZQNOLGdA3rKRn4g8rmjqEcPn5PmlT2kK1aMFqv5zh6Op6IGHFY/\n+/xa\r\n=KRVJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCQzPT7V03q7LL/r3hVnlcFayfS457NKYd7MPJN/L7xmQIhAIGZN86ajXIMTNVYuNW3W3h1ufeCRJNHpndDBEDMy41k"}],"size":93206,"noattachment":false,"key":"/fast-equals/-/fast-equals-1.6.0.tgz"},"maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fast-equals_1.6.0_1533854768011_0.5128170271360755"},"_hasShrinkwrap":false,"readme":"# fast-equals\n\n<img src=\"https://img.shields.io/badge/build-passing-brightgreen.svg\"/>\n<img src=\"https://img.shields.io/badge/coverage-100%25-brightgreen.svg\"/>\n<img src=\"https://img.shields.io/badge/license-MIT-blue.svg\"/>\n\nPerform [blazing fast](#benchmarks) equality comparisons (either deep or shallow) on two objects passed, while also maintaining a high degree of flexibility for various implementation use-cases. It has no dependencies, and is ~1.8kB when minified and gzipped.\n\nThe following types are handled out-of-the-box:\n\n- Plain objects (including `react` elements and `Arguments`)\n- Arrays\n- Typed Arrays\n- `Date` objects\n- `RegExp` objects\n- `Map` / `Set` iterables\n- `Promise` objects\n- Primitive wrappers (`new Boolean()` / `new Number()` / `new String()`)\n- Custom class instances, including subclasses of native classes\n\nMethods are available for deep, shallow, or referential equality comparison. In addition, you can opt into support for circular objects, or performing a \"strict\" comparison with unconventional property definition, or both. You can also customize any specific type comparison based on your application's use-cases.\n\n## Table of contents\n\n- [fast-equals](#fast-equals)\n  - [Table of contents](#table-of-contents)\n  - [Usage](#usage)\n    - [Specific builds](#specific-builds)\n  - [Available methods](#available-methods)\n    - [deepEqual](#deepequal)\n      - [Comparing `Map`s](#comparing-maps)\n    - [shallowEqual](#shallowequal)\n    - [sameValueZeroEqual](#samevaluezeroequal)\n    - [circularDeepEqual](#circulardeepequal)\n    - [circularShallowEqual](#circularshallowequal)\n    - [strictDeepEqual](#strictdeepequal)\n    - [strictShallowEqual](#strictshallowequal)\n    - [strictCircularDeepEqual](#strictcirculardeepequal)\n    - [strictCircularShallowEqual](#strictcircularshallowequal)\n    - [createCustomEqual](#createcustomequal)\n      - [Recipes](#recipes)\n  - [Benchmarks](#benchmarks)\n  - [Development](#development)\n\n## Usage\n\n```ts\nimport { deepEqual } from 'fast-equals';\n\nconsole.log(deepEqual({ foo: 'bar' }, { foo: 'bar' })); // true\n```\n\n### Specific builds\n\nBy default, npm should resolve the correct build of the package based on your consumption (ESM vs CommonJS). However, if you want to force use of a specific build, they can be located here:\n\n- ESM => `fast-equals/dist/esm/index.mjs`\n- CommonJS => `fast-equals/dist/cjs/index.cjs`\n- UMD => `fast-equals/dist/umd/index.js`\n- Minified UMD => `fast-equals/dist/min/index.js`\n\nIf you are having issues loading a specific build type, [please file an issue](https://github.com/planttheidea/fast-equals/issues).\n\n## Available methods\n\n### deepEqual\n\nPerforms a deep equality comparison on the two objects passed and returns a boolean representing the value equivalency of the objects.\n\n```ts\nimport { deepEqual } from 'fast-equals';\n\nconst objectA = { foo: { bar: 'baz' } };\nconst objectB = { foo: { bar: 'baz' } };\n\nconsole.log(objectA === objectB); // false\nconsole.log(deepEqual(objectA, objectB)); // true\n```\n\n#### Comparing `Map`s\n\n`Map` objects support complex keys (objects, Arrays, etc.), however [the spec for key lookups in `Map` are based on `SameZeroValue`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#key_equality). If the spec were followed for comparison, the following would always be `false`:\n\n```ts\nconst mapA = new Map([[{ foo: 'bar' }, { baz: 'quz' }]]);\nconst mapB = new Map([[{ foo: 'bar' }, { baz: 'quz' }]]);\n\ndeepEqual(mapA, mapB);\n```\n\nTo support true deep equality of all contents, `fast-equals` will perform a deep equality comparison for key and value parirs. Therefore, the above would be `true`.\n\n### shallowEqual\n\nPerforms a shallow equality comparison on the two objects passed and returns a boolean representing the value equivalency of the objects.\n\n```ts\nimport { shallowEqual } from 'fast-equals';\n\nconst nestedObject = { bar: 'baz' };\n\nconst objectA = { foo: nestedObject };\nconst objectB = { foo: nestedObject };\nconst objectC = { foo: { bar: 'baz' } };\n\nconsole.log(objectA === objectB); // false\nconsole.log(shallowEqual(objectA, objectB)); // true\nconsole.log(shallowEqual(objectA, objectC)); // false\n```\n\n### sameValueZeroEqual\n\nPerforms a [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) comparison on the two objects passed and returns a boolean representing the value equivalency of the objects. In simple terms, this means either strictly equal or both `NaN`.\n\n```ts\nimport { sameValueZeroEqual } from 'fast-equals';\n\nconst mainObject = { foo: NaN, bar: 'baz' };\n\nconst objectA = 'baz';\nconst objectB = NaN;\nconst objectC = { foo: NaN, bar: 'baz' };\n\nconsole.log(sameValueZeroEqual(mainObject.bar, objectA)); // true\nconsole.log(sameValueZeroEqual(mainObject.foo, objectB)); // true\nconsole.log(sameValueZeroEqual(mainObject, objectC)); // false\n```\n\n### circularDeepEqual\n\nPerforms the same comparison as `deepEqual` but supports circular objects. It is slower than `deepEqual`, so only use if you know circular objects are present.\n\n```ts\nfunction Circular(value) {\n  this.me = {\n    deeply: {\n      nested: {\n        reference: this,\n      },\n    },\n    value,\n  };\n}\n\nconsole.log(circularDeepEqual(new Circular('foo'), new Circular('foo'))); // true\nconsole.log(circularDeepEqual(new Circular('foo'), new Circular('bar'))); // false\n```\n\nJust as with `deepEqual`, [both keys and values are compared for deep equality](#comparing-maps).\n\n### circularShallowEqual\n\nPerforms the same comparison as `shallowequal` but supports circular objects. It is slower than `shallowEqual`, so only use if you know circular objects are present.\n\n```ts\nconst array = ['foo'];\n\narray.push(array);\n\nconsole.log(circularShallowEqual(array, ['foo', array])); // true\nconsole.log(circularShallowEqual(array, [array])); // false\n```\n\n### strictDeepEqual\n\nPerforms the same comparison as `deepEqual` but performs a strict comparison of the objects. In this includes:\n\n- Checking symbol properties\n- Checking non-enumerable properties in object comparisons\n- Checking full descriptor of properties on the object to match\n- Checking non-index properties on arrays\n- Checking non-key properties on `Map` / `Set` objects\n\n```ts\nconst array = [{ foo: 'bar' }];\nconst otherArray = [{ foo: 'bar' }];\n\narray.bar = 'baz';\notherArray.bar = 'baz';\n\nconsole.log(strictDeepEqual(array, otherArray)); // true;\nconsole.log(strictDeepEqual(array, [{ foo: 'bar' }])); // false;\n```\n\n### strictShallowEqual\n\nPerforms the same comparison as `shallowEqual` but performs a strict comparison of the objects. In this includes:\n\n- Checking non-enumerable properties in object comparisons\n- Checking full descriptor of properties on the object to match\n- Checking non-index properties on arrays\n- Checking non-key properties on `Map` / `Set` objects\n\n```ts\nconst array = ['foo'];\nconst otherArray = ['foo'];\n\narray.bar = 'baz';\notherArray.bar = 'baz';\n\nconsole.log(strictDeepEqual(array, otherArray)); // true;\nconsole.log(strictDeepEqual(array, ['foo'])); // false;\n```\n\n### strictCircularDeepEqual\n\nPerforms the same comparison as `circularDeepEqual` but performs a strict comparison of the objects. In this includes:\n\n- Checking `Symbol` properties on the object\n- Checking non-enumerable properties in object comparisons\n- Checking full descriptor of properties on the object to match\n- Checking non-index properties on arrays\n- Checking non-key properties on `Map` / `Set` objects\n\n```ts\nfunction Circular(value) {\n  this.me = {\n    deeply: {\n      nested: {\n        reference: this,\n      },\n    },\n    value,\n  };\n}\n\nconst first = new Circular('foo');\n\nObject.defineProperty(first, 'bar', {\n  enumerable: false,\n  value: 'baz',\n});\n\nconst second = new Circular('foo');\n\nObject.defineProperty(second, 'bar', {\n  enumerable: false,\n  value: 'baz',\n});\n\nconsole.log(circularDeepEqual(first, second)); // true\nconsole.log(circularDeepEqual(first, new Circular('foo'))); // false\n```\n\n### strictCircularShallowEqual\n\nPerforms the same comparison as `circularShallowEqual` but performs a strict comparison of the objects. In this includes:\n\n- Checking non-enumerable properties in object comparisons\n- Checking full descriptor of properties on the object to match\n- Checking non-index properties on arrays\n- Checking non-key properties on `Map` / `Set` objects\n\n```ts\nconst array = ['foo'];\nconst otherArray = ['foo'];\n\narray.push(array);\notherArray.push(otherArray);\n\narray.bar = 'baz';\notherArray.bar = 'baz';\n\nconsole.log(circularShallowEqual(array, otherArray)); // true\nconsole.log(circularShallowEqual(array, ['foo', array])); // false\n```\n\n### createCustomEqual\n\nCreates a custom equality comparator that will be used on nested values in the object. Unlike `deepEqual` and `shallowEqual`, this is a factory method that receives the default options used internally, and allows you to override the defaults as needed. This is generally for extreme edge-cases, or supporting legacy environments.\n\nThe signature is as follows:\n\n```ts\ninterface Cache<Key extends object, Value> {\n  delete(key: Key): boolean;\n  get(key: Key): Value | undefined;\n  set(key: Key, value: any): any;\n}\n\ninterface ComparatorConfig<Meta> {\n  areArraysEqual: TypeEqualityComparator<any[], Meta>;\n  areDatesEqual: TypeEqualityComparator<Date, Meta>;\n  areMapsEqual: TypeEqualityComparator<Map<any, any>, Meta>;\n  areObjectsEqual: TypeEqualityComparator<Record<string, any>, Meta>;\n  arePrimitiveWrappersEqual: TypeEqualityComparator<\n    boolean | string | number,\n    Meta\n  >;\n  areRegExpsEqual: TypeEqualityComparator<RegExp, Meta>;\n  areSetsEqual: TypeEqualityComparator<Set<any>, Meta>;\n  areTypedArraysEqual: TypeEqualityComparatory<TypedArray, Meta>;\n}\n\nfunction createCustomEqual<Meta>(options: {\n  circular?: boolean;\n  createCustomConfig?: (\n    defaultConfig: ComparatorConfig<Meta>,\n  ) => Partial<ComparatorConfig<Meta>>;\n  createInternalComparator?: (\n    compare: <A, B>(a: A, b: B, state: State<Meta>) => boolean,\n  ) => (\n    a: any,\n    b: any,\n    indexOrKeyA: any,\n    indexOrKeyB: any,\n    parentA: any,\n    parentB: any,\n    state: State<Meta>,\n  ) => boolean;\n  createState?: () => { cache?: Cache; meta?: Meta };\n  strict?: boolean;\n}): <A, B>(a: A, b: B) => boolean;\n```\n\nCreate a custom equality comparator. This allows complete control over building a bespoke equality method, in case your use-case requires a higher degree of performance, legacy environment support, or any other non-standard usage. The [recipes](#recipes) provide examples of use in different use-cases, but if you have a specific goal in mind and would like assistance feel free to [file an issue](https://github.com/planttheidea/fast-equals/issues).\n\n_**NOTE**: `Map` implementations compare equality for both keys and value. When using a custom comparator and comparing equality of the keys, the iteration index is provided as both `indexOrKeyA` and `indexOrKeyB` to help use-cases where ordering of keys matters to equality._\n\n#### Recipes\n\nSome recipes have been created to provide examples of use-cases for `createCustomEqual`. Even if not directly applicable to the problem you are solving, they can offer guidance of how to structure your solution.\n\n- [Legacy environment support for `RegExp` comparators](./recipes/legacy-regexp-support.md)\n- [Explicit property check](./recipes/explicit-property-check.md)\n- [Using `meta` in comparison](./recipes//using-meta-in-comparison.md)\n- [Comparing non-standard properties](./recipes/non-standard-properties.md)\n- [Strict property descriptor comparison](./recipes/strict-property-descriptor-check.md)\n- [Legacy environment support for circualr equal comparators](./recipes/legacy-circular-equal-support.md)\n\n## Benchmarks\n\nAll benchmarks were performed on an i9-11900H Ubuntu Linux 22.04 laptop with 64GB of memory using NodeJS version `16.14.2`, and are based on averages of running comparisons based deep equality on the following object types:\n\n- Primitives (`String`, `Number`, `null`, `undefined`)\n- `Function`\n- `Object`\n- `Array`\n- `Date`\n- `RegExp`\n- `react` elements\n- A mixed object with a combination of all the above types\n\n```bash\nTesting mixed objects equal...\n┌─────────┬─────────────────────────────────┬────────────────┐\n│ (index) │             Package             │    Ops/sec     │\n├─────────┼─────────────────────────────────┼────────────────┤\n│    0    │          'fast-equals'          │ 1249567.730326 │\n│    1    │        'fast-deep-equal'        │ 1182463.587514 │\n│    2    │      'react-fast-compare'       │ 1152487.319161 │\n│    3    │      'shallow-equal-fuzzy'      │ 1092360.712389 │\n│    4    │    'fast-equals (circular)'     │  676669.92003  │\n│    5    │      'underscore.isEqual'       │ 429430.837497  │\n│    6    │        'lodash.isEqual'         │ 237915.684734  │\n│    7    │     'fast-equals (strict)'      │  181386.38032  │\n│    8    │ 'fast-equals (strict circular)' │ 156779.745875  │\n│    9    │           'deep-eql'            │ 139155.099209  │\n│   10    │          'deep-equal'           │  1026.527229   │\n└─────────┴─────────────────────────────────┴────────────────┘\n\nTesting mixed objects not equal...\n┌─────────┬─────────────────────────────────┬────────────────┐\n│ (index) │             Package             │    Ops/sec     │\n├─────────┼─────────────────────────────────┼────────────────┤\n│    0    │          'fast-equals'          │ 3255824.097237 │\n│    1    │      'react-fast-compare'       │ 2654721.726058 │\n│    2    │        'fast-deep-equal'        │ 2582218.974752 │\n│    3    │    'fast-equals (circular)'     │ 2474303.26566  │\n│    4    │     'fast-equals (strict)'      │ 1088066.604881 │\n│    5    │ 'fast-equals (strict circular)' │ 949253.614181  │\n│    6    │          'nano-equal'           │ 939170.554148  │\n│    7    │      'underscore.isEqual'       │ 738852.197879  │\n│    8    │        'lodash.isEqual'         │ 307306.622212  │\n│    9    │           'deep-eql'            │ 156250.110401  │\n│   10    │    'assert.deepStrictEqual'     │  22839.454561  │\n│   11    │          'deep-equal'           │   4034.45114   │\n└─────────┴─────────────────────────────────┴────────────────┘\n```\n\nCaveats that impact the benchmark (and accuracy of comparison):\n\n- `Map`s, `Promise`s, and `Set`s were excluded from the benchmark entirely because no library other than `deep-eql` fully supported their comparison\n- `fast-deep-equal`, `react-fast-compare` and `nano-equal` throw on objects with `null` as prototype (`Object.create(null)`)\n- `assert.deepStrictEqual` does not support `NaN` or `SameValueZero` equality for dates\n- `deep-eql` does not support `SameValueZero` equality for zero equality (positive and negative zero are not equal)\n- `deep-equal` does not support `NaN` and does not strictly compare object type, or date / regexp values, nor uses `SameValueZero` equality for dates\n- `fast-deep-equal` does not support `NaN` or `SameValueZero` equality for dates\n- `nano-equal` does not strictly compare object property structure, array length, or object type, nor `SameValueZero` equality for dates\n- `react-fast-compare` does not support `NaN` or `SameValueZero` equality for dates, and does not compare `function` equality\n- `shallow-equal-fuzzy` does not strictly compare object type or regexp values, nor `SameValueZero` equality for dates\n- `underscore.isEqual` does not support `SameValueZero` equality for primitives or dates\n\nAll of these have the potential of inflating the respective library's numbers in comparison to `fast-equals`, but it was the closest apples-to-apples comparison I could create of a reasonable sample size. It should be noted that `react` elements can be circular objects, however simple elements are not; I kept the `react` comparison very basic to allow it to be included.\n\n## Development\n\nStandard practice, clone the repo and `npm i` to get the dependencies. The following npm scripts are available:\n\n- benchmark => run benchmark tests against other equality libraries\n- build => build `main`, `module`, and `browser` distributables with `rollup`\n- clean => run `rimraf` on the `dist` folder\n- dev => start webpack playground App\n- dist => run `build`\n- lint => run ESLint on all files in `src` folder (also runs on `dev` script)\n- lint:fix => run `lint` script, but with auto-fixer\n- prepublish:compile => run `lint`, `test:coverage`, `transpile:lib`, `transpile:es`, and `dist` scripts\n- start => run `dev`\n- test => run AVA with NODE_ENV=test on all files in `test` folder\n- test:coverage => run same script as `test` with code coverage calculation via `nyc`\n- test:watch => run same script as `test` but keep persistent watcher\n","publish_time":1533854768090,"_cnpm_publish_time":1533854768090,"dist-tags":{"latest":"6.2.2","latest-v5":"5.4.5","next":"6.0.0-rc.1"}}