# multiblob

> A content-addressable store supporting multiple hash algorithms

Latest version **1.13.8** (published 2022-03-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install multiblob
pnpm add multiblob
yarn add multiblob
bun add multiblob
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.13.8 |
| Published | 2022-03-02 |
| First published | 2014-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 15 |
| Unpacked size | 18.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Dominic Tarr |
| Maintainers | chereseeriepa, happy0, staltz, arj03, pfrazee, mixmix, cel, christianbundy, mmckegg, dominictarr, marak, substack, ahdinosaur, cryp7ix |

## Links

- npm: https://www.npmjs.com/package/multiblob
- Repository: https://github.com/ssbc/multiblob
- Issues: https://github.com/ssbc/multiblob/issues
- npm.io page: https://npm.io/package/multiblob

## Dependencies (15)

- [cont](https://npm.io/package/cont.md) ^1.0.1
- [mkdirp](https://npm.io/package/mkdirp.md) ^1.0.4
- [rimraf](https://npm.io/package/rimraf.md) ^3.0.2
- [blake2s](https://npm.io/package/blake2s.md) ^1.0.1
- [pull-file](https://npm.io/package/pull-file.md) ^1.0.0
- [pull-glob](https://npm.io/package/pull-glob.md) ~1.0.6
- [pull-live](https://npm.io/package/pull-live.md) ^1.0.0
- [pull-catch](https://npm.io/package/pull-catch.md) ^1.0.0
- [pull-defer](https://npm.io/package/pull-defer.md) ^0.2.2
- [pull-notify](https://npm.io/package/pull-notify.md) ^0.1.1
- [pull-stream](https://npm.io/package/pull-stream.md) ^3.6.2
- [pull-paramap](https://npm.io/package/pull-paramap.md) ^1.2.2
- [clarify-error](https://npm.io/package/clarify-error.md) ^1.0.0
- [pull-write-file](https://npm.io/package/pull-write-file.md) ^0.2.1
- [stream-to-pull-stream](https://npm.io/package/stream-to-pull-stream.md) ^1.7.2

## Recent versions

- 1.13.8 (latest) — 2022-03-02
- 1.13.7 — 2020-01-15
- 1.13.6 — 2019-12-03
- 1.13.5 — 2019-11-22
- 1.13.4 — 2019-04-10
- 1.13.3 — 2019-01-14
- 1.13.2 — 2018-11-25
- 1.13.1 — 2018-09-04
- 1.13.0 — 2018-02-20
- 1.12.0 — 2017-07-07
- 1.11.1 — 2017-07-07
- 1.11.0 — 2017-06-03
- 1.10.4 — 2017-04-14
- 1.10.3 — 2017-04-13
- 1.10.2 — 2016-07-23
- … 21 more at https://npm.io/package/multiblob/versions

## README

# multiblob

A content-addressable-store that supports multiple hashing algorithms,
and pull-streams.

## example

``` js
var Blobs = require('multiblob')

var blobs = Blobs({ dir: '/media/blobCollection' })

pull(
  source, // a buffer stream e.g. from pull-file
  blobs.add(function (err, hash) {
    console.log('added source to blobs:', hash)
  })
)
```

## API

### Blobs(config) => blobs

where config is an Object with properties:
- `dir` _String_ - the directory to store blobs in
- `alg` _String_ (optional) - the algorithm for hashing. Valid options: `'blake2s'`, `'sha256'` (default: `'blake2s'`)
- `encode` _Function_ (optional) - converts a buffer to a string (default: see `util.js#encode`)
- `decode` _Function_ (optional) - recovers a string into an object `{ hash: Buffer, alg }` (default: see `util.js#decode`)
- `isHash` _Function_ (optional) - tests a string to check if it's a valid hash (default: see `util.js#isHash`)

### blobs.add (hash?, cb?) => Sink

Create a sink stream for writing a blob.
Expects to receive a buffer stream.

If `hash` was given, then it will error if the file turned out to be different.
If a `cb` is not given and there was an error, this function will throw.

### blobs.get (hash || opts) => Source

Takes the hash of blob already in the store and return a source buffer stream.
If the file does not exist this stream will error.

If the argument is a `hash` string, then return the stream.
If the argument is an `opts` object, with the `key: hash` property,
retrive that blob, but error if the size does not exactly match the
`size` property, or is over `max` property (in bytes)

### blobs.getSlice(opts) => Source

create a source stream that reads a slice of a given blob,
from the `start` property to the `end` property, in bytes.
Error if the file does not exist or if
the size of the whole blob does not exactly match the
`size` property, or is over `max` property (in bytes).

### blobs.has(hash, cb)

check if the given hash is in the store.
If `hash` is an array of hashes,
`size` will callback with an array of booleans.

### blobs.size(hash, cb)

get the size of this blob. If `hash` is an array of hashes,
`size` will callback with an array of sizes.
If the hash does not exist in the store, `size` will callback `null`.


### blobs.ls() => Source

source stream that reads the list of hashes available in the store.

### blobs.rm(hash, cb)

remove a hash from the store.

### blobs.isEmptyHash(hash)

Check if a given hash is actually the empty hash. If something has the empty hash,
that is probably a bug. The above methods will act like the empty file is already in the store.

### blobs.meta

???

### blobs.resolve

???


## todo

maybe emit events when blobs are stored?

## License

MIT

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