import { decoder } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { union } = decoder;
Provide an alternative Decoder to fallback against if the first one fails. This is an alias of alt.
Examples
Example 1
Example 1
import * as D from "./decoder.ts";
import { pipe } from "./fn.ts";
const numOrStr = pipe(
D.string,
D.union(D.number),
);
const result1 = numOrStr(0); // Right(0)
const result2 = numOrStr("Hello"); // Right("Hello")
const result3 = numOrStr(null); // Left(DecodeError)