Skip to main content
Module

x/fun/decoder.ts>partial

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function partial
import { partial } from "https://deno.land/x/fun@v2.0.0/decoder.ts";

A decoder over a heterogenous record type. This struct can have different values at each key or the key can not exist or the value can be undefined, and the resultant decoder will ensure that each key matches its corresponding decoder.

Examples

Example 1

import * as D from "./decoder.ts";

const person = D.partial({ name: D.string, age: D.number });

const result1 = person({}); // Right({})
const result2 = person(null); // Left(DecodeError)
const result3 = person({ name: "Brandon" }); // Right({ name: "Brandon" })
const result4 = person({ name: "Brandon", age: 37 });
// Right({ name: "Brandon", age: 37 })

Parameters

items: [K in keyof A]: Decoder<unknown, A[K]>

Returns

Decoder<unknown, readonly [K in keyof A]?: A[K]>