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

x/rimbu/deep/deep.ts>patchAtWith

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

Returns a function that patches a given value with the given patchItems at the given path.

Examples

Example 1

const items = [{ a: { b:  1, c: 'a' } }, { a: { b: 2, c: 'b' } }];
items.map(Deep.patchAtWith('a', [{ b: (v) => v + 1 }]));
// => [{ a: { b: 2, c: 'a' } }, { a: { b: 3, c: 'b' } }]

Type Parameters

T
P extends Path.Set<T>
optional
TE extends T = T
optional
TT = T

Parameters

path: P
  • the string path in the object
patchItem: Patch<Path.Result<TE, P>, Path.Result<TT, P>>
  • the Patch definition to update the value at the given path in T with.

Returns

(source: T) => T