@f/clamp

1.0.0 • Public • Published

clamp

Build status Git tag NPM version Code style

Clamp a number between two values

Installation

$ npm install @f/clamp

Usage

var clamp = require('@f/clamp')

clamp(1, 2, 3) === 2
clamp(3, 1, 2) === 2
clamp(2, 1, 3) === 2

API

clamp(n, min, max)

  • n - The number to be clamped
  • min - The minimum value
  • max - The maximum value

Returns: If n is between min and max, returns n. If n is greater than max, returns max. If n is less than min, returns min.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @f/clamp

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • f