🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

fast-equals

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-equals - npm Package Compare versions

Comparing version
6.0.0-rc.1
to
6.0.0
+20
-16
dist/cjs/index.cjs

@@ -79,2 +79,14 @@ 'use strict';

/**
* Whether the values passed are equal based on a
* [Strict Equality Comparison](https://262.ecma-international.org/7.0/#sec-strict-equality-comparison) basis.
* Simplified, this maps to if the two values are referentially equal to one another (`a === b`).
*
* @note
* This is mainly available as a convenience function, such as being a default when a function to determine equality between
* two objects is used.
*/
function strictEqual(a, b) {
return a === b;
}
/**
* Whether the array buffers are equal in value.

@@ -120,8 +132,2 @@ */

/**
* Whether the functions passed are equal in value.
*/
function areFunctionsEqual(a, b) {
return a === b;
}
/**
* Whether the `Map`s are equal in value.

@@ -176,6 +182,2 @@ */

/**
* Whether the numbers are equal in value.
*/
const areNumbersEqual = sameValueEqual;
/**
* Whether the objects are equal in value.

@@ -374,4 +376,4 @@ */

// instead of `instanceof` because it is more performant for the common
// use-case. If someone is subclassing a native class, it will be handled
// with the string tag comparison.
// use-case. If someone is creating a subclass from a native class, it will be
// handled with the string tag comparison.
if (constructor === Object) {

@@ -405,3 +407,3 @@ return areObjectsEqual(a, b, state);

}
// Since this is a custom object, capture the string tag to determing its type.
// Since this is a custom object, capture the string tag to determining its type.
// This is reasonably performant in modern environments like v8 and SpiderMonkey.

@@ -413,3 +415,3 @@ const tag = toString.call(a);

}
const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, tag);
const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, state, tag);
if (unsupportedCustomComparator) {

@@ -439,5 +441,5 @@ return unsupportedCustomComparator(a, b, state);

areErrorsEqual: areErrorsEqual,
areFunctionsEqual: areFunctionsEqual,
areFunctionsEqual: strictEqual,
areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
areNumbersEqual: areNumbersEqual,
areNumbersEqual: sameValueEqual,
areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,

@@ -522,2 +524,3 @@ arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,

'[object ArrayBuffer]': areArrayBuffersEqual,
'[object AsyncGeneratorFunction]': areFunctionsEqual,
'[object BigInt]': areNumbersEqual,

@@ -637,2 +640,3 @@ '[object BigInt64Array]': areTypedArraysEqual,

exports.strictDeepEqual = strictDeepEqual;
exports.strictEqual = strictEqual;
exports.strictShallowEqual = strictShallowEqual;

@@ -30,12 +30,2 @@ /**

}
interface CircularState<Meta> extends State<Meta> {
readonly cache: Cache<any, any>;
}
interface DefaultState<Meta> extends State<Meta> {
readonly cache: undefined;
}
interface Dictionary<Value = any> {
[key: string | symbol]: Value;
$$typeof?: any;
}
interface ComparatorConfig<Meta> {

@@ -46,3 +36,3 @@ /**

*/
areArrayBuffersEqual: TypeEqualityComparator<any, Meta>;
areArrayBuffersEqual: EqualityComparator<Meta>;
/**

@@ -52,19 +42,19 @@ * Whether the arrays passed are equal in value. In strict mode, this includes

*/
areArraysEqual: TypeEqualityComparator<any, Meta>;
areArraysEqual: EqualityComparator<Meta>;
/**
* Whether the data views passed are equal in value.
*/
areDataViewsEqual: TypeEqualityComparator<any, Meta>;
areDataViewsEqual: EqualityComparator<Meta>;
/**
* Whether the dates passed are equal in value.
*/
areDatesEqual: TypeEqualityComparator<any, Meta>;
areDatesEqual: EqualityComparator<Meta>;
/**
* Whether the errors passed are equal in value.
*/
areErrorsEqual: TypeEqualityComparator<any, Meta>;
areErrorsEqual: EqualityComparator<Meta>;
/**
* Whether the functions passed are equal in value.
*/
areFunctionsEqual: TypeEqualityComparator<any, Meta>;
areFunctionsEqual: EqualityComparator<Meta>;
/**

@@ -74,7 +64,7 @@ * Whether the maps passed are equal in value. In strict mode, this includes

*/
areMapsEqual: TypeEqualityComparator<any, Meta>;
areMapsEqual: EqualityComparator<Meta>;
/**
* Whether the numbers passed are equal in value.
*/
areNumbersEqual: TypeEqualityComparator<any, Meta>;
areNumbersEqual: EqualityComparator<Meta>;
/**

@@ -84,11 +74,11 @@ * Whether the objects passed are equal in value. In strict mode, this includes

*/
areObjectsEqual: TypeEqualityComparator<any, Meta>;
areObjectsEqual: EqualityComparator<Meta>;
/**
* Whether the primitive wrappers passed are equal in value.
*/
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
arePrimitiveWrappersEqual: EqualityComparator<Meta>;
/**
* Whether the regexps passed are equal in value.
*/
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
areRegExpsEqual: EqualityComparator<Meta>;
/**

@@ -98,3 +88,3 @@ * Whether the sets passed are equal in value. In strict mode, this includes

*/
areSetsEqual: TypeEqualityComparator<any, Meta>;
areSetsEqual: EqualityComparator<Meta>;
/**

@@ -104,20 +94,13 @@ * Whether the typed arrays passed are equal in value. In strict mode, this includes

*/
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
areTypedArraysEqual: EqualityComparator<Meta>;
/**
* Whether the URLs passed are equal in value.
*/
areUrlsEqual: TypeEqualityComparator<any, Meta>;
areUrlsEqual: EqualityComparator<Meta>;
/**
* Get a custom comparator based on the objects passed.
*/
getUnsupportedCustomComparator: ((a: any, b: any, tag: string) => TypeEqualityComparator<any, Meta> | undefined) | undefined;
getUnsupportedCustomComparator: ((a: any, b: any, state: State<Meta>, tag: string) => EqualityComparator<Meta> | undefined) | undefined;
}
type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
type CreateState<Meta> = () => {
cache?: Cache<any, any> | undefined;
meta?: Meta;
};
type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) => boolean;
type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
type EqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;

