Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fun/sortable.ts>clamp

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

Construct an inclusive clamp function over A from Sortable.

Examples

Example 1

import * as O from "./sortable.ts";
import { SortableNumber } from "./number.ts";

const clamp = O.clamp(SortableNumber);
const clamp1 = clamp(0, 10)

const result1 = clamp1(-1); // 0
const result2 = clamp1(1); // 1
const result3 = clamp1(100); // 10

Returns

(low: A, high: A) => (value: A) => A