-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: parse method mutating its input #231
Conversation
/cc @lholmquist @lance |
475a93b
to
ff925ef
Compare
@@ -32,17 +32,20 @@ function parse(payload, headers, receiver) { | |||
source: undefined | |||
}; | |||
|
|||
|
|||
const unprocessed = new Set(Object.keys(incoming)); |
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.
is Set
necessary here. Can't we assume that the keys in the object are unique already?
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 think they should be unique. The thing is: If I understand it correctly Object.keys(incoming)
returns an array and deletion from an array is more complicated than just delete()
which is offered by a Set
object.
@@ -32,17 +32,20 @@ function parse(payload, headers, receiver) { | |||
source: undefined | |||
}; | |||
|
|||
|
|||
const unprocessed = new Set(Object.keys(incoming)); |
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 think the most efficient would be using the spread operator like this.
const unprocessed = new Set(Object.keys(incoming)); | |
const unprocessed = { ...incoming }; |
Signed-off-by: Matej Vasek <mvasek@redhat.com>
ff925ef
to
4aa2cda
Compare
@lance I force pushed it. There is now only one line changed: |
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.
Excellent - thank you!
fixes: #230