blob: f81cb6b3ec61b11987513c182a89690fb1dfa03c [file] [log] [blame]
import {User} from '../model/user';
export class UserMap {
private mappedUsers: User[];
constructor( allUsers: User[] ) {
this.mappedUsers = [];
if ( !allUsers ) {
console.log('UserMap was created without any Users!');
throw new EvalError('UserMap was created without any Users!');
}
for ( const usr of allUsers ) {
this.mappedUsers[ usr.username ] = usr;
}
}
public findUser( usrShort: string ): User {
return this.mappedUsers[ usrShort ];
}
public findAndRenderUser( shortUsr: string ): string {
const usr = this.findUser(shortUsr);
if ( !usr ) {
return '[' + shortUsr + ']';
} else {
return usr.name;
}
}
}