Skip to content

Commit

Permalink
fix: remove some usages of constructor.name #74
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Aug 27, 2023
1 parent 4c06389 commit e400435
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/atem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class BasicAtem extends EventEmitter<AtemEvents> {

private _mutateState(commands: IDeserializedCommand[]): void {
// Is this the start of a new connection?
if (commands.find((cmd) => cmd.constructor.name === Commands.VersionCommand.name)) {
if (commands.find((cmd) => cmd instanceof Commands.VersionCommand)) {
// On start of connection, create a new state object
this._state = AtemStateUtil.Create()
this._status = AtemConnectionStatus.CONNECTING
Expand Down Expand Up @@ -238,7 +238,7 @@ export class BasicAtem extends EventEmitter<AtemEvents> {
}
}

const initComplete = commands.find((cmd) => cmd.constructor.name === Commands.InitCompleteCommand.name)
const initComplete = commands.find((cmd) => cmd instanceof Commands.InitCompleteCommand)
if (initComplete) {
this._status = AtemConnectionStatus.CONNECTED
this._onInitComplete()
Expand Down
5 changes: 2 additions & 3 deletions src/lib/atemSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,9 @@ export class AtemSocket extends EventEmitter<AtemSocketEvents> {
this._commandParser.version
)

if (cmdConstructor.name === VersionCommand.name) {
if (cmd instanceof VersionCommand) {
// init started
const verCmd = cmd as VersionCommand
this._commandParser.version = verCmd.properties.version
this._commandParser.version = cmd.properties.version
}

parsedCommands.push(cmd)
Expand Down

0 comments on commit e400435

Please sign in to comment.