Socket
Socket
Sign inDemoInstall

object-group-bye

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    object-group-bye

ponyfill or polyfill of Object.groupBy ES feature


Version published
Maintainers
1
Created

Readme

Source

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);
/* Result is:
{
  vegetables: [
    { name: 'asparagus', type: 'vegetables', quantity: 5 },
  ],
  fruit: [
    { name: "bananas", type: "fruit", quantity: 0 },
    { name: "cherries", type: "fruit", quantity: 5 }
  ],
  meat: [
    { name: "goat", type: "meat", quantity: 23 },
    { name: "fish", type: "meat", quantity: 22 }
  ]
}
*/

This package also supports polyfill usage:

    // import the polyfill at the top of your code
    import "object-group-bye/polyfill"
    // now you can use it directly with `object.groupBy` static method
    const result = Object.groupBy(inventory, ({ type }) => type);
    // ...

license

MIT

Keywords

FAQs

Last updated on 05 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc