Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
throw new RangeError('Invalid interval')
}
max = Math.floor(max)
- if (min) {
+ if (min != null && min !== 0) {
if (max < min || min < 0) {
throw new RangeError('Invalid interval')
}
}
const randomPivotIndexSelect = (leftIndex, rightIndex) => {
- return generateRandomInteger(leftIndex, rightIndex)
+ return generateRandomInteger(rightIndex, leftIndex)
}
/**
*/
function getSecureRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) {
max = Math.floor(max)
- if (min) {
+ if (min != null && min !== 0) {
min = Math.ceil(min)
return Math.floor(secureRandom() * (max - min + 1)) + min
}
*/
function getRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) {
max = Math.floor(max)
- if (min) {
+ if (min != null && min !== 0) {
min = Math.ceil(min)
return Math.floor(Math.random() * (max - min + 1)) + min
}