Skip to main content
Module

x/fun/record.ts>modifyAt

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

Modify a value A into a ReadonlyRecord at the key location. If the object does not hold the specified key then no change is made. This is the same function as modify with the order of parameters flipped.

Examples

Example 1

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

const inc = (n: number) => n + 1;
const atOne = R.modifyAt('one');

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

Parameters

key: string