1.0.1 • Published 3 years ago

js-clamp v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

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