| 17 | type TransformerFn = (data: any) => any |
| 18 | |
| 19 | function 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 | |
| 38 | export interface DehydrateOptions { |
| 39 | serializeData?: TransformerFn |