Skip to content

Commit

Permalink
Slight optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Aug 11, 2023
1 parent 7edf3eb commit c0701d8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/irc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1696,10 +1696,15 @@ export class Client extends (EventEmitter as unknown as new () => TypedEmitter<C
private _addWhoisData<
K extends keyof(WhoisResponse),
V extends WhoisResponse[K]>(nick: string, key: K, value: V, onlyIfExists = false) {
if (onlyIfExists && !this.state.whoisData.has(nick)) {return;}
const data: WhoisResponse = this.state.whoisData.get(nick) || { nick };
let data: WhoisResponse|undefined = this.state.whoisData.get(nick);
if (onlyIfExists && !data) {
return;
}
else if (!data) {
data = { nick };
this.state.whoisData.set(nick, data);
}
data[key] = value;
this.state.whoisData.set(nick, data);
}

private _clearWhoisData(nick: string) {
Expand Down

0 comments on commit c0701d8

Please sign in to comment.