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

lazy

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

Create a lazy Comparable that defers evaluation.

@example
import { lazy, intersect, struct, partial, string, Comparable } from "./comparable.ts";
import { pipe } from "./fn.ts";

type Person = { name: string, child?: Person };

// Annotating the type is required for recursion
const person: Comparable<Person> = lazy('Person', () => pipe(
  struct({ name: string }),
  intersect(partial({ child: person }))
));

const icarus = { name: "Icarus" };
const daedalus = { name: "Daedalus", child: icarus };

const result1 = person.compare(icarus)(daedalus); // false
const result2 = person.compare(daedalus)(daedalus); // true
function lazy<A>(_: string, f: () => Comparable<A>): Comparable<A>;
§
lazy<A>(_: string, f: () => Comparable<A>): Comparable<A>
[src]

§Type Parameters

§Parameters

§
_: string
[src]
§
f: () => Comparable<A>
[src]

§Return Type