1.0.2 • Published 4 years ago

@feizheng/next-list2map v1.0.2

Weekly downloads
3
License
MIT
Repository
-
Last release
4 years ago

next-list2map

Transform list to map.

installation

npm install -S @feizheng/next-list2map

usage

import '@feizheng/next-list2map';

const items = [
  { id: 1, name: 'xiaoming' },
  { id: 2, name: 'lihua' },
  { id: 3, name: 'hanmeimei' }
];

const result = nx.list2map(items, {
  key: 'id',
  value: function(i, val) {
    return val;
  }
});

// result:
{
  '1': { id: 1, name: 'xiaoming' },
  '2': { id: 2, name: 'lihua' },
  '3': { id: 3, name: 'hanmeimei' }
}