1.0.0 • Published 8 years ago

@f/clamp v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

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