From 0369bf7afe049791e9dcc6c3cbac6ba2d3be0dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Lipi=C5=84ski?= Date: Sat, 18 Feb 2017 16:40:38 +0100 Subject: [PATCH] Replace one time used variables with their original refs in `random`. --- random.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/random.js b/random.js index 8ebaa701f..6a8ffb31b 100644 --- a/random.js +++ b/random.js @@ -5,9 +5,7 @@ import toFinite from './toFinite.js' const freeParseFloat = parseFloat /* Built-in method references for those with the same name as other `lodash` methods. */ -const nativeMin = Math.min const nativeRandom = Math.random -const nativeFloor = Math.floor /** * Produces a random number between the inclusive `lower` and `upper` bounds. @@ -74,9 +72,9 @@ function random(lower, upper, floating) { if (floating || lower % 1 || upper % 1) { const rand = nativeRandom() const randLength = `${ rand }`.length - 1 - return nativeMin(lower + (rand * (upper - lower + freeParseFloat(`1e-${ randLength }`)), upper)) + return Math.min(lower + (rand * (upper - lower + freeParseFloat(`1e-${ randLength }`)), upper)) } - return lower + nativeFloor(nativeRandom() * (upper - lower + 1)) + return lower + Math.floor(nativeRandom() * (upper - lower + 1)) } export default random