Skip to main content
Module

x/fun/record.ts>insertAt

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

Insert a value A into a ReadonlyRecord at the key location. If the value inserted has object equality with the current value in the record then no change is made and the original record is returned. This is the same function as insert but with the order of parameters swapped

Examples

Example 1

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

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

const result1 = pipe(
  { one: 1, two: 2 },
  atOne(1),
); // No Mutation, returns original object
const result2 = pipe(
  { two: 2 },
  atOne(1),
); // { one: 1, two: 2 }

Parameters

key: string