Open History to see the last commit
1---
2id: replaceEqualDeep
3title: replaceEqualDeep
4---
5β
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7β
8```ts
9function replaceEqualDeep<T>(
10 a: unknown,
11 b: T,
12 depth?: number
13): T;
14```
15β
16Defined in: [packages/query-core/src/utils.ts:388](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L388)
17β
18This function returns `a` if `b` is deeply equal.
19If not, it will replace any deeply equal children of `b` with those of `a`.
20This can be used for structural sharing between JSON values for example.
21β
22## Type Parameters
23β
24### T
25β
26`T`
27β
28## Parameters
29β
30### a
31β
32`unknown`
33β
34The previous value, whose deeply equal parts are reused.
35β
36### b
37β
38`T`
39β
40The new value.
41β
42### depth?
43β
44`number`
45β
46The current recursion depth. Past a depth of `500`, `b` is returned as is.
47β
48## Returns
49β
50`T`
51β
52`a` if `b` is deeply equal to it, otherwise `b` with its deeply equal parts replaced by
53those of `a`.