replace Math.random() with crypto.randomInt()
This commit is contained in:
@@ -2,6 +2,7 @@ import { OpenWeatherAPI, type DailyWeather } from 'openweather-api-node';
|
|||||||
import { voiceLines } from './voice.js';
|
import { voiceLines } from './voice.js';
|
||||||
import type { Config } from './index.js';
|
import type { Config } from './index.js';
|
||||||
import type { Voice } from './voice.js';
|
import type { Voice } from './voice.js';
|
||||||
|
import crypto from 'crypto';
|
||||||
|
|
||||||
type SegmentName = string;
|
type SegmentName = string;
|
||||||
type SequenceName = string;
|
type SequenceName = string;
|
||||||
@@ -16,7 +17,7 @@ type Sequences = { [sequence: SequenceName]: Sequence };
|
|||||||
let config: Config = null;
|
let config: Config = null;
|
||||||
|
|
||||||
function selectOne<T>(arr: T[]): T {
|
function selectOne<T>(arr: T[]): T {
|
||||||
return arr[Math.floor(Math.random() * arr.length)];
|
return arr[crypto.randomInt(0, arr.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveSide(side: string, currentWeather: DailyWeather) {
|
function resolveSide(side: string, currentWeather: DailyWeather) {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import { describe, expect, it, vi } from 'vitest';
|
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 { Sequencer } from '../src/sequencer.js';
|
||||||
import type { Config } from '../src/index.js';
|
|
||||||
|
|
||||||
const dummyWeather: Options = { key: 'dummy' };
|
const dummyWeather: Options = { key: 'dummy' };
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user