Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

hamt-sharding

ipfs370.4kApache-2.0 OR MIT3.0.6TypeScript support: included

JavaScript implementation of sharding using hash array mapped tries

IPFS, hamt, sharding

readme

hamt-sharding

codecov CI

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

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.

changelog

3.0.6 (2024-02-06)

Trivial Changes

Documentation

3.0.5 (2024-02-06)

Dependencies

  • bump uint8arrays from 4.0.10 to 5.0.1 (#64) (63d56e4)

3.0.4 (2024-02-06)

Dependencies

  • dev: bump aegir from 37.12.1 to 42.2.3 (#63) (f4a59e9)

3.0.3 (2024-02-06)

Trivial Changes

  • add or force update .github/workflows/js-test-and-release.yml (#61) (a993a1e)
  • delete templates [skip ci] (#60) (2d4bdc6)
  • Update .github/workflows/stale.yml [skip ci] (18629a9)
  • Update .github/workflows/stale.yml [skip ci] (97305d6)
  • Update .github/workflows/stale.yml [skip ci] (12ec5c4)

Dependencies

  • dev: bump it-length from 2.0.1 to 3.0.4 (#62) (6fec868)

3.0.2 (2022-10-18)

Documentation

Dependencies

  • bump uint8arrays from 3.1.1 to 4.0.2 (#35) (f8867d6)
  • dev: bump it-length from 1.0.4 to 2.0.0 (#36) (c844d7a)

3.0.1 (2022-08-11)

Trivial Changes

  • Update .github/workflows/stale.yml [skip ci] (0c6fd46)

Dependencies

3.0.0 (2022-02-21)

⚠ BREAKING CHANGES

  • this module is ESM-only now

Bug Fixes

Trivial Changes

2.0.1 (2021-08-23)

2.0.0 (2021-02-18)

Features

1.0.0 (2020-01-08)

Bug Fixes

0.0.2 (2018-11-23)

Bug Fixes

  • compact children before counting them (56a2ece)
  • remove async generator so we can webpack it (ebef92a)

Features

  • use async instead of callbacks (2478d09)