MCPcopy Create free account
hub / github.com/TanStack/query / cloneDeepUnref

Function cloneDeepUnref

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

Source from the content-addressed store, hash-verified

82 * be passed straight through to `@tanstack/query-core`.
83 */
84export function cloneDeepUnref<T>(
85 obj: MaybeRefDeep<T>,
86 unrefGetters = false,
87): T {
88 return cloneDeep(obj, (val, key, level) => {
89 // Check if we're at the top level and the key is 'queryKey'
90 //
91 // If so, take the recursive descent where we resolve
92 // getters to values as well as refs.
93 if (level === 1 && key === 'queryKey') {
94 return cloneDeepUnref(val, true)
95 }
96
97 // Resolve getters to values if specified.
98 if (unrefGetters && isFunction(val)) {
99 // Cast due to older TS versions not allowing calling
100 // on certain intersection types.
101 return cloneDeepUnref((val as Function)(), unrefGetters)
102 }
103
104 // Unref refs and continue to recurse into the value.
105 if (isRef(val)) {
106 return cloneDeepUnref(unref(val), unrefGetters)
107 }
108
109 return undefined
110 })
111}
112
113// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
114function 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