hamt-sharding
v3.0.6
Published
JavaScript implementation of sharding using hash array mapped tries
Downloads
215,994
Readme
hamt-sharding
JavaScript implementation of sharding using hash array mapped tries
About
A Hash Mapped Trie implementation for JavaScript.
This is used by @helia/unixfs for it's HAMT-sharded directory implementation.
Example
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
$ npm i hamt-sharding
Browser <script>
tag
Loading this module through a script tag will make it's exports available as HamtSharding
in the global namespace.
<script src="https://unpkg.com/hamt-sharding/dist/index.min.js"></script>
API Docs
License
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/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.