Skip to content

Commit

Permalink
feat: add UserManager.byName() (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc authored Feb 8, 2025
1 parent a27454f commit ebe9f4d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/user-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ export class UserManager {
return this._users.get(session);
}

/**
* Finds a user by their name.
* @param name The name of the user to look for.
* @returns User (if found) or undefined.
*/
byName(name: string): User | undefined {
return Array.from(this._users.values()).find(u => u.name === name);
}

findAll(predicate: (user: User) => boolean): User[] {
return Array.from(this._users.values()).filter(predicate);
}
Expand Down

0 comments on commit ebe9f4d

Please sign in to comment.