mirror of
https://github.com/SrIzan10/lofi.git
synced 2026-06-06 00:56:53 +00:00
chore: copilot review nitpicks
This commit is contained in:
@@ -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--);
|
||||
|
||||
@@ -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[]>;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { stations } from '@/stations/index.js';
|
||||
import { stations } from '@/stations';
|
||||
|
||||
export async function GET(event) {
|
||||
const { stationId } = event.params;
|
||||
|
||||
Reference in New Issue
Block a user