-
Notifications
You must be signed in to change notification settings - Fork 735
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
feat(command): new command: uniq() #453
Conversation
@nfischer: What are your thoughts on this? I'm not really sure this needs to be a part of shelljs, this could maybe be a plugin, or just a js lib... It's not really shell specific. |
@ariporad This is part of GNU core-utils (here's the source for that), so it seems pretty shell-specific to me. What do you think? I think this could be a pretty useful utility for some people. @DaedalusUsedPerl Could you please update this to fix the lint errors? |
|
||
var result; | ||
|
||
result = shell.uniq(); |
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.
Available options: | ||
|
||
+ `-i`: Ignore differences in case when comparing | ||
+ `-c`: Prefix lines by the number of occurrences |
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.
This sounds a bit ambiguous. Could you reword this?
}); | ||
uniqed = uniqed. | ||
//Do we want only duplicated objects? | ||
filter(function(obj){return options.duplicates ? obj.count > 1 : true;}). |
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 you write out callbacks in the form:
filter(function (obj) {
// Do we want only duplicated objects?
return options.duplicates ? obj.count > 1 : true;
}).map( // etc ...
@joshi-sh I left some comments. Overall, looks pretty thorough! This is something I'd really like to see in ShellJS. Most of the comments are very nitpicky, so I can fix them if you'd like. |
Your comments are pretty reasonable, actually. I just copied the GNU man pages in lieu of writing docs. |
Gonna give this an LGTM. We might want to wait to merge until after shelljs v0.7.1, and then this can be in 0.7.2. Edit: I originally put v0.8 instead of v0.7 |
LGTM 👍 |
I'll handle merging this once we get a patch release out with some of the fixes we've made since v0.7.0. |
The uniq utility removes adjacent identical lines from it's input. I have implemented uniq with support for the -i (ignore case) option.