Keep the dummy busy wait timeout implementation as a reference.
[benchmarks-js.git] / benchmark-utils.js
CommitLineData
e9bfc28e
JB
1/**
2 * @param max
3 * @param min
4 */
ed2968f2
JB
5function generateRandomInteger (max, min = 0) {
6 if (min) {
7 return Math.floor(Math.random() * (max - min + 1) + min)
8 }
9 return Math.floor(Math.random() * max + 1)
10}
11
a9c78d5d
JB
12/**
13 * @param ms
14 */
15async function sleep (ms) {
16 return new Promise(resolve => setTimeout(resolve, ms))
17}
18
ed2968f2
JB
19const LIST_FORMATTER = new Intl.ListFormat('en-US', {
20 style: 'long',
21 type: 'conjunction'
22})
23
a9c78d5d 24module.exports = { generateRandomInteger, sleep, LIST_FORMATTER }