Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
events, doc: add type checking in defaultMaxListeners getter#11938
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
events, doc: add type checking in defaultMaxListeners getter #11938
Uh oh!
There was an error while loading. Please reload this page.
Conversation
DavidCai1111 commented Mar 20, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
lib/events.js Outdated
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 we replace isNaN(n) with n !== n, possibly with a comment with a short explanation?
vsemozhetbytMar 20, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
@mscdex Is this similar place also worth replacing then?
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.
Probably, but as a separate commit I'd say.
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.
@mscdex@vsemozhetbyt OK, updated.
aa568e6 to 58f7610CompareDavidCai1111 commented Mar 20, 2017
@vsemozhetbyt Thanks for reminding, changed it to a shorter one :) |
vsemozhetbyt commented Mar 20, 2017
ce92c12 to 35db7e6Comparevsemozhetbyt commented Mar 20, 2017
lib/events.js Outdated
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.
'which value is larger than zero' should probably instead be something like 'whose value is zero or greater'
cjihrig left a comment
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.
LGTM with a couple nits.
doc/api/events.md Outdated
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.
Can I suggest rewording this as:
If this value is not a positive number, a TypeError will be thrown.
lib/events.js Outdated
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.
Changing this variable name seems unnecessary.
jasnell left a comment
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.
LGTM with nits addressed
35db7e6 to b3c06f2CompareDavidCai1111 commented Mar 21, 2017
mscdex commented Mar 21, 2017
jasnell commented Mar 22, 2017
@mscdex ... does this LGTY? |
| // check whether the input is a positive number (whose value is zero or | ||
| // greater and not a NaN). | ||
| if(typeofarg!=='number'||arg<0||arg!==arg) | ||
| thrownewTypeError('defaultMaxListeners must be a positive number'); |
mscdexMar 22, 2017 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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.
'defaultMaxListeners' should be enclosed in double quotes to match the style when referencing property names in error messages.
mscdex commented Mar 22, 2017
One minor nit, but otherwise LGTM. |
jasnell commented Mar 22, 2017
I can take care of that nit while landing |
PR-URL: #11938 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: Brian White <[email protected]>
jasnell commented Mar 22, 2017
Landed in 221b03a |
Since
EventEmitter.defaultMaxListenersandemitter.setMaxListeners(n)are both public APIs listed in the document, so it is reasonable to checkEventEmitter.defaultMaxListenersgetter's input like whatemitter.setMaxListeners(n)does to avoid potential confusing results or error messages caused by some userland mistaken input, like:Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
events, doc