-
Notifications
You must be signed in to change notification settings - Fork 3
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 conditional to check if there is a result returned from Server method #6
Conversation
@@ -99,7 +99,7 @@ export class Client { | |||
} | |||
|
|||
// resolve when a result is received | |||
if (response && response.result) { | |||
if (response && typeof response.result !== 'undefined') { |
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.
the original if statement will actually properly filter if the response.result
is truly undefined
and this statement check is more specific and feels unnecessary in this case... was this a change for testing purposes that can be backed out?
@@ -204,7 +204,7 @@ export class Server extends EventEmitter { | |||
} | |||
|
|||
// handle synchronous results | |||
if (result && (!result.then || typeof result.then !== 'function')) { | |||
if (typeof result !== 'undefined' && (!result.then || typeof result.then !== 'function')) { |
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.
Same comment as above... if (result)
will result in the same result as if (typeof result !== 'undefined')
, but is more generic and a tad tighter in terms of implementation (plus more consistent with the rest of the code base). Is this a vestige from testing?
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.
Ah I think I see... the issue is that the result from the call is actually a scalar boolean value of false
. In this case, your code change makes sense.
No description provided.