source: node_modules/es-toolkit/dist/compat/predicate/isEqualWith.d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[a762898]1import { IsEqualCustomizer } from '../_internal/IsEqualCustomizer.js';
2
3/**
4 * Compares two values for equality using a custom comparison function.
5 *
6 * The custom function allows for fine-tuned control over the comparison process. If it returns a boolean, that result determines the equality. If it returns undefined, the function falls back to the default equality comparison.
7 *
8 * This function also uses the custom equality function to compare values inside objects,
9 * arrays, maps, sets, and other complex structures, ensuring a deep comparison.
10 *
11 * This approach provides flexibility in handling complex comparisons while maintaining efficient default behavior for simpler cases.
12 *
13 * The custom comparison function can take up to six parameters:
14 * - `x`: The value from the first object `a`.
15 * - `y`: The value from the second object `b`.
16 * - `property`: The property key used to get `x` and `y`.
17 * - `xParent`: The parent of the first value `x`.
18 * - `yParent`: The parent of the second value `y`.
19 * - `stack`: An internal stack (Map) to handle circular references.
20 *
21 * @param {unknown} a - The first value to compare.
22 * @param {unknown} b - The second value to compare.
23 * @param {(x: any, y: any, property?: PropertyKey, xParent?: any, yParent?: any, stack?: Map<any, any>) => boolean | void} [areValuesEqual=noop] - A function to customize the comparison.
24 * If it returns a boolean, that result will be used. If it returns undefined,
25 * the default equality comparison will be used.
26 * @returns {boolean} `true` if the values are equal according to the customizer, otherwise `false`.
27 *
28 * @example
29 * const customizer = (a, b) => {
30 * if (typeof a === 'string' && typeof b === 'string') {
31 * return a.toLowerCase() === b.toLowerCase();
32 * }
33 * };
34 * isEqualWith('Hello', 'hello', customizer); // true
35 * isEqualWith({ a: 'Hello' }, { a: 'hello' }, customizer); // true
36 * isEqualWith([1, 2, 3], [1, 2, 3], customizer); // true
37 */
38declare function isEqualWith(a: any, b: any, areValuesEqual?: IsEqualCustomizer): boolean;
39
40export { isEqualWith };
Note: See TracBrowser for help on using the repository browser.