Skip to main content
Module

x/rimbu/mod.ts>Path.update

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

Sets the value at the given path in the source to the given value.

Examples

Example 1

console.log(Path.update({ a: { b: { c: 5 } } }, 'a.b.c', v => v + 5)
// => { a: { b: { c: 6 } } }

Type Parameters

T
optional
P extends Path<T> = Path<T>

Parameters

source: T & PlainObj<T>
  • the object to update
path: P
  • the path in the object to update
value: Update<Path.Result<T, P>>
  • the new value to set at the given position