mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: support random picking cdn and ws endpoints
This commit is contained in:
2 files changed
+11
-2
No files matched your search
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user