Skip to content

normalise an array to an object with byId and items

Notifications You must be signed in to change notification settings

UXtemple/normaliser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

normaliser

normalise an array to an object with byId and items

import normalise from 'normaliser';

const list = [{
  id: '1',
  data: 1
}, {
  id: '2',
  data: 2
}];

normalise(list)
// => {
//   byId: {
//     '1': {
//       id: '1',
//       data: 1
//     }, {
//     '2': {
//       id: '2',
//       data: 2
//     }
//   },
//   items: ['1', '2']
// }

MIT license. By UXtemple.

About

normalise an array to an object with byId and items

Resources

Stars

Watchers

Forks

Packages