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
immosquare-cleaner-0.1.60 node_modules/lodash/clamp.js
immosquare-cleaner-0.1.59 node_modules/lodash/clamp.js
immosquare-cleaner-0.1.58 node_modules/lodash/clamp.js
immosquare-cleaner-0.1.57 node_modules/lodash/clamp.js
immosquare-cleaner-0.1.56 node_modules/lodash/clamp.js
immosquare-cleaner-0.1.55 node_modules/lodash/clamp.js
immosquare-cleaner-0.1.54 node_modules/lodash/clamp.js
immosquare-cleaner-0.1.53 node_modules/lodash/clamp.js
immosquare-cleaner-0.1.52 node_modules/lodash/clamp.js
trusty-cms-6.3.1 node_modules/lodash/clamp.js
immosquare-cleaner-0.1.51 node_modules/lodash/clamp.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/lodash/clamp.js
clapton-0.0.26 lib/clapton/javascripts/node_modules/lodash/clamp.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/lodash/clamp.js
immosquare-cleaner-0.1.50 node_modules/lodash/clamp.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/lodash/clamp.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/lodash/clamp.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/lodash/clamp.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/lodash/clamp.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/lodash/clamp.js