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

x/rimbu/deep/internal.ts>Deep.patchAtWith

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

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