| 1 | /** |
| 2 | * @param max |
| 3 | * @param min |
| 4 | */ |
| 5 | function 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 | |
| 12 | /** |
| 13 | * @param ms |
| 14 | */ |
| 15 | async function sleep (ms) { |
| 16 | return new Promise(resolve => setTimeout(resolve, ms)) |
| 17 | } |
| 18 | |
| 19 | const LIST_FORMATTER = new Intl.ListFormat('en-US', { |
| 20 | style: 'long', |
| 21 | type: 'conjunction' |
| 22 | }) |
| 23 | |
| 24 | module.exports = { generateRandomInteger, sleep, LIST_FORMATTER } |