import { decoder } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { nullable } = decoder;
A decoder combinator that modifies an existing decoder to accept null as an input value and a successful return value.
Examples
Example 1
Example 1
import * as D from "./decoder.ts";
const orNull = D.nullable(D.string);
const result1 = orNull(null); // Right(null)
const result2 = orNull(2); // Left(DecodeError)
const result3 = orNull("Hello"); // Right("Hello")