Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

getComparableEither

import { getComparableEither } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/either.ts";

Create a Comparable instance for Either given Comparable instances for both Left and Right types. Left values are compared before Right values.

@example
import * as E from "./either.ts";
import * as S from "./string.ts";
import * as N from "./number.ts";

const comparableEither = E.getComparableEither(S.ComparableString, N.ComparableNumber);

const result1 = comparableEither.compare(E.right(5))(E.right(3));
// true (5 > 3)

const result2 = comparableEither.compare(E.left("a"))(E.left("b"));
// false ("a" < "b")

const result3 = comparableEither.compare(E.right(5))(E.left("error"));
// false (Right comes after Left)
function getComparableEither<A, B>(SB: Comparable<B>, SA: Comparable<A>): Comparable<Either<B, A>>;
§
getComparableEither<A, B>(SB: Comparable<B>, SA: Comparable<A>): Comparable<Either<B, A>>
[src]

§Type Parameters

§Parameters

§Return Type