Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/deep/internal.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@1.0.4/deep/internal.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