ddopson / underscore-cli

Command-line utility-belt for hacking JSON and Javascript.
Other
1.72k stars 83 forks source link

add first/last/groupBy #18

Open boxxxie opened 11 years ago

boxxxie commented 11 years ago

cat json.json | underscore first 50 `cat json.json | underscore groupBy id'

:)

i'm finding myself doing this quite a bit too... it would be cool if you could make it easy for us to add our own commands/mixins underscore process 'groupBy(data,"LocationName")' | underscore values | underscore map 'extend.apply(null,value,{})'

mrquincle commented 10 years ago

It is not exactly what you ask here, namely custom commands...

However, to get the first 50 items from a list:

< json.json underscore filter 'key < 50'

And if you want to have the one with index 50:

< json.json underscore find 'key >= 50'

This is only for arrays of course...