Skip to main content
Module

x/fun/record.ts>update

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 update
import { update } 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.

Examples

Example 1

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

const to2 = R.update(2);

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