-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add checks for peripheral.mtu #165
Conversation
@@ -569,7 +569,7 @@ Noble.prototype.onHandleNotify = function (peripheralUuid, handle, data) { | |||
|
|||
Noble.prototype.onMtu = function (peripheralUuid, mtu) { | |||
var peripheral = this._peripherals[peripheralUuid]; | |||
peripheral.mtu = mtu; | |||
if (peripheral && peripheral.mtu && mtu) peripheral.mtu = mtu; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt "if (peripheral)" enough ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe : var peripheral = this._peripherals[peripheralUuid] || {} ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or maybe : var peripheral = this._peripherals[peripheralUuid] || {} ?
if peripheral = {}
then peripheral.mtu
will get TypeError i guess? same for if (peripheral)
when accessing .mtu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if peripheral = {} then peripheral.mtu is undefined but you can do affectation:
``
node
Welcome to Node.js v14.15.0.
Type ".help" for more information.
var p = {};
undefined
p.foo = true;
true
console.log( p.as)
undefined
please rebase |
can you please try to update your branch ? |
checks if it's valid when setting it. Should fix the TypeError of it
@rzr sry for the late reply just rebased it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be simplified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this is to fix TypeError. Checked with typescript and yields error
checks if it's valid when setting it.
Should fix the TypeError of it