Skip to main content
Module

x/fun/decoder.ts>array

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 array
import { array } from "https://deno.land/x/fun@v2.0.0-alpha.10/decoder.ts";

A decoder against an array with only values that adhere to the passed in items decoder.

Examples

Example 1

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

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

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

Parameters

items: Decoder<unknown, A>

Returns

Decoder<unknown, ReadonlyArray<A>>