# @web3-storage/blob-index

> An index for slices that may be sharded across multiple blobs.

Latest version **1.0.5** (published 2024-12-19) · Apache-2.0 OR MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @web3-storage/blob-index
pnpm add @web3-storage/blob-index
yarn add @web3-storage/blob-index
bun add @web3-storage/blob-index
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-12-19 |
| First published | 2024-05-14 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.15 |
| Dependencies | 8 |
| Unpacked size | 126.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 87 |
| Maintainers | alanshaw, it-dag-house, fforbeck |

## Links

- npm: https://www.npmjs.com/package/@web3-storage/blob-index
- Repository: https://github.com/storacha/w3up
- Homepage: https://web3.storage
- Issues: https://github.com/storacha/w3up/issues
- npm.io page: https://npm.io/package/@web3-storage/blob-index

## Dependencies (8)

- [carstream](https://npm.io/package/carstream.md) ^2.1.0
- [uint8arrays](https://npm.io/package/uint8arrays.md) ^5.0.3
- [@ucanto/core](https://npm.io/package/@ucanto/core.md) ^10.0.1
- [multiformats](https://npm.io/package/multiformats.md) ^13.0.1
- [@ipld/dag-cbor](https://npm.io/package/@ipld/dag-cbor.md) ^9.0.6
- [@ucanto/interface](https://npm.io/package/@ucanto/interface.md) ^10.0.1
- [@storacha/one-webcrypto](https://npm.io/package/@storacha/one-webcrypto.md) ^1.0.1
- [@web3-storage/capabilities](https://npm.io/package/@web3-storage/capabilities.md) ^18.0.1

## Recent versions

- 1.0.5 (latest) — 2024-12-19
- 1.0.4 — 2024-07-29
- 1.0.3 — 2024-06-04
- 1.0.2 — 2024-05-15
- 1.0.1 — 2024-05-14

## README

# `@web3-storage/blob-index`

An index for slices that may be sharded across multiple blobs.

## Install

```sh
npm install @web3-storage/blob-index
```

## Usage

Create:

```js
import { ShardedDAGIndex } from '@web3-storage/blob-index'

// Create a brand new index
const index = ShardedDAGIndex.create(rootCID)

// Add index data for slices within a shard
index.setSlice(shardMultihash, sliceMultihash, [offset, length])
// ...

// Create CAR archive
const result = index.archive()

console.log(result.ok) // a Uint8Array
```

Read:

```js
import { ShardedDAGIndex } from '@web3-storage/blob-index'
import { base58btc } from 'multiformats/bases/base58'

const index = ShardedDAGIndex.extract(car)

console.log(index.content)

for (const [shard, slices] of index.shards.entries()) {
  console.log(`Shard ${base58btc.encode(shard.bytes)}`)
  console.log('  Slices:')
  for (const [slice, [offset, length]] of slices.entries()) {
    console.log(`    ${base58btc.encode(slice.bytes)} @ ${offset} -> ${offset + length}`)
  }
}

// Output:
// Shard zQmQKw6B745GGL3eeTcEE5kAoLAJgkBQydJPC5fWv5HA68A
//  Slices:
//    zQmeHPRNRDxHU5YMPewcBCbPYxzA3jBcadAZQwpQXm3jFFt @ 96 -> 128
// ...
```

## Contributing

Feel free to join in. All welcome. Please [open an issue](https://github.com/storacha/w3up/issues)!

## License

Dual-licensed under [MIT + Apache 2.0](https://github.com/storacha/w3up/blob/main/license.md)

---
_Source: https://npm.io/package/@web3-storage/blob-index · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
