@alanshaw/pail
TypeScript icon, indicating that this package has built-in type declarations

0.3.3 • Public • Published

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'

// Initialize a new bucket
const blocks = new Blockstore() // like https://npm.im/blockstore-core
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

Install

npm i @alanshaw/pail

DownloadsWeekly Downloads

6

Version

0.3.3

License

Apache-2.0 OR MIT

Unpacked Size

100 kB

Total Files

29

Last publish

Collaborators

  • alanshaw