diff --git a/src/sequencer.ts b/src/sequencer.ts index d9d5482..31dcb2e 100644 --- a/src/sequencer.ts +++ b/src/sequencer.ts @@ -2,6 +2,7 @@ import { OpenWeatherAPI, type DailyWeather } from 'openweather-api-node'; import { voiceLines } from './voice.js'; import type { Config } from './index.js'; import type { Voice } from './voice.js'; +import crypto from 'crypto'; type SegmentName = string; type SequenceName = string; @@ -16,7 +17,7 @@ type Sequences = { [sequence: SequenceName]: Sequence }; let config: Config = null; function selectOne(arr: T[]): T { - return arr[Math.floor(Math.random() * arr.length)]; + return arr[crypto.randomInt(0, arr.length)]; } function resolveSide(side: string, currentWeather: DailyWeather) { diff --git a/test/sequencer.test.ts b/test/sequencer.test.ts index 60187c6..d50c54a 100644 --- a/test/sequencer.test.ts +++ b/test/sequencer.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it, vi } from 'vitest'; -import { type CurrentWeather, type Options } from 'openweather-api-node'; +import { type Options } from 'openweather-api-node'; import { Sequencer } from '../src/sequencer.js'; -import type { Config } from '../src/index.js'; const dummyWeather: Options = { key: 'dummy' };