feat(utils.js): improve genRandomNumberBetweenIntervals performances

This commit is contained in:
Ronan Abhamon 2016-10-21 17:01:55 +02:00
parent b8218a33d5
commit 7b99d70d98

View file

@ -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) {