groop
Normalize an array of objects by a property.
Both lists and single objects can be normalized.
Usage
import { createArrayGroup } from '@dankreiger/groop';
const listGroup = [
{ name: 'Dan', age: 5 },
{ name: 'Puppy', age: 5 },
{ name: 'Woofer', age: 22 },
{ name: 'Dan', age: 20 },
];
const byAge = createArrayGroup('age');
byAge(listGroup);
const byName = createArrayGroup('name');
byName(listGroup);
import { createGroup } from '@dankreiger/groop';
const singleGroup = { name: 'Dan', age: 5 };
const byAge = createGroup('age');
byAge(singleGroup);
const byName = createGroup('name');
byName(singleGroup);