object.groupby
As its name says, it is a ponyfill or polyfill of Object.groupBy ES feature.
install
You can use any package management tool you like to download it. pnpm is recommended:
$ pnpm i object-group-bye
usage
import { ObjectGroupBy } from "object-group-bye"
const inventory = [
{ name: "asparagus", type: "vegetables", quantity: 5 },
{ name: "bananas", type: "fruit", quantity: 0 },
{ name: "goat", type: "meat", quantity: 23 },
{ name: "cherries", type: "fruit", quantity: 5 },
{ name: "fish", type: "meat", quantity: 22 },
];
const result = ObjectGroupBy(inventory, ({ type }) => type);
This package also supports polyfill usage:
import "object-group-bye/polyfill"
const result = Object.groupBy(inventory, ({ type }) => type);
license
MIT