Skip to content

Commit

Permalink
refactor: compare with undefined directly (discordjs#9191)
Browse files Browse the repository at this point in the history
* refactor: compare with `undefined` directly

* fix: lint
  • Loading branch information
almeidx committed Mar 12, 2023
1 parent 29ddbcf commit 62c0fa1
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/DataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,6 @@ export function deleteAudioPlayer(player: AudioPlayer) {
audioPlayers.splice(index, 1);
if (audioPlayers.length === 0) {
nextTime = -1;
if (typeof audioCycleInterval !== 'undefined') clearTimeout(audioCycleInterval);
if (audioCycleInterval !== undefined) clearTimeout(audioCycleInterval);
}
}
4 changes: 2 additions & 2 deletions src/VoiceConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ export class VoiceConnection extends EventEmitter {
private addStatePacket(packet: GatewayVoiceStateUpdateDispatchData) {
this.packets.state = packet;

if (typeof packet.self_deaf !== 'undefined') this.joinConfig.selfDeaf = packet.self_deaf;
if (typeof packet.self_mute !== 'undefined') this.joinConfig.selfMute = packet.self_mute;
if (packet.self_deaf !== undefined) this.joinConfig.selfDeaf = packet.self_deaf;
if (packet.self_mute !== undefined) this.joinConfig.selfMute = packet.self_mute;
if (packet.channel_id) this.joinConfig.channelId = packet.channel_id;
/*
the channel_id being null doesn't necessarily mean it was intended for the client to leave the voice channel
Expand Down
2 changes: 1 addition & 1 deletion src/audio/AudioResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export function createAudioResource<T>(
// string inputs can only be used with FFmpeg
if (typeof input === 'string') {
inputType = StreamType.Arbitrary;
} else if (typeof inputType === 'undefined') {
} else if (inputType === undefined) {
const analysis = inferStreamType(input);
inputType = analysis.streamType;
needsInlineVolume = needsInlineVolume && !analysis.hasVolume;
Expand Down
2 changes: 1 addition & 1 deletion src/networking/Networking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export class Networking extends EventEmitter {
public dispatchAudio() {
const state = this.state;
if (state.code !== NetworkingStatusCode.Ready) return false;
if (typeof state.preparedPacket !== 'undefined') {
if (state.preparedPacket !== undefined) {
this.playAudioPacket(state.preparedPacket);
state.preparedPacket = undefined;
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/networking/VoiceWebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class VoiceWebSocket extends EventEmitter {
* @param ms - The interval in milliseconds. If negative, the interval will be unset
*/
public setHeartbeatInterval(ms: number) {
if (typeof this.heartbeatInterval !== 'undefined') clearInterval(this.heartbeatInterval);
if (this.heartbeatInterval !== undefined) clearInterval(this.heartbeatInterval);
if (ms > 0) {
this.heartbeatInterval = setInterval(() => {
if (this.lastHeartbeatSend !== 0 && this.missedHeartbeats >= 3) {
Expand Down
2 changes: 1 addition & 1 deletion src/receive/AudioReceiveStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class AudioReceiveStream extends Readable {
buffer &&
(this.end.behavior === EndBehaviorType.AfterInactivity ||
(this.end.behavior === EndBehaviorType.AfterSilence &&
(buffer.compare(SILENCE_FRAME) !== 0 || typeof this.endTimeout === 'undefined')))
(buffer.compare(SILENCE_FRAME) !== 0 || this.endTimeout === undefined)))
) {
this.renewEndTimeout(this.end);
}
Expand Down

0 comments on commit 62c0fa1

Please sign in to comment.