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

Function setNestedValue

packages/db/src/query/live/collection-config-builder.ts:2243–2262  ·  view source on GitHub ↗
(
  target: Record<string, any>,
  path: Array<string>,
  value: unknown,
)

Source from the content-addressed store, hash-verified

2241}
2242
2243function setNestedValue(
2244 target: Record<string, any>,
2245 path: Array<string>,
2246 value: unknown,
2247): void {
2248 if (path.length === 0) {
2249 return
2250 }
2251
2252 let cursor = target
2253 for (let i = 0; i < path.length - 1; i++) {
2254 const segment = path[i]!
2255 const next = cursor[segment]
2256 if (next == null || typeof next !== `object`) {
2257 cursor[segment] = {}
2258 }
2259 cursor = cursor[segment]
2260 }
2261 cursor[path[path.length - 1]!] = value
2262}
2263
2264function cloneForIncludesUpdate<T extends Record<string, any>>(
2265 target: T,

Callers 1

setIncludedValueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected