Hashify an array and get
elements by its key
$ npm install hash-array
var hashArray = require('hash-array');
var src = [
{ 'type': 'mail', value: 30 },
{ 'type': 'foll', value: 20 }
]
var hashedArr = hashArray(src, 'type');
console.log(hashedArr.get('mail')) // prints 30
console.log(hashedArr.get('foll')) // prints 20
Scan a source array src
, and generate a new objectbased on 2nd argument key
, that has below methods.
Get value from your hashed array
Set value to your hashed array and source array
MIT