@e280/behemoth
v0.1.0-6
Published
hashed blob storage
Maintainers
Readme

BEHEMOTH
hashed blob storage. on opfs. in memory. on disk. in orbit.
- 🗿 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
🐉 abstract Behemoth
all behemoths have the same shape
Behemoth
.has(hash: Hash): Promise<boolean>const exists = await behemoth.has(hash).require(hash: Hash): Promise<Blob>const blob = await behemoth.require(hash).get(hash: Hash): Promise<Blob | undefined>const blob = await behemoth.get(hash).set(blob: Blob, options?: SetOptions): Promise<Hash>const hash = await behemoth.set(blob)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<void>await behemoth.delete(hash)
🐉 BehemothOpfs
store data in the browser's origin private file system
import {BehemothOpfs} from "@e280/behemoth"
const behemoth = await BehemothOpfs.mkdir("my-data")🐉 BehemothDisk
store data to disk via node fs
import {BehemothDisk} from "@e280/behemoth/node"
// 👆
const behemoth = await BehemothDisk.mkdir("./my-data")🐉 BehemothMemory
store data in memory
import {BehemothMemory} from "@e280/behemoth"
const behemoth = new BehemothMemory()🐉 tools
handy tools you might wanna use
hashBlob(blob: Blob, onProgress: (hashed: number) => void): Promise<Hash>const hash = await hashBlob(blob)const hash = await hashBlob(blob, hashed => { console.log(`bytes hashed: ${hashed}`) })readBlob(blob: Blob): AsyncGenerator<Uint8Array>for await (const chunk of readBlob(blob)) chunkreadStream(stream: ReadableStream<Uint8Array>): AsyncGenerator<Uint8Array>for await (const chunk of readStream(stream)) chunk
🧑💻 open source
e280.org, github stars plz
