js-clamp

1.0.1 • Public • Published

js-clamp

A simple NodeJS module that clamps a number between two other numbers

How to use

require("js-clamp");

const number = 50;

console.log(number.clamp(30, 60));

or

require("js-clamp");

const number = 50;

console.log(Math.clamp(number, 30, 60));

or

const clamp = require("js-clamp");
// alternatively you can do:
// const { clamp } = require("js-clamp");

const number = 50;

console.log(clamp(30, 60));

When not given enough arguments or if one of them is NaN, the return value is NaN

Package Sidebar

Install

npm i js-clamp

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

1.3 kB

Total Files

3

Last publish

Collaborators

  • erdi