Binato/server/objects/UserArray.ts

26 lines
568 B
TypeScript
Raw Permalink Normal View History

2023-09-10 12:59:22 +01:00
import FunkyArray from "./FunkyArray";
import User from "./User";
2022-11-16 15:25:46 +00:00
2023-09-10 12:59:22 +01:00
export default class UserArray extends FunkyArray<User> {
2022-11-16 15:25:46 +00:00
public getById(id:number) : User | undefined {
for (const user of this.getIterableItems()) {
2022-11-16 15:25:46 +00:00
if (user.id == id)
return user;
}
return undefined;
}
public getByUsername(username:string) : User | undefined {
for (const user of this.getIterableItems()) {
2022-11-16 15:25:46 +00:00
if (user.username === username)
return user;
}
return undefined;
}
public getByToken(token:string) : User | undefined {
return this.getByKey(token);
}
}