import { optic } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { props } = optic;
A composible combinator that focuses on a list of properties of a struct.
Examples
Example 1
Example 1
import * as O from "./optic.ts";
import { pipe } from "./fn.ts";
type Book = {
title: string,
description: string,
authors: readonly string[],
published: Date,
};
const short = pipe(O.id<Book>(), O.props("title", "description"));
const suttree: Book = {
title: "Suttree",
description: "Cormac on Cormac",
authors: ["Cormac McCarthy"],
published: new Date("May 01 1979"),
};
const result1 = pipe(short, O.view(suttree));
// { title: "Suttree", description: "Cormac on Cormac" }
Type Parameters
P extends keyof A