TreasureTrails/node_modules/remeda/dist/isDeepEqual.cjs.map

1 line
8.4 KiB
Text
Raw Normal View History

2026-03-18 09:02:21 -05:00
{"version":3,"file":"isDeepEqual.cjs","names":["purry"],"sources":["../src/isDeepEqual.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Performs a *deep structural* comparison between two values to determine if\n * they are equivalent. For primitive values this is equivalent to `===`, for\n * arrays the check would be performed on every item recursively, in order, and\n * for objects all props will be compared recursively.\n *\n * The built-in Date and RegExp are special-cased and will be compared by their\n * values.\n *\n * !IMPORTANT: TypedArrays and symbol properties of objects are not supported\n * right now and might result in unexpected behavior. Please open an issue in\n * the Remeda github project if you need support for these types.\n *\n * The result would be narrowed to the second value so that the function can be\n * used as a type guard.\n *\n * See:\n * - `isStrictEqual` if you don't need a deep comparison and just want to\n * check for simple (`===`, `Object.is`) equality.\n * - `isShallowEqual` if you need to compare arrays and objects \"by-value\" but\n * don't want to recurse into their values.\n *\n * @param data - The first value to compare.\n * @param other - The second value to compare.\n * @signature\n * R.isDeepEqual(data, other)\n * @example\n * R.isDeepEqual(1, 1) //=> true\n * R.isDeepEqual(1, '1') //=> false\n * R.isDeepEqual([1, 2, 3], [1, 2, 3]) //=> true\n * @dataFirst\n * @category Guard\n */\nexport function isDeepEqual<T, S extends T>(\n data: T,\n other: T extends Exclude<T, S> ? S : never,\n): data is S;\nexport function isDeepEqual<T>(data: T, other: T): boolean;\n\n/**\n * Performs a *deep structural* comparison between two values to determine if\n * they are equivalent. For primitive values this is equivalent to `===`, for\n * arrays the check would be performed on every item recursively, in order, and\n * for objects all props will be compared recursively.\n *\n * The built-in Date and RegExp are special-cased and will be compared by their\n * values.\n *\n * !IMPORTANT: TypedArrays and symbol properties of objects are not supported\n * right now and might result in unexpected behavior. Please open an issue in\n * the Remeda github project if you need support for these types.\n *\n * The result would be narrowed to the second value so that the function can be\n * used as a type guard.\n *\n * See:\n * - `isStrictEqual` if you don't need a deep comparison and just want to\n * check for simple (`===`, `Object.is`) equality.\n * - `isShallowEqual` if you need to compare arrays and objects \"by-value\" but\n * don't want to recurse into their values.\n *\n * @param other - The second value to compare.\n * @signature\n * R.isDeepEqual(other)(data)\n * @example\n * R.pipe(1, R.isDeepEqual(1)); //=> true\n * R.pipe(1, R.isDeepEqual('1')); //=> false\n * R.pipe([1, 2, 3], R.isDeepEqual([1, 2, 3])); //=> true\n * @dataLast\n * @category Guard\n */\nexport function isDeepEqual<T, S extends T>(\n other: T extends Exclude<T, S> ? S : never,\n): (data: T) => data is S;\nexport function isDeepEqual<T>(other: T): (data: T) => boolean;\n\nexport function isDeepEqual(...args: readonly unknown[]): unknown {\n return purry(isDeepEqualImplementation, args);\n}\n\nfunction isDeepEqualImplementation<T>(data: unknown, other: T): data is T {\n if (data === other) {\n return true;\n }\n\n if (Object.is(data, other)) {\n // We want to ignore the slight differences between `===` and `Object.is` as\n // both of them largely define equality from a semantic point-of-view.\n return true;\n }\n\n if (typeof data !== \"object\" || typeof other !== \"object\") {\n return false;\n }\n\n if (data === null || other === null) {\n return false;\n }\n\n if (Object.getPrototypeOf(data) !== Object.getPrototypeOf(other)) {\n // If the objects don't share a prototype it's unlikely that they are\n // semantically equal. It is technically possible to build 2 prototypes that\n // act the same but are not equal (at the reference level, checked