mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-04 18:00:18 +00:00
fix(js-client): Remove union with undefined of methods for getting random peer (#417)
Fix types
This commit is contained in:
parent
5d7ae85e58
commit
4d90414190
@ -165,21 +165,23 @@ export const kras: Relay[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const randomKras = () => {
|
||||
export const randomKras = (): Relay => {
|
||||
return randomItem(kras);
|
||||
};
|
||||
|
||||
export const randomTestNet = () => {
|
||||
export const randomTestNet = (): Relay => {
|
||||
return randomItem(testNet);
|
||||
};
|
||||
|
||||
export const randomStage = () => {
|
||||
export const randomStage = (): Relay => {
|
||||
return randomItem(stage);
|
||||
};
|
||||
|
||||
function randomItem(arr: Relay[]) {
|
||||
function randomItem(arr: Relay[]): Relay {
|
||||
const index = randomInt(0, arr.length);
|
||||
return arr[index];
|
||||
// This array access always defined
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
return arr[index] as Relay;
|
||||
}
|
||||
|
||||
function randomInt(min: number, max: number) {
|
||||
|
Loading…
Reference in New Issue
Block a user