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

Function tryResolveSync

packages/query-core/src/hydration.ts:19–36  ·  view source on GitHub ↗
(promise: PromiseLike<unknown>)

Source from the content-addressed store, hash-verified

17type TransformerFn = (data: any) => any
18
19function tryResolveSync(promise: PromiseLike<unknown>) {
20 let data: unknown
21
22 const thenResult = promise.then((result) => {
23 data = result
24 return result
25 }, noop) as Promise<unknown> | undefined
26
27 // .catch can be unavailable on certain kinds of thenable's
28 // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
29 thenResult?.catch?.(noop)
30
31 if (data !== undefined) {
32 return { data }
33 }
34
35 return undefined
36}
37
38export interface DehydrateOptions {
39 serializeData?: TransformerFn

Callers 1

hydrateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected