Skip to main content
Module

x/fun/record.ts>updateAt

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function updateAt
import { updateAt } from "https://deno.land/x/fun@v2.0.0-alpha.10/record.ts";

Update a ReadonlyRecord at key with a value A. The record will only be updated if it already holds the specified key, otherwise no changes are made. This function does the same as update but has the parameters switched in order

Examples

Example 1

import * as R from "./record.ts";
import { pipe } from "./fn.ts";

const atOne = R.updateAt('one');

const result1 = pipe(
  { one: 1, two: 2 },
  atOne(2),
); // { one: 2, two: 2 }
const result2 = pipe(
  { two: 2 },
  atOne(2),
); // No change { two: 2 }

Parameters

key: string