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

x/rimbu/core/main/index.ts>Update

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
type alias Update
Re-export
import { type Update } from "https://deno.land/x/rimbu@0.13.5/core/main/index.ts";

A value of type T, or a function taking a value of type T and returning a new value of type T.

definition: T | ((value: T) => T)
function Update
Re-export
import { Update } from "https://deno.land/x/rimbu@0.13.5/core/main/index.ts";

Returns the result of given update parameter, where it can either directly give a new value, or it is a function receiving the given value, and returns a new value.

Examples

Example 1

Update(1, 2)          // => 2
Update(1, () => 10)   // => 10
Update(1, v => v + 1) // => 2

Parameters

value: T
  • the current value
update: Update<T>
  • an Update value, either a new value or a function receiving the old value and returning a new one.