Socket
Book a DemoInstallSign in
Socket

js-clamp

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-clamp

Clamp a number between two other numbers

1.0.1
latest
npmnpm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

math

FAQs

Package last updated on 16 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.