Sha256: 9f0074b089c0de70fe3e80ccbb6ac8e108c51b0e7447ce5e820d8220443d1d18

Contents?: true

Size: 890 Bytes

Versions: 300

Compression:

Stored size: 890 Bytes

Contents

var baseClamp = require('./_baseClamp'),
    toNumber = require('./toNumber');

/**
 * Clamps `number` within the inclusive `lower` and `upper` bounds.
 *
 * @static
 * @memberOf _
 * @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) {
  if (upper === undefined) {
    upper = lower;
    lower = undefined;
  }
  if (upper !== undefined) {
    upper = toNumber(upper);
    upper = upper === upper ? upper : 0;
  }
  if (lower !== undefined) {
    lower = toNumber(lower);
    lower = lower === lower ? lower : 0;
  }
  return baseClamp(toNumber(number), lower, upper);
}

module.exports = clamp;

Version data entries

300 entries across 276 versions & 32 rubygems

Version Path
locomotivecms-3.4.0 app/javascript/node_modules/lodash/clamp.js
cortex-0.1.3 spec/dummy/node_modules/lodash/clamp.js
sumomo-0.8.3 data/sumomo/api_modules/node_modules/lodash/clamp.js
sumomo-0.8.2 data/sumomo/api_modules/node_modules/lodash/clamp.js
sumomo-0.8.1 data/sumomo/api_modules/node_modules/lodash/clamp.js
condenser-0.0.4 lib/condenser/processors/node_modules/lodash/clamp.js
ela-4.0.0 node_modules/lodash/clamp.js
ela-3.4.3 node_modules/lodash/clamp.js
ela-3.4.2 node_modules/lodash/clamp.js
ela-3.4.0 node_modules/lodash/clamp.js
ela-3.3.1 node_modules/lodash/clamp.js
dragonfly_puppeteer-0.1.0 node_modules/lodash/clamp.js
ela-3.3.0 node_modules/lodash/clamp.js
ela-3.2.0 node_modules/lodash/clamp.js
ela-3.1.1 node_modules/lodash/clamp.js
ela-3.1.0 node_modules/lodash/clamp.js
ela-3.0.0 node_modules/lodash/clamp.js
ela-2.0.0 node_modules/lodash/clamp.js
ela-1.1.0 node_modules/lodash/clamp.js
sumomo-0.8.0 data/sumomo/api_modules/node_modules/lodash/clamp.js