COLLECTED BY
Organization:
Internet Archive
Focused crawls are collections of frequently-updated webcrawl data from narrow (as opposed to broad or wide) web crawls, often focused on a single domain or subdomain.
The Wayback Machine - https://web.archive.org/web/20201220220313/https://github.com/lodash/lodash/blob/master/clamp.js
Permalink
Cannot retrieve contributors at this time
31 lines (30 sloc)
708 Bytes
/**
* Clamps `number` within the inclusive `lower` and `upper` bounds.
*
* @since 4.0.0
* @category Number
* @param {number } number The number to clamp.
* @param {number } lower The lower bound.
* @param {number } upper The upper bound.
* @returns {number } Returns the clamped number.
* @example
*
* clamp(-10, -5, 5)
* // => -5
*
* clamp(10, -5, 5)
* // => 5
*/
function clamp ( number , lower , upper ) {
number = + number
lower = + lower
upper = + upper
lower = lower === lower ? lower : 0
upper = upper === upper ? upper : 0
if ( number === number ) {
number = number <= upper ? number : upper
number = number >= lower ? number : lower
}
return number
}
export default clamp
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.