Skip to main content
Module

x/fun/mod.ts>refinement.literal

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

Creates an instance of Refinement<unknown, P> where P is a union of literal values.

Examples

Example 1

import * as R from "./refinement.ts";

const places = R.literal(1, 2, 3);

const result1 = places(null); // false
const result2 = places(1); // true, variable now typed as 1 | 2 | 3
const result3 = places(2); // true, variable now typed as 1 | 2 | 3
const result4 = places(10); // false

Type Parameters

A extends NonEmptyArray<Literal>

Parameters

...literals: A

Returns

Refinement<unknown, A[number]>