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

struct

import { struct } from "https://raw.githubusercontent.com/baetheus/fun/main/sortable.ts";

Derives an Sortable from a structs of Sortables. The derived Sortable will compare two structs starting with the first defined key and return the first ordering that is non-zero, otherwise the two structs are equal.

@example
import { struct, lt } from "./sortable.ts"
import { SortableNumber } from "./number.ts";
import { SortableString } from "./string.ts";
import { pipe } from "./fn.ts";

const ord = struct({ num: SortableNumber, str: SortableString });
const _lt = lt(ord);

const result1 = pipe(
  { num: 1, str: "a" },
  _lt({ str: "b", num: 2 })
); // true
const result2 = pipe(
  { num: 1, str: "a" },
  _lt({ str: "b", num: 1 })
); // true
const result3 = pipe(
  { num: 1, str: "a" },
  _lt({ str: "a", num: 1 })
); // false

function struct<A>(sorts: readonly [K in keyof A]: Sortable<A[K]>): Sortable<readonly [K in keyof A]: A[K]>;
§
struct<A>(sorts: readonly [K in keyof A]: Sortable<A[K]>): Sortable<readonly [K in keyof A]: A[K]>
[src]

§Type Parameters

§Parameters

§
sorts: readonly [K in keyof A]: Sortable<A[K]>
[src]

§Return Type

§
Sortable<readonly [K in keyof A]: A[K]>
[src]