# hamt-sharding
[](https://codecov.io/gh/ipfs-shipyard/js-hamt-sharding)
[](https://github.com/ipfs/js-hamt-sharding/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
> JavaScript implementation of sharding using hash array mapped tries
# About
A [Hash Mapped Trie](https://en.wikipedia.org/wiki/Hash_array_mapped_trie) implementation for JavaScript.
This is used by [@helia/unixfs](https://www.npmjs.com/package/@helia/unixfs) for it's HAMT-sharded directory implementation.
## Example
```TypeScript
import { createHAMT } from 'hamt-sharding'
import crypto from 'crypto-promise'
// decide how to hash buffers made from keys, can return a Promise
const hashFn = async (buf) => {
return crypto
.createHash('sha256')
.update(buf)
.digest()
}
const bucket = createHAMT({
hashFn: hashFn
})
await bucket.put('key', 'value')
const output = await bucket.get('key')
// output === 'value'
```
# Install
```console
$ npm i hamt-sharding
```
## Browser `
```
# API Docs
-
# License
Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / )
- MIT ([LICENSE-MIT](LICENSE-MIT) / )
# Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.