Skip to main content
Module

x/rambda/source/clamp.js

Faster and smaller alternative to Ramda
Go to Latest
File
import {curry} from './curry'
function clampFn(min, max, input) { if (min > max) { throw new Error( 'min must not be greater than max in clamp(min, max, value)' ) } if (input >= min && input <= max) return input
if (input > max) return max if (input < min) return min}
export const clamp = curry(clampFn)