resorting-key
v1.0.0
Published
Resorting array index/key with own array values
Downloads
1
Readme
Resorting Array By Object
Test Package
Install
npm install --save resorting-key
Usage
import ResortingKey from 'resorting-key';
const obj = [
{
data1: 'Sample1',
data2: 'Sample data 2.1'
},
{
data1: 'Sample2',
data2: 'Sample data 2.2'
},
{
data1: 'Sample3',
data2: 'Sample data 3.3'
}
]
console.log(ResortingKey(obj, 'data1'))
// {
// result: {
// 'Sample1': { data1: 'Sample1', data2: 'Sample data 2.1' },
// 'Sample2': { data1: 'Sample2', data2: 'Sample data 2.2' },
// 'Sample3': { data1: 'Sample3', data2: 'Sample data 3.3' }
// },
// length: 3
// }