This package has been deprecated

Author message:

Moved to @web3-storage/pail

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

0.3.4 • 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'
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

Dependents (5)

Package Sidebar

Install

npm i @alanshaw/pail

Weekly Downloads

42

Version

0.3.4

License

Apache-2.0 OR MIT

Unpacked Size

101 kB

Total Files

29

Last publish

Collaborators

  • alanshaw