repositories
/
benchmarks-js.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #116 from jerome-benoit/dependabot/npm_and_yarn/eslint-plugin...
[benchmarks-js.git]
/
random.mjs
diff --git
a/random.mjs
b/random.mjs
index 70d48c0a53fbf6084db9481a12e9dee865fb969e..f01ab2ba009d3c20c03627f259d9d6849cf7f837 100644
(file)
--- a/
random.mjs
+++ b/
random.mjs
@@
-17,7
+17,7
@@
function getSecureRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) {
throw new RangeError('Invalid interval')
}
max = Math.floor(max)
throw new RangeError('Invalid interval')
}
max = Math.floor(max)
- if (min !=
null && min !=
= 0) {
+ if (min !== 0) {
min = Math.ceil(min)
return Math.floor(secureRandom() * (max - min + 1)) + min
}
min = Math.ceil(min)
return Math.floor(secureRandom() * (max - min + 1)) + min
}
@@
-37,7
+37,7
@@
function getSecureRandomIntegerWithRandomValues (
throw new RangeError('Invalid interval')
}
max = Math.floor(max)
throw new RangeError('Invalid interval')
}
max = Math.floor(max)
- if (min !=
null && min !=
= 0) {
+ if (min !== 0) {
min = Math.ceil(min)
return Math.floor(secureRandomWithRandomValues() * (max - min + 1)) + min
}
min = Math.ceil(min)
return Math.floor(secureRandomWithRandomValues() * (max - min + 1)) + min
}
@@
-54,7
+54,7
@@
function getRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) {
throw new RangeError('Invalid interval')
}
max = Math.floor(max)
throw new RangeError('Invalid interval')
}
max = Math.floor(max)
- if (min !=
null && min !=
= 0) {
+ if (min !== 0) {
min = Math.ceil(min)
return Math.floor(Math.random() * (max - min + 1)) + min
}
min = Math.ceil(min)
return Math.floor(Math.random() * (max - min + 1)) + min
}
@@
-74,7
+74,7
@@
Benchmark.suite(
),
Benchmark.add('Crypto random integer generator', (max = maximum, min = 0) => {
max = Math.floor(max)
),
Benchmark.add('Crypto random integer generator', (max = maximum, min = 0) => {
max = Math.floor(max)
- if (min !=
null && min !=
= 0) {
+ if (min !== 0) {
min = Math.ceil(min)
return Math.floor(randomInt(min, max + 1))
}
min = Math.ceil(min)
return Math.floor(randomInt(min, max + 1))
}
@@
-100,6
+100,4
@@
Benchmark.suite(
format: 'table.html',
details: true
})
format: 'table.html',
details: true
})
-).catch(err => {
- console.error(err)
-})
+).catch(console.error)