Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.clamp

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.clamp

The lodash method `_.clamp` exported as a module.

  • 4.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
126K
increased by1.28%
Maintainers
3
Weekly downloads
 
Created

What is lodash.clamp?

The lodash.clamp package is a utility function that clamps a number within the inclusive lower and upper bounds. It is part of the Lodash library, which provides utility functions for common programming tasks.

What are lodash.clamp's main functionalities?

Clamping a number within a range

This feature allows you to clamp a number within a specified range. In this example, the number 10 is clamped to the upper bound of 5.

const clamp = require('lodash.clamp');

const result = clamp(10, 0, 5);
console.log(result); // Output: 5

Clamping a number to the lower bound

This feature allows you to clamp a number to the lower bound if it is below the specified range. In this example, the number -5 is clamped to the lower bound of 0.

const clamp = require('lodash.clamp');

const result = clamp(-5, 0, 5);
console.log(result); // Output: 0

Clamping a number within a range where it is already within bounds

This feature allows you to clamp a number that is already within the specified range. In this example, the number 3 remains unchanged as it is within the range of 0 to 5.

const clamp = require('lodash.clamp');

const result = clamp(3, 0, 5);
console.log(result); // Output: 3

Other packages similar to lodash.clamp

Keywords

FAQs

Package last updated on 13 Aug 2016

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc