-
Notifications
You must be signed in to change notification settings - Fork 83
Fix removeListener Iteration #95
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
Conversation
gr2m
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.
Wonderful pull request, thank you so much! I just have one little nitpick question
| // remove last hook that has been added, that way | ||
| // it behaves the same as removeListener | ||
| for (let i = state.hooks[webhookNameOrNames].length; i > 0; i--) { | ||
| for (let i = state.hooks[webhookNameOrNames].length - 1; i >= 0; i--) { |
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.
Wow, good catch, thanks so much for investigating and sending a pull request, with tests 😻
| @@ -0,0 +1,42 @@ | |||
| const test = require('tap').test | |||
|
|
|||
| const receiverListener = require('../../event-handler/remove-listener') | |||
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.
have you meant to call this variable removeListener? I think that would make the tests a little more clear!
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.
I agree it does look cleaner to call it removeListener. I've updated the test with the new name.
gr2m
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.
Perfect, thank you!
|
🎉 This PR is included in version 6.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
The current implementation of EventHandler#removeListener never iterates to index
0in the state.Example code to reproduce this issue:
Without the fix:
With the fix: