array-reduce-group-by
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

array-reduce-group-by

NPM Version node Build Status Dependency Status Dev Dependency Status

A group-by function working with the built-in Array.reduce()

Install

$ npm install array-reduce-group-by

Usage

const arrayReduceGroupBy = require('array-reduce-group-by');
 
['Alpha', 'Beta', 'Animal']
    .reduce(arrayReduceGroupBy(o => o[0]), {})
//=> {A: ['Alpha', 'Animal'], B: ['Beta']}

Make sure not to forget the {} in the end!

API

arrayReduceGroupBy(keyFunc)

keyFunc

Type: (arrayElement) => string

Function to determine the key of a given array element

Readme

Keywords

none

Package Sidebar

Install

npm i array-reduce-group-by

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

4.07 kB

Total Files

5

Last publish

Collaborators

  • edjopato