Skip to content

yorkie/node-hash-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-hash-array Build Status

Hashify an array and get elements by its key

Installation

$ npm install hash-array

Usage

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

API

hashArray(src, key)

Scan a source array src, and generate a new objectbased on 2nd argument key, that has below methods.

.get(key)

Get value from your hashed array

.set(key, val)

Set value to your hashed array and source array

License

MIT

About

hashify array and get element by its key

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published