core: support random picking cdn and ws endpoints

This commit is contained in:
undefined committed 2024-04-06 05:37:52 +08:00
1 parent 5519fc4270
commit 3ad9d5e614
2 files changed
+11 -2

No files matched your search

+4
View File
@@ -199,6 +199,10 @@ export function size(s: number, base = 1) {
return `${Math.round(s * unit)} ${unitNames[unitNames.length - 1]}`;
}
export function randomPick<T>(arr: T[]): T {
return arr[Math.floor(Math.random() * arr.length)];
}
export type StringKeys<O> = {
[K in keyof O]: string extends O[K] ? K : never
}[keyof O];