MCPcopy
hub / github.com/TanStack/query / cloneDeepUnref

Function cloneDeepUnref

packages/vue-query/src/utils.ts:70–97  ·  view source on GitHub ↗
(
  obj: MaybeRefDeep<T>,
  unrefGetters = false,
)

Source from the content-addressed store, hash-verified

68}
69
70export function cloneDeepUnref<T>(
71 obj: MaybeRefDeep<T>,
72 unrefGetters = false,
73): T {
74 return cloneDeep(obj, (val, key, level) => {
75 // Check if we're at the top level and the key is 'queryKey'
76 //
77 // If so, take the recursive descent where we resolve
78 // getters to values as well as refs.
79 if (level === 1 && key === 'queryKey') {
80 return cloneDeepUnref(val, true)
81 }
82
83 // Resolve getters to values if specified.
84 if (unrefGetters && isFunction(val)) {
85 // Cast due to older TS versions not allowing calling
86 // on certain intersection types.
87 return cloneDeepUnref((val as Function)(), unrefGetters)
88 }
89
90 // Unref refs and continue to recurse into the value.
91 if (isRef(val)) {
92 return cloneDeepUnref(unref(val), unrefGetters)
93 }
94
95 return undefined
96 })
97}
98
99// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
100function isPlainObject(value: unknown): value is Object {

Callers 15

isFetchingMethod · 0.90
isMutatingMethod · 0.90
getQueryDataMethod · 0.90
ensureQueryDataMethod · 0.90
getQueriesDataMethod · 0.90
setQueryDataMethod · 0.90
setQueriesDataMethod · 0.90
getQueryStateMethod · 0.90
removeQueriesMethod · 0.90
resetQueriesMethod · 0.90
cancelQueriesMethod · 0.90
invalidateQueriesMethod · 0.90

Calls 2

cloneDeepFunction · 0.85
isFunctionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…