Skip to main content
Module

x/fun/decoder.ts>record

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

A decoder against a record with string keys and values that match the items decoder.

Examples

Example 1

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

const strings = D.record(D.string);

const result1 = strings(null); // Left(DecodeError)
const result2 = strings({}); // Right({})
const result3 = strings([]); // Right({})
const result4 = strings({"one": 1}); // Left(DecodeError)
const result5 = strings({ one: "one" }); // Right({ one: "one" })

Parameters

items: Decoder<unknown, A>