New commands: sort(), head(), and tail()#379
Conversation
|
I just added in the test cases, so this is ready for review. If anyone from the community wants to chime in for features, please do. The semantics are slightly different than unix's While unix sorts things like: This difference could be avoided, but I'm not sure if it really matters so much. |
|
@ariporad If you get the chance, this should be ready for review. I see that it's failing on Feel free to review but not merge, since there's no huge rush to get these features. We can always use more input from the community. On the other hand, if we merge now, we can always go back and add features before the next release. |
README.md
Outdated
| Examples: | ||
|
|
||
| ```javascript | ||
| var str = head({'-n, 1}, 'file*.txt'); |
There was a problem hiding this comment.
You're missing a quote her.
There was a problem hiding this comment.
Should be fixed now (good catch)
|
Looks like there's iojs compatibility issues. I'll try to fix that today and see if I can get |
|
A few nits, otherwise looks good. |
373b9c1 to
3140e60
Compare
|
Ok, I think I fixed the inconsistency. Also, this is now compatible with how unix sort works, which is a plus. Should be good to merge now. |
|
Let's hold off to merge this. I think this should be refactored to read input in via buffers (vs. reading it all at once), when possible. This is to account for the case where a file is infinite in size (or maybe just super large) and we print out the first 10 lines, keeping the operation constant time instead of hanging indefinitely. I should have time to refactor this today. I can also add in |
|
SGTM! |
3140e60 to
c66c947
Compare
|
@ariporad I refactored this into 3 commits. Leave any comments/concerns and I can address when I get back. |
c66c947 to
eceea45
Compare
b9d032f to
7658a8b
Compare
|
@ariporad This should be ready for review |
src/sort.js
Outdated
|
|
||
| //@ | ||
| //@ ### sort([options,] file [, file ...]) | ||
| //@ ### sed([options,] file_array) |
There was a problem hiding this comment.
Why is this also called sed? I thought sed was find/replace?
There was a problem hiding this comment.
Whoops! That was a mistake. I'll fix that
|
@nfischer: One comment, also can you either squash your final commit or make it comply with the commit guidelines? Thanks! |
7658a8b to
101b25e
Compare
101b25e to
ef3a740
Compare
|
@ariporad Rebased this and fixed the issues |
|
@ariporad Let me know once you've taken a look at this. I'll address any issues and rebase. If there are no issues, feel free to give the thumbs up and I'll rebase and merge. |
|
LGTM! |
|
Ok great! I'll rebase this and merge |
ef3a740 to
60d6301
Compare
|
LGTM (because of rebase) |
|
any chance of having this published to npm? |
|
Hopefully soon. We had some last minute concerns raised, but it should be resolved soon |
These are initial versions of the
head()andsort()commands. Not ready to merge. Feel free to take a look and give feedback on what I have implemented so far.I haven't written unit tests yet, but I will do so soon.
The reason these are together in one PR is that I wanted to be able to hack out a translation of an adaptation of the famous Donald Knuth shell problem:
Will now (correctly) translate to:
Also, if someone wants
tail(), chime in and I can write that out as well.