chore: copilot review nitpicks

This commit is contained in:
2025-05-31 18:09:58 +02:00
parent de176acd8f
commit 99f3c26ed5
5 changed files with 13 additions and 13 deletions

View File

@@ -3,7 +3,7 @@
import type { SIMDMersenneTwister } from "./mersenne";
export const fisherYates = (sfml: SIMDMersenneTwister, ...arr: any[]) => {
export const fisherYates = (arr: any[], sfml: SIMDMersenneTwister) => {
let m = arr.length;
while (m) {
const i = Math.floor(sfml.random() * m--);

View File

@@ -1,4 +1,4 @@
import type { Song } from '@/types';
import type { Song, Station } from '@/types';
import { getChillhopStation } from './chillhop';
import { getSleepStationSongs } from './sleep';
import { getChillhopData } from '@/utils';
@@ -10,25 +10,25 @@ const customStations: Record<number, () => Promise<Song[]>> = {
export const stations: Record<number, () => Promise<Song[]>> = new Proxy(customStations, {
get(target, prop) {
const stationId = Number(prop);
if (target[stationId]) {
return target[stationId];
}
if (stationId >= 10000 && stationId < 20000) {
return () => getChillhopStation(stationId);
}
return undefined;
},
has(target, prop) {
const stationId = Number(prop);
return target[stationId] !== undefined || (stationId >= 10000 && stationId < 20000);
}
},
});
export const stationMetadata = Promise.resolve([
{ id: 50000, name: 'Lofi Sleep', description: 'Custom station with relaxing lofi beats' },
...(await getChillhopData()).stations
])
{ id: 50000, name: 'Lofi Sleep' },
...(await getChillhopData()).stations,
]) as Promise<Station[]>;

View File

@@ -21,6 +21,6 @@ export async function getSleepStationSongs(): Promise<Song[]> {
};
}) as Song[];
const shuffled = fisherYates(m, mapped).slice(0, 5);
const shuffled = fisherYates(mapped, m).slice(0, 5);
return shuffled;
}

View File

@@ -57,7 +57,7 @@ export interface DecodedStationMeta {
export interface Station {
name: string;
id: number;
meta: string; // Base64 encoded JSON string (DecodedStationMeta)
meta?: string; // Base64 encoded JSON string (DecodedStationMeta)
}
export interface Background {

View File

@@ -1,4 +1,4 @@
import { stations } from '@/stations/index.js';
import { stations } from '@/stations';
export async function GET(event) {
const { stationId } = event.params;