feat(command): new command: uniq()#453
feat(command): new command: uniq()#453nfischer merged 17 commits intoshelljs:masterfrom joshi-sh:master
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.
| Available options: | ||
|
|
||
| + `-i`: Ignore differences in case when comparing | ||
| + `-c`: Prefix lines by the number of occurrences |
There was a problem hiding this comment.
This sounds a bit ambiguous. Could you reword this?
src/uniq.js
Outdated
| }); | ||
| 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.
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.