Skip to main content
Module

x/fun/optic.ts>key

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

A composible combinator that focuses on a key in a readonly record.

Examples

Example 1

import * as O from "./optic.ts";
import { pipe } from "./fn.ts";

const one = pipe(
  O.id<Readonly<Record<string, string>>>(),
  O.key("one"),
);

const result1 = pipe(one, O.view({})); // None
const result2 = pipe(one, O.view({ one: "one" })); // Some("one")

Parameters

key: string

Returns

<U extends Tag, S, A>(first: Optic<U, S, ReadonlyRecord<A>>) => Optic<Align<U, AffineTag>, S, A>