proposal-array-grouping
proposal-array-grouping copied to clipboard
Other lodash use cases where the method could be handy
Thanks for creating this function proposal, I am very exiting to see it. I find this could be useful for many use cases, here are some of them from lodash.
Chunk
const chunk = (array, size = 1) => Object.values(array.groupBy((v, i) => Math.floor(i / size)))
Partition
// predicate returns boolean
const partition = (array, predicate) => Object.values(array.groupBy((v, i, a) => Number(predicate(v, i, a)))
Covered by proposal in #9
Covering Object.values() order consistency was left out for the simplicity.
If this is not worth adding to examples, feel free to close the issue. Thank you 🙂