"files" instead of exclude with .npmignore (Thanks @43081j).yarn folderunknownTagComparators in custom configuration (thanks to @mrcljx for the idea)NodeNext module resolutionsrc code in index.d.ts by flattening types in fileMap / Set) equality comparisonsdequal and dequal/lite in benchmark comparisonsRe-release of 5.1.0 with correct pre-release setup.
DO NOT USE
This was an accidental pre-release when cleaning up release setup.
Function instance comparisons (resolves #118)URL instance comparisons (resolves #121)Error instance comparisons (resolves #123)Number instance comparisons (resolves #112)assert.deepEqual check in benchmark (resolves #125)export type (attempts to resolve #114)metaOverride in typings and documentation (holdover from temporary API in v5 beta)constructor equality now requiredTo align with other implementations common in the community, but also to be more functionally correct, the two objects being compared now must have equal constructors.
Map / Set comparisons no longer support IE11In previous verisons, .forEach() was used to ensure that support for Symbol was not required, as IE11 did not have Symbol and therefore both Map and Set did not have iterator-based methods such as .values() or .entries(). Since IE11 is no longer a supported browser, and support for those methods is present in all browsers and Node for quite a while, the comparison has moved to use these methods. This results in a ~20% performance increase.
createCustomEqual contract has changedTo better facilitate strict comparisons, but also to allow for meta use separate from caching, the contract for createCustomEqual has changed. See the README documentation for more details, but froma high-level:
meta is no longer passed through to equality comparators, but rather a general state object which contains metacache now also lives on the state object, which allows for use of the meta property separate from but in parallel with the circular cacheequals is now on state, which prevents the need to pass through the separate isEqual method for the equality comparatorcreateCustomCircularEqual has been removedYou can create a custom circular equality comparator through createCustomEqual now by providing circular: true to the options.
meta values are no longer passed at callsiteTo use meta properties for comparisons, they must be returned in a createState method.
If you were deep-linking into a specific asset type (ESM / CJS / UMD), they have changed location.
NOTE: You may no longer need to deep-link, as the build resolution has improved.
The following new comparators are available:
strictDeepEqualstrictShallowEqualstrictCircularDeepEqualstrictCircularShallowEqualThis will perform the same comparisons as their non-strict counterparts, but will verify additional properties (non-enumerable properties on objects, keyed objects on Array / Map / Set) and that the descriptors for the properties align.
TypedArray supportSupport for comparing all typed array values is now supported, and you can provide a custom comparator via the new areTypedArraysEqual option in the createCustomEqual configuration.
The library now leverages the exports property in the package.json to provide builds specific to your method of consumption (ESM / CommonJS / UMD). There is still a minified UMD version available if you want to use it instead.
arePrimitiveWrappersEqual option added to createCustomEqual configurationIf you want a custom comparator for primitive wrappers (new Boolean() / new Number() / new String()) it is now available.
createCustomCircularEqual typing is incorrectindex.d.ts fileIn previous versions, there were automatic fallbacks for certain ES2015 features if they did not exist:
Due to the omnipresence of support in both browser and NodeJS, these have been deprecated. There is still an option if you require support for these legacy environments, however; see createCustomEqual and createCustomCircularEqual for more details.
createCustomEqual contract has changedTo allow more flexibility and customizability for a variety of edge cases, createCustomEqual now allows override of specific type value comparisons in addition to the general comparator it did prior. See the documentation for more details.
createCustomCircularEqual addedLike createCustomEqual, it will create a custom equality comparator, with the exception that it will handle circular references. See the documentation for more details.
Prior to 4.x.x., instanceof was used internally for checking of object classes, which only worked when comparing objects from the same Realm. This has changed to instead use an object's StringTag, which is not realm-specific.
For better typing in edge-case scenarios like custom comparators with meta values, typings have been refactored for accuracy and better narrow flow-through.
RegExp comparison in modern environmentsWhen creating a custom equality comparator via createCustomEqual, the equality method has an expanded contract:
// Before
type EqualityComparator = (objectA: any, objectB: any, meta: any) => boolean;
// After
type InternalEqualityComparator = (
objectA: any,
objectB: any,
indexOrKeyA: any,
indexOrKeyB: any,
parentA: any,
parentB: any,
meta: any,
) => boolean;
If you have a custom equality comparator, you can ignore the differences by just passing additional undefined parameters, or you can use the parameters to further improve / clarify the logic.
Map / Set can create false equality successMap being a part of deepEqual.rpt2_cache directory from being published for better CI environment support (thanks @herberttn)fast-equals/es, fast-equals/lib, fast-equals/mjs locations
dist for different consumption types:fast-equals.js (UMD / browser)fast-equals.esm.js (ESM / module)fast-equals.cjs.js (CommonJS / main)import * as fe from 'fast-equalsMap / Set comparisonsObject.create(null)) to be plain objectscreateCustomEqualuglify with terserrollup to build all the distributables (main, module, and browser)
lib and es transpilations in case consumers were deep-linkingbabel@7"sideEffects": false to package.json for better tree-shaking in webpack.mjs extension exportsMap / Set comparison to not require order to match to be equalhasKey methodunicode and sticky RegExp flag checkscircularDeepEqual and circularShallowEqual methodsmeta third parameter to comparator calls, for use with createCustomEqual methodlastIndex was not being tested on RegExp objectsreact comparison more accurate, and a touch fasterreact elementsreact-fast-comparerollup for dist file buildsisSameValueZero as sameValueZeroEqual optionisSameValueZeroisStrictlyEqual with isSameValueZero to ensure that shallowEqual accounts for NaN equalitySet objects (improves performance of Set check by ~12%)Map and Set comparisons more explicittypeof into helper for faster runtimeInitial release