0.3.4 • Published 8 months ago

@alanshaw/pail v0.3.4

Weekly downloads
-
License
Apache-2.0 OR MIT
Repository
github
Last release
8 months ago

pail

Test JavaScript Style Guide

DAG based key value store. Sharded DAG that minimises traversals and work to build shards.

Install

npm install @alanshaw/pail

Usage

import { ShardBlock, put, get, del } from '@alanshaw/pail'
import { MemoryBlockstore } from '@alanshaw/pail/block'

// Initialize a new bucket
const blocks = new MemoryBlockstore()
const init = await ShardBlock.create() // empty root shard
await blocks.put(init.cid, init.bytes)

// Add a key and value to the bucket
const { root, additions, removals } = await put(blocks, init.cid, 'path/to/data0', dataCID0)

console.log(`new root: ${root}`)

// Process the diff
for (const block of additions) {
  await blocks.put(block.cid, block.bytes)
}
for (const block of removals) {
  await blocks.delete(block.cid)
}

Contributing

Feel free to join in. All welcome. Open an issue!

License

Dual-licensed under MIT or Apache 2.0