@glyph-cat/equality
Version:
General purpose equality-checking presets.
72 lines (63 loc) • 3.33 kB
TypeScript
/**
* A wrapper around {@link arrayShallowEqual|`arrayShallowEqual`} and
* {@link objectShallowEqual|`objectShallowEqual`}.
*
* Only use this when you cannot determine whether the values to compare will
* return an array or an object as it exhausts additional computing resources
* that could otherwise be prevented.
* @returns `true` if both values are considered equal, otherwise `false`.
* @public
*/
export declare function arrayOrObjectShallowEqual(a: Array<any> | any, b: Array<any> | any): boolean;
/**
* Compares each element in the array using [`Object.is`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
* @returns `true` if both values are considered equal, otherwise `false`.
* @public
*/
export declare function arrayShallowEqual(a: Array<any> | any, b: Array<any> | any): boolean;
/**
* Compares each item in the object using [`Object.is`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
* @returns `true` if both values are considered equal, otherwise `false`.
* @public
*/
export declare function objectShallowEqual(a: any, b: any): boolean;
/**
* Compares each element in the array using [`Object.is`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
* @returns `true` if both values are considered equal, otherwise `false`.
* @public
* @deprecated Please use {@link arrayShallowEqual|`arrayShallowEqual`} instead.
*/
export declare const shallowCompareArray: typeof arrayShallowEqual;
/**
* A wrapper around {@link arrayShallowEqual|`arrayShallowEqual`} and
* {@link objectShallowEqual|`objectShallowEqual`}.
*
* Only use this when you cannot determine whether the values to compare will
* return an array or an object as it exhausts additional computing resources
* that could otherwise be prevented.
* @returns `true` if both values are considered equal, otherwise `false`.
* @public
* @deprecated Please use {@link arrayOrObjectShallowEqual|`arrayOrObjectShallowEqual`} instead.
*/
export declare const shallowCompareArrayOrObject: typeof arrayOrObjectShallowEqual;
/**
* Compares each item in the object using [`Object.is`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
* @returns `true` if both values are considered equal, otherwise `false`.
* @public
* @deprecated Please use {@link objectShallowEqual|`objectShallowEqual`} instead.
*/
export declare const shallowCompareObject: typeof objectShallowEqual;
/**
* Compares the values after serializing them with [`JSON.stringify`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).
* @returns `true` if both values are considered equal, otherwise `false`.
* @public
* @deprecated Please use {@link stringifyEqual|`stringifyEqual`} instead.
*/
export declare const stringifyCompare: typeof stringifyEqual;
/**
* Compares the values after serializing them with [`JSON.stringify`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify).
* @returns `true` if both values are considered equal, otherwise `false`.
* @public
*/
export declare function stringifyEqual(a: any, b: any): boolean;
export { }