Skip to main content
Module

x/rimbu/mod.ts>Deep.patchAt

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function Deep.patchAt
import { Deep } from "https://deno.land/x/rimbu@0.14.0/mod.ts";
const { patchAt } = Deep;

Patches the value at the given path in the source to the given value. Because the path to update must exist in the source object, optional chaining and array indexing is not allowed.

Examples

Example 1

const value = { a: { b: { c: 5 } } };
Deep.patchAt(value, 'a.b.c', v => v + 5);
// => { a: { b: { c: 6 } } }

Type Parameters

T
P extends Path.Set<T>
optional
C = Path.Result<T, P>

Parameters

source: T
  • the object to update
path: P
  • the path in the object to update
patchItem: Patch<Path.Result<T, P>, Path.Result<T, P> & C>
  • the patch for the value at the given path