From f0c38a6419f9d0bc1e70c03529608e6ae8bf5ec5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 21 Oct 2015 22:11:41 -0700 Subject: [PATCH] Use `_.clamp` in `_.sampleSize`, `_.endsWith`, and `_.startsWith`. --- lodash.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lodash.js b/lodash.js index d20a62a2b..8cea06fc8 100644 --- a/lodash.js +++ b/lodash.js @@ -7349,7 +7349,7 @@ length = result.length, lastIndex = length - 1; - n = nativeMin(nativeMax(toInteger(n), 0), length); + n = clamp(toInteger(n), 0, length); while (++index < n) { var rand = baseRandom(index, lastIndex), value = result[rand]; @@ -11134,7 +11134,7 @@ var length = string.length; position = position === undefined ? length - : nativeMin(nativeMax(toInteger(position), 0), length); + : clamp(toInteger(position), 0, length); position -= target.length; return position >= 0 && string.indexOf(target, position) == position; @@ -11518,7 +11518,7 @@ */ function startsWith(string, target, position) { string = toString(string); - position = nativeMin(nativeMax(toInteger(position), 0), string.length); + position = clamp(toInteger(position), 0, string.length); return string.lastIndexOf(target, position) == position; }