UNPKG

1.43 kBTypeScriptView Raw
1export interface KeyAllowlist<T> {
2 include: Array<keyof T>;
3}
4export interface KeyDenylist<T> {
5 exclude: Array<keyof T>;
6}
7/**
8 * Returns true if the arrays are equal. Elements will be shallowly compared by
9 * default, or they will be compared using the custom `compare` function if one
10 * is provided.
11 */
12export declare function arraysEqual(arrA: any[], arrB: any[], compare?: (a: any, b: any) => boolean): boolean;
13/**
14 * Shallow comparison between objects. If `keys` is provided, just that subset
15 * of keys will be compared; otherwise, all keys will be compared.
16 *
17 * @returns true if items are equal.
18 */
19export declare function shallowCompareKeys<T extends {}>(objA: T | null | undefined, objB: T | null | undefined, keys?: KeyDenylist<T> | KeyAllowlist<T>): boolean;
20/**
21 * Deep comparison between objects. If `keys` is provided, just that subset of
22 * keys will be compared; otherwise, all keys will be compared.
23 *
24 * @returns true if items are equal.
25 */
26export declare function deepCompareKeys(objA: any, objB: any, keys?: Array<string | number | symbol>): boolean;
27/**
28 * Returns a descriptive object for each key whose values are deeply unequal
29 * between two provided objects. Useful for debugging shouldComponentUpdate.
30 */
31export declare function getDeepUnequalKeyValues<T extends {}>(objA?: T, objB?: T, keys?: Array<keyof T>): {
32 key: keyof T;
33 valueA: T[keyof T];
34 valueB: T[keyof T];
35}[];