open-index/open-npm huggingface dataset:
npm package: @nombienombie/array-to-hash
Description: A simple function for reducing an array of data into an object.
Author: Gordon Smith
Latest version: 0.1.3

# array-to-hash

A simple function for reducing an array of data into an object.

# Why this is useful?

Arrays can be slow for searching if you do not know the index of the item you require. Objetcs can be much quicker with larger data sets as
we can use the key, allowing us to get the value as fast as it can be retrieved from memory.

Example:

```javascript
const arrayToHash = require('@nombienombie/array-to-hash');

const users = [{ id: 1, name: 'Foo' }, { id: 2, name: 'Bar' }, { id: 3, name: 'Boo' }];

const userHash = arrayToHash(users);

console.log(userHash);
/*
{
    1: {id: 1, name: 'Foo'},
    2: {id: 2, name: 'Bar'},
    3: {id: 3, name: 'Boo'},
}
*/
```

# Usage

```sh
$ npm install --save @nombienombie/array-to-hash
```