Skip to content

bentatum/collection-to-hash

Repository files navigation

collection-to-hash

npm travis standard

convert a collection to a hash

Tip Jar

BTC 33dgdBhV1Yf5ERKLLKS7ztEAEEx3zTvSkw ETH 0xa6938ead6d6820377fed78b657e4eb6c5c44d1b3

Install

yarn add collection-to-hash

API

collectionToHash(array, string|function|optional|default:'key', string|function|optional)

Usage

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 first.

License

ISC

Releases

No releases published

Packages

No packages published