-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[BUGFIX] (Bug #2714) For _.uniq which acted incorrectly on sorted lists using a non injective iteratee #2715
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
…d list with a non injective iteratee and added a test case to test this fix
This is my first pull request ever, so please, kindly point out if I am doing something wrong, or if I have made any mistakes. Thank you so much. |
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.
Congrats on the first PR! Fix these and I'll be happy to merge.
underscore.js
Outdated
@@ -558,6 +558,8 @@ | |||
|
|||
// Produce a duplicate-free version of the array. If the array has already | |||
// been sorted, you have the option of using a faster algorithm. | |||
// The faster algorithm will not work with an iteratee if the iteratee is not a one-to-one function, so providing an iteratee will disable the faster algorithm |
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.
Comments should be complete sentences, with punctuation, wrapped to an ~80 line width.
underscore.js
Outdated
@@ -558,6 +558,8 @@ | |||
|
|||
// Produce a duplicate-free version of the array. If the array has already | |||
// been sorted, you have the option of using a faster algorithm. | |||
// The faster algorithm will not work with an iteratee if the iteratee is not a one-to-one function, so providing an iteratee will disable the faster algorithm | |||
// Perhaps a warning should be thrown if an iteratee is provided while isSorted is true, to warn that the faster algorithm will not be used |
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.
Let's get rid of this sentence — we don't need to publish it along with the library.
Thanks! I updated the lines that the bot flagged, and now I will update the code with the comments that you added. In a minute I will make another commit. |
I fixed the comments in the code as per your request. Let me know if you would like me to change anything else. |
3 similar comments
Nice work! |
Thank you, I really appreciate it! |
[BUGFIX] (Bug jashkenas#2714) For _.uniq which acted incorrectly on sorted lists using a non injective iteratee
When using an iteratee that is not a one-to-one function, and isSorted=true, then _.uniq would attempt to use the fast algorithm which fails for non one-to-one (injective) functions, because they map to resultant values which are not sorted.