@@ -130,3 +113,2 @@ type PrimitiveWrapper = Boolean | Number | String;

type TypedArray = BigInt64Array | BigUint64Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
interface CustomEqualCreatorOptions<Meta> {

@@ -142,5 +124,5 @@ /**

* This receives the default configuration, which allows either replacement
* or supersetting of the default methods.
* or a superset of the default methods.
*/
createCustomConfig?: CreateCustomComparatorConfig<Meta>;
createCustomConfig?: (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
/**

@@ -158,3 +140,6 @@ * Create a custom internal comparator, which is used as an override to the

*/
createState?: CreateState<Meta>;
createState?: () => {
cache?: Cache<any, any> | undefined;
meta?: Meta;
};
/**

@@ -183,2 +168,12 @@ * Whether the equality comparison is strict, meaning it matches

declare function sameValueZeroEqual(a: any, b: any): boolean;
/**
* Whether the values passed are equal based on a
* [Strict Equality Comparison](https://262.ecma-international.org/7.0/#sec-strict-equality-comparison) basis.
* Simplified, this maps to if the two values are referentially equal to one another (`a === b`).
*
* @note
* This is mainly available as a convenience function, such as being a default when a function to determine equality between
* two objects is used.
*/
declare function strictEqual(a: any, b: any): boolean;

@@ -229,3 +224,3 @@ /**

export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };
export type { AnyEqualityComparator, Cache, CircularState, ComparatorConfig, CreateCustomComparatorConfig, CreateState, CustomEqualCreatorOptions, DefaultState, Dictionary, EqualityComparator, EqualityComparatorCreator, InternalEqualityComparator, PrimitiveWrapper, State, TypeEqualityComparator, TypedArray };
export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictEqual, strictShallowEqual };
export type { Cache, ComparatorConfig, CustomEqualCreatorOptions, EqualityComparator, InternalEqualityComparator, PrimitiveWrapper, State, TypedArray };

@@ -30,12 +30,2 @@ /**

}
interface CircularState<Meta> extends State<Meta> {
readonly cache: Cache<any, any>;
}
interface DefaultState<Meta> extends State<Meta> {
readonly cache: undefined;
}
interface Dictionary<Value = any> {
[key: string | symbol]: Value;
$$typeof?: any;
}
interface ComparatorConfig<Meta> {

@@ -46,3 +36,3 @@ /**

*/
areArrayBuffersEqual: TypeEqualityComparator<any, Meta>;
areArrayBuffersEqual: EqualityComparator<Meta>;
/**

@@ -52,19 +42,19 @@ * Whether the arrays passed are equal in value. In strict mode, this includes

*/
areArraysEqual: TypeEqualityComparator<any, Meta>;
areArraysEqual: EqualityComparator<Meta>;
/**
* Whether the data views passed are equal in value.
*/
areDataViewsEqual: TypeEqualityComparator<any, Meta>;
areDataViewsEqual: EqualityComparator<Meta>;
/**
* Whether the dates passed are equal in value.
*/
areDatesEqual: TypeEqualityComparator<any, Meta>;
areDatesEqual: EqualityComparator<Meta>;
/**
* Whether the errors passed are equal in value.
*/
areErrorsEqual: TypeEqualityComparator<any, Meta>;
areErrorsEqual: EqualityComparator<Meta>;
/**
* Whether the functions passed are equal in value.
*/
areFunctionsEqual: TypeEqualityComparator<any, Meta>;
areFunctionsEqual: EqualityComparator<Meta>;
/**

@@ -74,7 +64,7 @@ * Whether the maps passed are equal in value. In strict mode, this includes

*/
areMapsEqual: TypeEqualityComparator<any, Meta>;
areMapsEqual: EqualityComparator<Meta>;
/**
* Whether the numbers passed are equal in value.
*/
areNumbersEqual: TypeEqualityComparator<any, Meta>;
areNumbersEqual: EqualityComparator<Meta>;
/**

@@ -84,11 +74,11 @@ * Whether the objects passed are equal in value. In strict mode, this includes

*/
areObjectsEqual: TypeEqualityComparator<any, Meta>;
areObjectsEqual: EqualityComparator<Meta>;
/**
* Whether the primitive wrappers passed are equal in value.
*/
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
arePrimitiveWrappersEqual: EqualityComparator<Meta>;
/**
* Whether the regexps passed are equal in value.
*/
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
areRegExpsEqual: EqualityComparator<Meta>;
/**

@@ -98,3 +88,3 @@ * Whether the sets passed are equal in value. In strict mode, this includes

*/
areSetsEqual: TypeEqualityComparator<any, Meta>;
areSetsEqual: EqualityComparator<Meta>;
/**

@@ -104,20 +94,13 @@ * Whether the typed arrays passed are equal in value. In strict mode, this includes

*/
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
areTypedArraysEqual: EqualityComparator<Meta>;
/**
* Whether the URLs passed are equal in value.
*/
areUrlsEqual: TypeEqualityComparator<any, Meta>;
areUrlsEqual: EqualityComparator<Meta>;
/**
* Get a custom comparator based on the objects passed.
*/
getUnsupportedCustomComparator: ((a: any, b: any, tag: string) => TypeEqualityComparator<any, Meta> | undefined) | undefined;
getUnsupportedCustomComparator: ((a: any, b: any, state: State<Meta>, tag: string) => EqualityComparator<Meta> | undefined) | undefined;
}
type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
type CreateState<Meta> = () => {
cache?: Cache<any, any> | undefined;
meta?: Meta;
};
type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) => boolean;
type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
type EqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;

