array-to-hash-object

0.1.5 • Public • Published

What this package do?

Transform array to object with a custom hash key. For example.

var before = [
{
  id:1,
  name:"youngwind',
  age:24
},
{
 id:2,
 name:"xiaoye",
 age:30
}
];

// after
{
  1:{
    name:"youngwind",
    age:24
  },
  2:{
    name:"xiaoye",
    age:30
  }
}

Install

npm install array-to-hash-object --save

Usage

var arrayToHash = require('array-to-hash-object');
var after = arrayToHash(before,'id');
console.log(after);

Readme

Keywords

Package Sidebar

Install

npm i array-to-hash-object

Weekly Downloads

1

Version

0.1.5

License

ISC

Last publish

Collaborators

  • youngwind