From 7b99d70d989221964bcaa964d52b9ad826f101a0 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 21 Oct 2016 17:01:55 +0200 Subject: [PATCH] feat(utils.js): improve `genRandomNumberBetweenIntervals` performances --- tests/ui/scripts/Utils/utils.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/ui/scripts/Utils/utils.js b/tests/ui/scripts/Utils/utils.js index 81aa56bfe..0fc3ec04f 100644 --- a/tests/ui/scripts/Utils/utils.js +++ b/tests/ui/scripts/Utils/utils.js @@ -142,6 +142,10 @@ function genRandomNumber (min, max) { // The `intervals` param must be orderer like this: // `[ [ 1, 4 ], [ 8, 16 ], [ 22, 25 ] ]` function genRandomNumberBetweenIntervals (intervals) { + if (intervals.length === 1) { + return genRandomNumber(intervals[0][0], intervals[0][1]) + } + // Compute the number of values. var size = 0 intervals.forEach(function (interval) {