@@ -130,3 +113,2 @@ type PrimitiveWrapper = Boolean | Number | String;

type TypedArray = BigInt64Array | BigUint64Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
interface CustomEqualCreatorOptions<Meta> {

@@ -142,5 +124,5 @@ /**

* This receives the default configuration, which allows either replacement
* or supersetting of the default methods.
* or a superset of the default methods.
*/
createCustomConfig?: CreateCustomComparatorConfig<Meta>;
createCustomConfig?: (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
/**

@@ -158,3 +140,6 @@ * Create a custom internal comparator, which is used as an override to the

*/
createState?: CreateState<Meta>;
createState?: () => {
cache?: Cache<any, any> | undefined;
meta?: Meta;
};
/**

@@ -183,2 +168,12 @@ * Whether the equality comparison is strict, meaning it matches

declare function sameValueZeroEqual(a: any, b: any): boolean;
/**
* Whether the values passed are equal based on a
* [Strict Equality Comparison](https://262.ecma-international.org/7.0/#sec-strict-equality-comparison) basis.
* Simplified, this maps to if the two values are referentially equal to one another (`a === b`).
*
* @note
* This is mainly available as a convenience function, such as being a default when a function to determine equality between
* two objects is used.
*/
declare function strictEqual(a: any, b: any): boolean;

@@ -229,3 +224,3 @@ /**

export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };
export type { AnyEqualityComparator, Cache, CircularState, ComparatorConfig, CreateCustomComparatorConfig, CreateState, CustomEqualCreatorOptions, DefaultState, Dictionary, EqualityComparator, EqualityComparatorCreator, InternalEqualityComparator, PrimitiveWrapper, State, TypeEqualityComparator, TypedArray };
export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictEqual, strictShallowEqual };
export type { Cache, ComparatorConfig, CustomEqualCreatorOptions, EqualityComparator, InternalEqualityComparator, PrimitiveWrapper, State, TypedArray };

@@ -77,2 +77,14 @@ const { getOwnPropertyNames, getOwnPropertySymbols } = Object;

/**
* Whether the values passed are equal based on a
* [Strict Equality Comparison](https://262.ecma-international.org/7.0/#sec-strict-equality-comparison) basis.
* Simplified, this maps to if the two values are referentially equal to one another (`a === b`).
*
* @note
* This is mainly available as a convenience function, such as being a default when a function to determine equality between
* two objects is used.
*/
function strictEqual(a, b) {
return a === b;
}
/**
* Whether the array buffers are equal in value.

@@ -118,8 +130,2 @@ */

/**
* Whether the functions passed are equal in value.
*/
function areFunctionsEqual(a, b) {
return a === b;
}
/**
* Whether the `Map`s are equal in value.

@@ -174,6 +180,2 @@ */

/**
* Whether the numbers are equal in value.
*/
const areNumbersEqual = sameValueEqual;
/**
* Whether the objects are equal in value.

@@ -372,4 +374,4 @@ */

// instead of `instanceof` because it is more performant for the common
// use-case. If someone is subclassing a native class, it will be handled
// with the string tag comparison.
// use-case. If someone is creating a subclass from a native class, it will be
// handled with the string tag comparison.
if (constructor === Object) {

@@ -403,3 +405,3 @@ return areObjectsEqual(a, b, state);

}
// Since this is a custom object, capture the string tag to determing its type.
// Since this is a custom object, capture the string tag to determining its type.
// This is reasonably performant in modern environments like v8 and SpiderMonkey.

@@ -411,3 +413,3 @@ const tag = toString.call(a);

}
const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, tag);
const unsupportedCustomComparator = getUnsupportedCustomComparator && getUnsupportedCustomComparator(a, b, state, tag);
if (unsupportedCustomComparator) {

@@ -437,5 +439,5 @@ return unsupportedCustomComparator(a, b, state);

areErrorsEqual: areErrorsEqual,
areFunctionsEqual: areFunctionsEqual,
areFunctionsEqual: strictEqual,
areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
areNumbersEqual: areNumbersEqual,
areNumbersEqual: sameValueEqual,
areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,

@@ -520,2 +522,3 @@ arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,

'[object ArrayBuffer]': areArrayBuffersEqual,
'[object AsyncGeneratorFunction]': areFunctionsEqual,
'[object BigInt]': areNumbersEqual,

@@ -625,2 +628,2 @@ '[object BigInt64Array]': areTypedArraysEqual,

export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };
export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictEqual, strictShallowEqual };

