Skip to content

groop 0.1.26

Install from the command line:
Learn more about npm packages
$ npm install @dankreiger/groop@0.1.26
Install via package.json:
"@dankreiger/groop": "0.1.26"

About this version

groop

Normalize an array of objects by a property.

Usage

import { createGroup } from '@dankreiger/groop';

const listGroup = [
  { name: 'Dan', age: 5 },
  { name: 'Puppy', age: 5 },
  { name: 'Woofer', age: 22 },
  { name: 'Dan', age: 20 },
];

const byAge = createGroup('age');

byAge(listGroup);

/** yields **/

{
  entities: {
    '20': [
      {
        age: 20,
        name: 'Dan',
      },
    ],
    '22': [
      {
        age: 22,
        name: 'Woofer',
      },
    ],
    '5': [
      {
        age: 5,
        name: 'Dan',
      },
      {
        age: 5,
        name: 'Puppy',
      },
    ],
  },
  ids: [5, 22, 20],
}

Details


Assets

  • groop-0.1.26.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0