import { comparable } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { readonly } = comparable;
Create a Comparable that casts the inner type of another Comparable to Readonly.
Examples
Example 1
Example 1
import { readonly, fromCompare } from "./comparable.ts";
// This has type Comparable<Array<string>>
const ComparableMutableArray = fromCompare<Array<string>>(
(second) => (first) => first.length === second.length
&& first.every((value, index) => value === second[index])
);
// This has type Comparable<Readonly<Array<string>>>
const ComparableReadonlyArray = readonly(ComparableMutableArray);
Parameters
comparable: Comparable<A>
Returns
Comparable<Readonly<A>>