- suite
- .on('cycle', event => {
- console.info(event.target.toString())
- })
- .on('complete', async function () {
- console.info(
- 'Fastest is ' +
- LIST_FORMATTER.format(this.filter('fastest').map('name'))
- )
- await pool.destroy()
- resolve()
- })
- .run({ async: true })
- } catch (error) {
- reject(error)
- }
- })
-}
-
-export const LIST_FORMATTER = new Intl.ListFormat('en-US', {
- style: 'long',
- type: 'conjunction'
-})
-
-export const executeAsyncFn = async fn => {
- try {
- await fn()
- } catch (e) {
- console.error(e)
- // eslint-disable-next-line n/no-process-exit
- process.exit(1)
- }
-}
-
-export const generateRandomInteger = (
- max = Number.MAX_SAFE_INTEGER,
- min = 0
-) => {
- if (max < min || max < 0 || min < 0) {
- throw new RangeError('Invalid interval')
- }
- max = Math.floor(max)
- if (min != null && min !== 0) {
- min = Math.ceil(min)
- return Math.floor(Math.random() * (max - min + 1)) + min
- }
- return Math.floor(Math.random() * (max + 1))
-}
-
-const jsonIntegerSerialization = n => {
- for (let i = 0; i < n; i++) {
- const o = {
- a: i