-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 a bug in ObjectUtils::areSimpleEquivalent method #1979
Fix a bug in ObjectUtils::areSimpleEquivalent method #1979
Conversation
If objects phave same parameters but declared in a different order, string obtained using JSON.stringify will be different, the method will return false, whereas it should return true. The fix uses deep-equal module to avoid this bug. Add a unit test to test the solution : using JSON.stringify, the unit test fails, using deep-equal module, the test is in success
This isn't a bug - the whole point of this method was to avoid importing a module and simply compare objects constructed in a predictable manner - see the jsdoc above. With this PR the method has no value now so the whole objectutils could be removed and deep-equal imported where needed. |
Guys is this needed or not. If not please close or please merge. |
Hi guys From my point of view, if you are planning to release an industrial product, I think we should correct this potential bug (even if the code is predictable). It's up to you to merge or not. |
I still think it'd be better to change the method name, or have an additional method for deep compare, ( |
I have renamed ObjectUtils::areSimpleEquivalent as ObjectUtils::areEqual to avoid any confusion |
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.
…merged in development
If objects have same parameters but declared in a different order, string obtained using JSON.stringify() will be different and the method will return false, whereas it should return true.
The fix uses deep-equal module to avoid this bug.
I have although added a unit test to test the solution (in streaming.utils.ObjectUtils.js file) : using JSON.stringify(), the unit test fails, using deep-equal module, the test is in success