From cabd4198b04569f0745d57e3de16dcb44a5ed260 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 23 Oct 2015 16:25:22 -0700 Subject: [PATCH] Remove `nativeMax` and `nativeMin` use from `_.clamp`. --- lodash.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lodash.js b/lodash.js index 21a16803d..94854d52e 100644 --- a/lodash.js +++ b/lodash.js @@ -10986,17 +10986,22 @@ * // => 5 */ function clamp(number, min, max) { - if (max === undefined) { - max = min; - min = undefined; - } - if (max !== undefined) { - max = +max; - number = nativeMin(number, max === max ? max : 0); - } - if (min !== undefined) { - min = +min; - number = nativeMax(number, min === min ? min : 0); + number = +number; + if (number === number) { + if (max === undefined) { + max = min; + min = undefined; + } + if (max !== undefined) { + max = +max; + max = max === max ? max : 0; + number = number <= max ? number : max; + } + if (min !== undefined) { + min = +min; + min = min === min ? min : 0; + number = number >= min ? number : min; + } } return number; }