arr-to-map
v1.0.3
Published
create a map from items of an array, using one property as 'key'
Downloads
187
Readme
arr-to-map
Simple function for converting arrays into maps by looking into one 'key' field
Install
To install run following command
npm install arr-to-map
To add it to your project's package.json run
npm install arr-to-map --save
Usage
var arrToMap = require('arr-to-map');
let fruitsArray = [
{name:'mango', species:'Mangifera indica'},
{name:'orange', species:'Citrus reticulata'}
];
let fruitsMap = arrToMap(fruitsArray, 'name');
console.log(fruitsMap);
License
BSD 2-Clause License
Copyright © 2017, nafSadh http://nafSadh.com All rights reserved.