1.0.0 • Published 5 years ago
@jswork/next-list2map v1.0.0
next-list2map
Transform list to map.
installation
npm install -S @jswork/next-list2map
usage
import '@jswork/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' }
}
license
Code released under the MIT license.
1.0.0
5 years ago