{"author":{"name":"tony_quetano@planttheidea.com"},"browser":"dist/umd/index.js","bugs":{"url":"https://github.com/planttheidea/fast-equals/issues"},"description":"A blazing fast equality comparison, either shallow or deep","devDependencies":{"@rollup/plugin-commonjs":"^24.0.0","@rollup/plugin-node-resolve":"^15.0.1","@rollup/plugin-replace":"^5.0.2","@rollup/plugin-terser":"^0.4.0","@rollup/plugin-typescript":"^11.0.0","@types/jest":"^29.2.5","@types/lodash":"^4.14.184","@types/node":"^18.14.0","@types/ramda":"^0.28.23","@types/react":"^18.0.28","@types/react-dom":"^18.0.11","@typescript-eslint/eslint-plugin":"^5.52.0","@typescript-eslint/parser":"^5.52.0","decircularize":"^1.0.0","deep-eql":"^4.1.0","deep-equal":"^2.0.5","eslint":"^8.34.0","eslint-friendly-formatter":"^4.0.1","eslint-webpack-plugin":"^4.0.0","fast-deep-equal":"^3.1.3","html-webpack-plugin":"^5.5.0","in-publish":"^2.0.0","jest":"^29.4.3","jest-environment-jsdom":"^29.4.3","jest-expect-message":"^1.1.3","lodash":"^4.17.21","nano-equal":"^2.0.2","prettier":"^2.8.4","react":"^18.2.0","react-dom":"^18.2.0","react-fast-compare":"^3.2.0","release-it":"^15.6.0","rollup":"^3.16.0","shallow-equal-fuzzy":"^0.0.2","tinybench":"^2.3.1","ts-jest":"^29.0.3","ts-loader":"^9.4.2","typescript":"^4.9.5","underscore":"^1.13.4","webpack":"^5.75.0","webpack-cli":"^5.0.1","webpack-dev-server":"^4.11.1"},"exports":{".":{"import":{"types":"./dist/esm/types/index.d.ts","default":"./dist/esm/index.mjs"},"require":{"types":"./dist/cjs/types/index.d.ts","default":"./dist/cjs/index.cjs"},"default":{"types":"./dist/umd/types/index.d.ts","default":"./dist/umd/index.js"}}},"homepage":"https://github.com/planttheidea/fast-equals#readme","keywords":["fast","equal","equals","deep-equal","equivalent"],"license":"MIT","main":"dist/cjs/index.cjs","module":"dist/esm/index.mjs","name":"fast-equals","repository":{"type":"git","url":"git+https://github.com/planttheidea/fast-equals.git"},"scripts":{"benchmark":"npm run build:esm && node benchmark/index.js","build":"npm run build:esm && npm run build:cjs && npm run build:umd && npm run build:min","build:cjs":"rimraf dist/cjs && NODE_ENV=production rollup -c build/rollup/config.cjs.js && tsc -p ./build/tsconfig/cjs.json","build:esm":"rimraf dist/esm && NODE_ENV=production rollup -c build/rollup/config.esm.js && tsc -p ./build/tsconfig/esm.json","build:min":"rimraf dist/min && NODE_ENV=production rollup -c build/rollup/config.min.js && tsc -p ./build/tsconfig/min.json","build:umd":"rimraf dist/umd && NODE_ENV=production rollup -c build/rollup/config.umd.js && tsc -p ./build/tsconfig/umd.json","dev":"NODE_ENV=development webpack serve --progress --config=build/webpack.config.js","dist":"rimraf dist && npm run build","format":"prettier **/*.ts --write","lint":"eslint src/*.ts","lint:fix":"npm run lint -- --fix","start":"npm run dev","prepublish":"if in-publish; then npm run prepublish:compile; fi","release":"release-it","release:beta":"release-it --config=.release-it.beta.json","release:scripts":"npm run typecheck && npm run lint && npm run test && npm run dist","test":"NODE_PATH=. jest","test:coverage":"rimraf coverage && npm test -- --coverage","test:watch":"npm test -- --watch","typecheck":"tsc --noEmit"},"sideEffects":false,"type":"module","types":"./index.d.ts","version":"5.0.0-beta.2","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. It has no dependencies, and is ~1.27kB when minified and gzipped.\n\nUnlike most equality validation libraries, the following types are handled out-of-the-box:\n\n- `NaN`\n- `Date` objects\n- `RegExp` objects\n- `Map` / `Set` iterables\n- `Promise` objects\n- `react` elements\n\nStarting with version `1.5.0`, circular objects are supported for both deep and shallow equality (see [`circularDeepEqual`](#circulardeepequal) and [`circularShallowEqual`](#circularshallowequal)). You can also create a custom nested comparator, for specific scenarios ([see below](#createcustomequal)).\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 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 BaseCircular extends Pick<WeakMap<any, any>, 'delete' | 'get'> {\n  set(key: object, value: any): any;\n}\n\ninterface DefaultState<Meta> {\n  readonly cache: undefined | BaseCircular;\n  readonly equals: InternalEqualityComparator<Meta>;\n  meta: Meta;\n  readonly strict: boolean;\n}\n\ntype EqualityComparator<Meta> = <A, B>(\n  a: A,\n  b: B,\n  state: State<Meta>,\n) => boolean;\n\ninterface CreateComparatorCreatorOptions<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}\n\ninterface CustomEqualCreatorOptions<Meta> {\n  circular?: boolean;\n  comparator?: EqualityComparator<Meta>;\n  createCustomConfig?: CreateCustomComparatorConfig<Meta>;\n  createInternalComparator?: <Meta>(\n    compare: EqualityComparator<Meta>,\n  ) => InternalEqualityComparator<Meta>;\n  createState?: CreateState<Meta>;\n  strict?: boolean;\n}\n\nfunction createCustomEqual(\n  options: CustomEqualCreatorOptions<Meta>,\n): <A, B>(a: A, b: B, metaOverride?: Meta) => 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 i7-8650U Ubuntu Linux laptop with 24GB of memory using NodeJS version `12.19.1`, 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|                            | Operations / second |\n| -------------------------- | ------------------- |\n| **fast-equals**            | **153,880**         |\n| fast-deep-equal            | 144,035             |\n| react-fast-compare         | 130,324             |\n| nano-equal                 | 104,624             |\n| **fast-equals (circular)** | **97,610**          |\n| shallow-equal-fuzzy        | 83,946              |\n| underscore.isEqual         | 47,370              |\n| lodash.isEqual             | 25,053              |\n| deep-eql                   | 22,146              |\n| assert.deepStrictEqual     | 532                 |\n| deep-equal                 | 209                 |\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- `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","readmeFilename":"README.md","gitHead":"9f4878f48de7170e57c42bf9c15506b55794c709","_id":"fast-equals@5.0.0-beta.2","_nodeVersion":"16.14.2","_npmVersion":"8.7.0","dist":{"integrity":"sha512-SOLZwK0ZDd8r440fILto+xqs0ZR3ar7a81CY7buYkeOaawkhi2maDa9l/7fKD7ivpMPVRAeWEOmkzf6oFUwZ9A==","shasum":"75333c7bcbd68590c2216ff2a82a9b4c1138ee8d","tarball":"http://registry-npm.ywwl.com/fast-equals/download/fast-equals-5.0.0-beta.2.tgz","fileCount":59,"unpackedSize":269163,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC4Dx5C3ALB//Lb6Seqss3alG/l1Z1/2KwTrFmUxAWO9AIhANATM0hsWehD3Rf3k99YJC+2S+qkx9SyaLLsA5YddZ/g"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj8g+DACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrWoA/+MaQfQ1eB978Xa7giOg9LPc64vg5mSb9r1n5v5v0d4yCae/KF\r\nAbsOawqFW1Ba+LvjJbb1lFiTkCZYSXpZ/uXTYsFTGk8+a3s/4+cnZXYbbfxT\r\nuEvE8Y+uaREkQF/eIDgLEO4E8rh903pYfvN5Nsl5C8B4OB6AfRcl3fkX8QqD\r\nku/Vqs/g/UIV/zeordCnjGGDwTJS1ZCZ1WWRTsnUSCRwD78raGdfPiwwe2zf\r\nzL9/0JcAawjLmP2/Tn9mbek5qcmspeEa0DXUMX6tFbB647iK6ssr+2NsY9IQ\r\n/WlvYPbHtNlPt6eYTooE2Xgv+65/+5hpb/e7KC5fKzhdEbZweEPAJtYkNTOL\r\nr4yn0VX7B6jEMdzcMnSV66MJ403IG3RwAALmwWhnUZp059JNEdzAXSsP7Uto\r\n8ya83FGnGCocSWncE+ZwtbQBbaajR3T+74oxRiCuNaWaDE/vn58K5tqrgV8s\r\nocpk0tcxPHHqjyP0ZMmGjWk1HGOS4dMW+nIANw8GlleXYY+fYvSut2ZMK2wa\r\n7BeYRthW6JvnTPiHF/qaZY2VoAAem91MHBjLY03K8x1IpPBy1c/05O7N1BMk\r\n9yUe2/1G3ngONq6cmhBv4zZbisQ9LtgM0DfiUaSv24YebKQi15sIGWBX1bnJ\r\n1krNN9HPOzvZmcD07zgLg3CPF6PbABUS3Wc=\r\n=8BoX\r\n-----END PGP SIGNATURE-----\r\n","size":53974,"noattachment":false,"key":"/fast-equals/-/fast-equals-5.0.0-beta.2.tgz"},"_npmUser":{"name":"planttheidea","email":"tony.quetano@planttheidea.com"},"directories":{},"maintainers":[{"name":"planttheidea","email":"tony.quetano@planttheidea.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fast-equals_5.0.0-beta.2_1676808067180_0.9404781574075962"},"_hasShrinkwrap":false,"publish_time":1676808067330,"_cnpm_publish_time":1676808067330,"dist-tags":{"latest":"6.2.2","latest-v5":"5.4.5","next":"6.0.0-rc.1"}}