loading...

Discussion on: 5 JavaScript functions to add to your utilities library

Collapse
orelkan profile image
Orel Kanditan

It's a neat trick, but it's a little YAGNI isn't it? I can't really think of a situation where I would use this

Collapse
vonheikemen profile image
Heiker

Is certainly not necessary. You can always wrap the thing in another function.

const groupByType = arr => groupBy(arr, 'type');

It does come handy when callbacks are involve.

// function composition in ramda style
const complexFunc = pipe(someFunc, groupBy('type'), otherFunc);

// when mapping
someArrWithStuff.map(groupBy('type'));

// a raw promise (if you are one of those)
ipromise.then(groupBy('type'));