Link Search Menu Expand Document

Table of contents


clamp (function)

Similar to R.clamp, but:

  • requires an explicit Ord<A> instance, thus it supports any A not just “JS ordered types”
  • doesn’t throw if min > max (returns min instead)

Signature

export function clamp<A>(
  O: Ord<A>
): {
  (low: A): {
    (hi: A): (x: A) => A;
    (hi: A, x: A): A;
  };
  (low: A, hi: A): (x: A) => A;
  (low: A, hi: A, x: A): A;
}; { ... }

Added in v0.1.2