@jswork/next-list2kv
v1.0.0
Published
Transform pure list to key value pairs.
Downloads
5
Maintainers
Readme
next-list2kv
Transform pure list to key value pairs.
installation
npm install -S @jswork/next-list2kv
usage
import '@jswork/next-list2kv';
const list1 = ['a', 'b', 'c'];
const res1 = nx.list2kv(list1);
const res2 = nx.list2kv(list1, { indexable: true });
const res3 = nx.list2kv(list1, { label: 'title', id: 'value' });
/*
// res1
[
{ label: 'a', value: 'a' },
{ label: 'b', value: 'b' },
{ label: 'c', value: 'c' }
]
// res2
[
{ label: 'a', value: 0 },
{ label: 'b', value: 1 },
{ label: 'c', value: 2 }
]
// res3
[
{ title: 'a', value: 'a' },
{ title: 'b', value: 'b' },
{ title: 'c', value: 'c' }
]
*/
license
Code released under the MIT license.