MCPcopy Create free account
hub / github.com/TanStack/db / convertPartial

Function convertPartial

packages/trailbase-db-collection/src/trailbase.ts:70–85  ·  view source on GitHub ↗
(
  conversions: Conversions<InputType, OutputType>,
  input: Partial<InputType>,
)

Source from the content-addressed store, hash-verified

68}
69
70function convertPartial<
71 InputType extends ShapeOf<OutputType> & Record<string, unknown>,
72 OutputType extends ShapeOf<InputType>,
73>(
74 conversions: Conversions<InputType, OutputType>,
75 input: Partial<InputType>,
76): Partial<OutputType> {
77 const c = conversions as Record<string, Conversion<InputType, OutputType>>
78
79 return Object.fromEntries(
80 Object.keys(input).map((k: string) => {
81 const value = input[k]
82 return [k, c[k]?.(value as any) ?? value]
83 }),
84 ) as OutputType
85}
86
87export type TrailBaseSyncMode = SyncMode
88

Callers 1

serialUpdFunction · 0.85

Calls 2

mapMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected