hashed blob storage
npm install @e280/behemoth

- 🗿 behemoth stores binary data, anywhere.
- 🔒 content-addressable -- sha256 hashes for identity (never store a dupe)
- 🔮 blob-oriented -- blobs provide random-access and are generally super cool
- 🏞️ stream-oriented -- streams allow you to upload/download big stuff smoothly
- ♻️ isomorphic -- runs in browsers or node
- 🛰️ remote -- (coming soon) connect to a remote behemoth api service
Behemoth
- .has(hash: Hash): Promise
``ts`
const exists = await behemoth.has(hash)
.require(hash: Hash): Promise
- `
ts`
const blob = await behemoth.require(hash)
.get(hash: Hash): Promise
- `
ts`
const blob = await behemoth.get(hash)
.set(blob: Blob, options?: SetOptions): Promise
- `
ts`
const hash = await behemoth.set(blob)
`
ts`
const hash = await behemoth.set(blob, {
onProgress: progress => {
progress.total // number, total amount of work
progress.done // number, amount of work completed
},
})
.delete(...hashes: Hash[]): Promise
- `
ts`
await behemoth.delete(hash)
`ts
import {BehemothOpfs} from "@e280/behemoth"
const behemoth = await BehemothOpfs.mkdir("my-data")
`
`ts
import {BehemothDisk} from "@e280/behemoth/node"
// 👆
const behemoth = await BehemothDisk.mkdir("./my-data")
`
`ts
import {BehemothMemory} from "@e280/behemoth"
const behemoth = new BehemothMemory()
`
- hashBlob(blob: Blob, onProgress: (hashed: number) => void): Promise
`ts`
const hash = await hashBlob(blob)
`
tsbytes hashed: ${hashed}
const hash = await hashBlob(blob, hashed => {
console.log()`
})
readBlob(blob: Blob): AsyncGenerator
- `
ts`
for await (const chunk of readBlob(blob))
chunk
readStream(stream: ReadableStream
- `
ts``
for await (const chunk of readStream(stream))
chunk