Skip to content

Commit

Permalink
fix: event listeners in node-hid-wapper to follow style in web-hid-wr…
Browse files Browse the repository at this point in the history
…apper.
  • Loading branch information
nytamin committed Aug 12, 2024
1 parent 0d44da7 commit ee1d6c6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/node/src/node-hid-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import * as HID from 'node-hid'
export class NodeHIDDevice extends EventEmitter implements HIDDevice {
constructor(private device: HID.HIDAsync) {
super()
this._handleData = this._handleData.bind(this)
this._handleError = this._handleError.bind(this)

this.device.on('error', this._handleError)
this.device.on('data', this._handleData)
Expand All @@ -35,10 +33,10 @@ export class NodeHIDDevice extends EventEmitter implements HIDDevice {
this.device.removeListener('data', this._handleData)
}

private _handleData(data: Buffer) {
private _handleData = (data: Buffer) => {
this.emit('data', data)
}
private _handleError(error: any) {
private _handleError = (error: any) => {
this.emit('error', error)
}
}
3 changes: 0 additions & 3 deletions packages/webhid/src/web-hid-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ export class WebHIDDevice extends EventEmitter implements CoreHIDDevice {
constructor(device: HIDDevice) {
super()

this._handleInputreport = this._handleInputreport.bind(this)
this._handleError = this._handleError.bind(this)

this.device = device

this.device.addEventListener('inputreport', this._handleInputreport)
Expand Down

0 comments on commit ee1d6c6

Please sign in to comment.