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

x/rimbu/deep/tuple.ts>Tuple.updateAt

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

Returns a copy of the given tuple where the element at given index is updated with the given updater.

Examples

Example 1

const t = Tuple.of(1, 'a', true)
console.log(Tuple.updateAt(t, 1, 'b'))
// => [1, 'b', true]

Type Parameters

T extends Tuple.Source
optional
K extends keyof T = keyof T

Parameters

tuple: T
  • the source tuple
index: K
  • the index in the tuple
updater: Update<T[K]>
  • the updater for the value