@jswork/next-list2kv

1.0.0 • Public • Published

next-list2kv

Transform pure list to key value pairs.

version license size download

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.

Package Sidebar

Install

npm i @jswork/next-list2kv

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.82 kB

Total Files

3

Last publish

Collaborators

  • afeiship