Test name | Executions per second |
---|---|
Lodash | 20.6 Ops/sec |
Native | 49.7 Ops/sec |
Ramda | 14115801.0 Ops/sec |
<script src='https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.1/ramda.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js'></script>
var max2 = 1000000;
var data = [];
for (var i = 0; i <= max2; i++) { data.push({ id: i }); }
_.groupBy(data, ({ id }) => id)
data.reduce((acc, item) => {
acc[item.id] = item;
return acc;
}, {})
R.groupBy(data => data.id)