https://github.com/bentatum/collection-to-hash
convert a collection to a hash object.
https://github.com/bentatum/collection-to-hash
collection conversion hash hash-map hashmap
Last synced: about 2 months ago
JSON representation
convert a collection to a hash object.
- Host: GitHub
- URL: https://github.com/bentatum/collection-to-hash
- Owner: bentatum
- License: isc
- Created: 2017-08-23T02:49:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-08T20:10:34.000Z (over 7 years ago)
- Last Synced: 2025-03-09T22:35:36.677Z (2 months ago)
- Topics: collection, conversion, hash, hash-map, hashmap
- Language: JavaScript
- Size: 28.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# collection-to-hash
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url][npm-image]: https://img.shields.io/npm/v/collection-to-hash.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/collection-to-hash
[travis-image]: https://img.shields.io/travis/bentatum/collection-to-hash.svg?style=flat-square
[travis-url]: https://travis-ci.org/bentatum/collection-to-hash
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standardconvert a collection to a hash
## Tip Jar
BTC 33dgdBhV1Yf5ERKLLKS7ztEAEEx3zTvSkw
ETH 0xa6938ead6d6820377fed78b657e4eb6c5c44d1b3## Install
```
yarn add collection-to-hash
```## API
```js
collectionToHash(array, string|function|optional|default:'key', string|function|optional)
```## Usage
```js
import collectionToHash from 'collection-to-hash'const collection = [{ key: 123, ... }, { key: 'abc', ... }]
const hash = collectionToHash(collection)
// const hash = collectionToHash(collection, 'key')
// const hash = collectionToHash(collection, x => x.key)
// const hash = collectionToHash(collection, 'key', x => x)/*
{
123: { ... },
abc: { ... }
}
*/
```## Contributing
Contributions welcome! Please read the [contributing guidelines](CONTRIBUTING.md) first.
## License
[ISC](LICENSE.md)