# @alanshaw/pail

> DAG based key value store.

Latest version **0.3.4** (published 2023-09-11) · Apache-2.0 OR MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @alanshaw/pail
pnpm add @alanshaw/pail
yarn add @alanshaw/pail
bun add @alanshaw/pail
```

Provides the command `pail`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.4 |
| Published | 2023-09-11 |
| First published | 2023-01-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 98.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 48 |
| Author | Alan Shaw |
| Maintainers | alanshaw |
| Keywords | bucket, KV, DAG, IPLD, CID, IPFS |

## Links

- npm: https://www.npmjs.com/package/@alanshaw/pail
- Repository: https://github.com/alanshaw/pail
- Homepage: https://github.com/alanshaw/pail#readme
- Issues: https://github.com/alanshaw/pail/issues
- npm.io page: https://npm.io/package/@alanshaw/pail

## Dependencies (6)

- [sade](https://npm.io/package/sade.md) ^1.8.1
- [archy](https://npm.io/package/archy.md) ^1.0.0
- [@ipld/car](https://npm.io/package/@ipld/car.md) ^5.0.1
- [cli-color](https://npm.io/package/cli-color.md) ^2.0.3
- [multiformats](https://npm.io/package/multiformats.md) ^12.1.1
- [@ipld/dag-cbor](https://npm.io/package/@ipld/dag-cbor.md) ^9.0.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 0.3.4 (latest) — 2023-09-11
- 0.3.3 — 2023-03-27
- 0.3.2 — 2023-03-27
- 0.3.1 — 2023-03-21
- 0.3.0 — 2023-03-20
- 0.2.1 — 2023-03-14
- 0.2.0 — 2023-03-14
- 0.1.1 — 2023-03-14
- 0.1.0 — 2023-01-24

## README

# pail

[![Test](https://github.com/alanshaw/pail/actions/workflows/test.yml/badge.svg)](https://github.com/alanshaw/pail/actions/workflows/test.yml)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

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

* 📖 [Read the SPEC](https://github.com/web3-storage/specs/blob/460b6511979a52ec9870f307695ee3f0b3860f81/kv.md).
* 🎬 [Watch the Presentation](https://youtu.be/f-BrtpYKZfg).

## Install

```
npm install @alanshaw/pail
```

## Usage

```js
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](https://github.com/alanshaw/pail/issues)!

## License

Dual-licensed under [MIT or Apache 2.0](https://github.com/alanshaw/pail/blob/main/LICENSE.md)

---
_Source: https://npm.io/package/@alanshaw/pail · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