@@ -30,12 +30,2 @@ /**

}
interface CircularState<Meta> extends State<Meta> {
readonly cache: Cache<any, any>;
}
interface DefaultState<Meta> extends State<Meta> {
readonly cache: undefined;
}
interface Dictionary<Value = any> {
[key: string | symbol]: Value;
$$typeof?: any;
}
interface ComparatorConfig<Meta> {

@@ -46,3 +36,3 @@ /**

*/
areArrayBuffersEqual: TypeEqualityComparator<any, Meta>;
areArrayBuffersEqual: EqualityComparator<Meta>;
/**

@@ -52,19 +42,19 @@ * Whether the arrays passed are equal in value. In strict mode, this includes

*/
areArraysEqual: TypeEqualityComparator<any, Meta>;
areArraysEqual: EqualityComparator<Meta>;
/**
* Whether the data views passed are equal in value.
*/
areDataViewsEqual: TypeEqualityComparator<any, Meta>;
areDataViewsEqual: EqualityComparator<Meta>;
/**
* Whether the dates passed are equal in value.
*/
areDatesEqual: TypeEqualityComparator<any, Meta>;
areDatesEqual: EqualityComparator<Meta>;
/**
* Whether the errors passed are equal in value.
*/
areErrorsEqual: TypeEqualityComparator<any, Meta>;
areErrorsEqual: EqualityComparator<Meta>;
/**
* Whether the functions passed are equal in value.
*/
areFunctionsEqual: TypeEqualityComparator<any, Meta>;
areFunctionsEqual: EqualityComparator<Meta>;
/**

@@ -74,7 +64,7 @@ * Whether the maps passed are equal in value. In strict mode, this includes

*/
areMapsEqual: TypeEqualityComparator<any, Meta>;
areMapsEqual: EqualityComparator<Meta>;
/**
* Whether the numbers passed are equal in value.
*/
areNumbersEqual: TypeEqualityComparator<any, Meta>;
areNumbersEqual: EqualityComparator<Meta>;
/**

@@ -84,11 +74,11 @@ * Whether the objects passed are equal in value. In strict mode, this includes

*/
areObjectsEqual: TypeEqualityComparator<any, Meta>;
areObjectsEqual: EqualityComparator<Meta>;
/**
* Whether the primitive wrappers passed are equal in value.
*/
arePrimitiveWrappersEqual: TypeEqualityComparator<any, Meta>;
arePrimitiveWrappersEqual: EqualityComparator<Meta>;
/**
* Whether the regexps passed are equal in value.
*/
areRegExpsEqual: TypeEqualityComparator<any, Meta>;
areRegExpsEqual: EqualityComparator<Meta>;
/**

@@ -98,3 +88,3 @@ * Whether the sets passed are equal in value. In strict mode, this includes

*/
areSetsEqual: TypeEqualityComparator<any, Meta>;
areSetsEqual: EqualityComparator<Meta>;
/**

@@ -104,20 +94,13 @@ * Whether the typed arrays passed are equal in value. In strict mode, this includes

*/
areTypedArraysEqual: TypeEqualityComparator<any, Meta>;
areTypedArraysEqual: EqualityComparator<Meta>;
/**
* Whether the URLs passed are equal in value.
*/
areUrlsEqual: TypeEqualityComparator<any, Meta>;
areUrlsEqual: EqualityComparator<Meta>;
/**
* Get a custom comparator based on the objects passed.
*/
getUnsupportedCustomComparator: ((a: any, b: any, tag: string) => TypeEqualityComparator<any, Meta> | undefined) | undefined;
getUnsupportedCustomComparator: ((a: any, b: any, state: State<Meta>, tag: string) => EqualityComparator<Meta> | undefined) | undefined;
}
type CreateCustomComparatorConfig<Meta> = (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
type CreateState<Meta> = () => {
cache?: Cache<any, any> | undefined;
meta?: Meta;
};
type EqualityComparator<Meta> = <A, B>(a: A, b: B, state: State<Meta>) => boolean;
type AnyEqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
type EqualityComparatorCreator<Meta> = (fn: EqualityComparator<Meta>) => InternalEqualityComparator<Meta>;
type EqualityComparator<Meta> = (a: any, b: any, state: State<Meta>) => boolean;
type InternalEqualityComparator<Meta> = (a: any, b: any, indexOrKeyA: any, indexOrKeyB: any, parentA: any, parentB: any, state: State<Meta>) => boolean;

@@ -130,3 +113,2 @@ type PrimitiveWrapper = Boolean | Number | String;

type TypedArray = BigInt64Array | BigUint64Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint16Array | Uint32Array | Uint8Array | Uint8ClampedArray;
type TypeEqualityComparator<Type, Meta = undefined> = (a: Type, b: Type, state: State<Meta>) => boolean;
interface CustomEqualCreatorOptions<Meta> {

@@ -142,5 +124,5 @@ /**

* This receives the default configuration, which allows either replacement
* or supersetting of the default methods.
* or a superset of the default methods.
*/
createCustomConfig?: CreateCustomComparatorConfig<Meta>;
createCustomConfig?: (config: ComparatorConfig<Meta>) => Partial<ComparatorConfig<Meta>>;
/**

@@ -158,3 +140,6 @@ * Create a custom internal comparator, which is used as an override to the

*/
createState?: CreateState<Meta>;
createState?: () => {
cache?: Cache<any, any> | undefined;
meta?: Meta;
};
/**

@@ -183,2 +168,12 @@ * Whether the equality comparison is strict, meaning it matches

declare function sameValueZeroEqual(a: any, b: any): boolean;
/**
* Whether the values passed are equal based on a
* [Strict Equality Comparison](https://262.ecma-international.org/7.0/#sec-strict-equality-comparison) basis.
* Simplified, this maps to if the two values are referentially equal to one another (`a === b`).
*
* @note
* This is mainly available as a convenience function, such as being a default when a function to determine equality between
* two objects is used.
*/
declare function strictEqual(a: any, b: any): boolean;

@@ -229,3 +224,3 @@ /**

export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictShallowEqual };
export type { AnyEqualityComparator, Cache, CircularState, ComparatorConfig, CreateCustomComparatorConfig, CreateState, CustomEqualCreatorOptions, DefaultState, Dictionary, EqualityComparator, EqualityComparatorCreator, InternalEqualityComparator, PrimitiveWrapper, State, TypeEqualityComparator, TypedArray };
export { circularDeepEqual, circularShallowEqual, createCustomEqual, deepEqual, sameValueEqual, sameValueZeroEqual, shallowEqual, strictCircularDeepEqual, strictCircularShallowEqual, strictDeepEqual, strictEqual, strictShallowEqual };
export type { Cache, ComparatorConfig, CustomEqualCreatorOptions, EqualityComparator, InternalEqualityComparator, PrimitiveWrapper, State, TypedArray };

@@ -10,3 +10,3 @@ {

},
"description": "A blazing fast equality comparison, either shallow or deep",
"description": "A blazing-fast equality comparison utility for a variety of use-cases",
"devDependencies": {

@@ -21,3 +21,3 @@ "@planttheidea/build-tools": "^2.0.0",

"@typescript-eslint/parser": "^8.50.0",
"@vitest/coverage-v8": "^4.0.15",
"@vitest/coverage-v8": "^4.0.16",
"cli-table3": "^0.6.5",

@@ -47,3 +47,3 @@ "decircularize": "^1.0.0",

"vite": "^7.3.0",
"vitest": "^4.0.15"
"vitest": "^4.0.16"
},

@@ -115,3 +115,3 @@ "engines": {

"types": "./index.d.ts",
"version": "6.0.0-rc.1"
"version": "6.0.0"
}
+81
-82

@@ -1,11 +0,6 @@

# fast-equals
> fast-equals
<img src="https://img.shields.io/badge/build-passing-brightgreen.svg"/>
<img src="https://img.shields.io/badge/coverage-100%25-brightgreen.svg"/>
<img src="https://img.shields.io/badge/license-MIT-blue.svg"/>
Perform [blazing fast](#benchmarks) equality comparisons between two objects, while also allowing for flexibility for
various use-cases. It has no dependencies, and is ~2kB when minified and gzipped.
Perform [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 ~2kB when
minified and gzipped.
The following types are handled out-of-the-box:

@@ -19,33 +14,40 @@

- `Map` / `Set` iterables
- `Promise` objects
- `Promise` objects and then-ables
- Primitive wrappers (`new Boolean()` / `new Number()` / `new String()`)
- Custom class instances, including subclasses of native classes
Methods 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.
Methods are available for deep, shallow, [`SameValue`](http://ecma-international.org/ecma-262/7.0/#sec-samevalue),
[`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero), or
[strict equality](https://262.ecma-international.org/7.0/#sec-strict-equality-comparison) 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.
## Table of contents
By 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:
- [fast-equals](#fast-equals)
- [Table of contents](#table-of-contents)
- [Usage](#usage)
- [Specific builds](#specific-builds)
- [Available methods](#available-methods)
- [deepEqual](#deepequal)
- [Comparing `Map`s](#comparing-maps)
- [shallowEqual](#shallowequal)
- [sameValueEqual](#samevalueequal)
- [circularDeepEqual](#circulardeepequal)
- [circularShallowEqual](#circularshallowequal)
- [strictDeepEqual](#strictdeepequal)
- [strictShallowEqual](#strictshallowequal)
- [strictCircularDeepEqual](#strictcirculardeepequal)
- [strictCircularShallowEqual](#strictcircularshallowequal)
- [createCustomEqual](#createcustomequal)
- [getUnsupportedCustomComparator](#getunsupportedcustomcomparator)
- [Recipes](#recipes)
- [Benchmarks](#benchmarks)
- [Development](#development)
- ESM => `fast-equals/dist/es/index.mjs`
- CommonJS => `fast-equals/dist/cjs/index.cjs`
If you are having any problems, want to request a new feature, or have any questions,
[please file an issue](https://github.com/planttheidea/fast-equals/issues).
- [Usage](#usage)
- [Available methods](#available-methods)
- [deepEqual](#deepequal)
- [Comparing `Map`s](#comparing-maps)
- [shallowEqual](#shallowequal)
- [sameValueEqual](#samevalueequal)
- [sameValueZeroEqual](#samevaluezeroequal)
- [strictEqual](#strictequal)
- [circularDeepEqual](#circulardeepequal)
- [circularShallowEqual](#circularshallowequal)
- [strictDeepEqual](#strictdeepequal)
- [strictShallowEqual](#strictshallowequal)
- [strictCircularDeepEqual](#strictcirculardeepequal)
- [strictCircularShallowEqual](#strictcircularshallowequal)
- [createCustomEqual](#createcustomequal)
- [getUnsupportedCustomComparator](#getunsupportedcustomcomparator)
- [Recipes](#recipes)
- [Benchmarks](#benchmarks)
## Usage

@@ -59,15 +61,2 @@

### Specific builds
By 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:
- ESM => `fast-equals/dist/esm/index.mjs`
- CommonJS => `fast-equals/dist/cjs/index.cjs`
- UMD => `fast-equals/dist/umd/index.js`
- Minified UMD => `fast-equals/dist/min/index.js`
If you are having issues loading a specific build type,
[please file an issue](https://github.com/planttheidea/fast-equals/issues).
## Available methods

@@ -104,3 +93,3 @@

To 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`.
pairs. Therefore, the above would be `true`.

@@ -149,5 +138,5 @@ ### shallowEqual

**NOTE**: In environments that support
_**NOTE**: In environments that support
[`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is),
`sameValueEqual` is just a re-export of that method.
`sameValueEqual` is just a re-export of that method._

@@ -177,2 +166,29 @@ ### sameValueZeroEqual

### strictEqual
Performs a [Strict Equality](https://262.ecma-international.org/7.0/#sec-strict-equality-comparison) comparison on the
two objects passed and returns a boolean representing the referential equality of the objects. In simple terms, this
means:
- `+0` and `-0` are equal
- `NaN` is not equal to `NaN`
- All other items are based on referential equality (`a === b`)
```ts
import { strictEqual } from 'fast-equals';
const mainObject = { foo: NaN, bar: 'baz' };
const objectA = 'baz';
const objectB = NaN;
const objectC = { foo: NaN, bar: 'baz' };
console.log(sameValueEqual(mainObject.bar, objectA)); // true
console.log(sameValueEqual(mainObject.foo, objectB)); // false
console.log(sameValueEqual(mainObject, objectC)); // false
```
_**NOTE**: This is mainly a convenience function, such as needing a default functional equality comparator. Naturally,
it is faster to simply compare `a === b`. :)_
### circularDeepEqual

@@ -336,17 +352,17 @@

interface ComparatorConfig<Meta> {
areArrayBuffersEcqual: TypeEqualityComparator<ArrayBuffer, Meta>;
areArraysEcqual: TypeEqualityComparator<any[], Meta>;
areDataViewsEqual: TypeEqualityComparator<DataView, Meta>;
areDatesEqual: TypeEqualityComparator<Date, Meta>;
areErrorsEqual: TypeEqualityComparator<Error, Meta>;
areFunctionsEqual: TypeEqualityComparator<(...args: any[]) => any, Meta>;
areMapsEqual: TypeEqualityComparator<Map<any, any>, Meta>;
areNumbersEqual: TypeEqualityComparator<number, Meta>;
areObjectsEqual: TypeEqualityComparator<Record<string, any>, Meta>;
arePrimitiveWrappersEqual: TypeEqualityComparator<Boolean | Number | String, Meta>;
areRegExpsEqual: TypeEqualityComparator<RegExp, Meta>;
areSetsEqual: TypeEqualityComparator<Set<any>, Meta>;
areTypedArraysEqual: TypeEqualityComparator<TypedArray, Meta>;
areUrlsEqual: TypeEqualityComparator<URL, Meta>;
getUnsupportedCustomComparator: <Type>(a: Type, b: Type, tag: string) => TypeEqualityComparator<Type, Meta>;
areArrayBuffersEqual: EqualityComparator<Meta>;
areArraysEqual: EqualityComparator<Meta>;
areDataViewsEqual: EqualityComparator<Meta>;
areDatesEqual: EqualityComparator<Meta>;
areErrorsEqual: EqualityComparator<Meta>;
areFunctionsEqual: EqualityComparator<Meta>;
areMapsEqual: EqualityComparator<Meta>;
areNumbersEqual: EqualityComparator<Meta>;
areObjectsEqual: EqualityComparator<Meta>;
arePrimitiveWrappersEqual: EqualityComparator<Meta>;
areRegExpsEqual: EqualityComparator<Meta>;
areSetsEqual: EqualityComparator<Meta>;
areTypedArraysEqual: EqualityComparator<Meta>;
areUrlsEqual: EqualityComparator<Meta>;
getUnsupportedCustomComparator: <Type>(a: Type, b: Type, state: State<Meta>, tag: string) => EqualityComparator<Meta>;
}

@@ -390,3 +406,3 @@

- [Strict property descriptor comparison](./recipes/strict-property-descriptor-check.md)
- [Legacy environment support for circualr equal comparators](./recipes/legacy-circular-equal-support.md)
- [Legacy environment support for circular equal comparators](./recipes/legacy-circular-equal-support.md)
- [Custom comparator support](./recipes/special-objects.md)

@@ -501,18 +517,1 @@

to be included.
## Development
Standard practice, clone the repo and `npm i` to get the dependencies. The following npm scripts are available:
- benchmark => run benchmark tests against other equality libraries
- build => build `main`, `module`, and `browser` distributables with `rollup`
- clean => run `rimraf` on the `dist` folder
- dev => start `vite` playground App
- dist => run `build`
- lint => run ESLint on all files in `src` folder (also runs on `dev` script)
- lint:fix => run `lint` script, but with auto-fixer
- prepublish:compile => run `lint`, `test:coverage`, `transpile:lib`, `transpile:es`, and `dist` scripts
- start => run `dev`
- test => run AVA with NODE_ENV=test on all files in `test` folder
- test:coverage => run same script as `test` with code coverage calculation via `nyc`
- test:watch => run same script as `test` but keep persistent watcher