( obj: MaybeRefDeep<T>, unrefGetters = false, )
| 111 | * @returns The cloned value, with `ref`s unwrapped. |
| 112 | */ |
| 113 | export function cloneDeepUnref<T>( |
| 114 | obj: MaybeRefDeep<T>, |
| 115 | unrefGetters = false, |
| 116 | ): T { |
| 117 | return cloneDeep(obj, (val, key, level) => { |
| 118 | // Check if we're at the top level and the key is 'queryKey' |
| 119 | // |
| 120 | // If so, take the recursive descent where we resolve |
| 121 | // getters to values as well as refs. |
| 122 | if (level === 1 && key === 'queryKey') { |
| 123 | return cloneDeepUnref(val, true) |
| 124 | } |
| 125 | |
| 126 | // Resolve getters to values if specified. |
| 127 | if (unrefGetters && isFunction(val)) { |
| 128 | // Cast due to older TS versions not allowing calling |
| 129 | // on certain intersection types. |
| 130 | return cloneDeepUnref((val as () => any)(), unrefGetters) |
| 131 | } |
| 132 | |
| 133 | // Unref refs and continue to recurse into the value. |
| 134 | if (isRef(val)) { |
| 135 | return cloneDeepUnref(unref(val), unrefGetters) |
| 136 | } |
| 137 | |
| 138 | return undefined |
| 139 | }) |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Checks whether a value is a plain object, created with an object literal or |
no test coverage detected