# @canvas-js/okra

> A p2p merkle index in pure JavaScript

Latest version **0.4.7** (published 2025-03-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @canvas-js/okra
pnpm add @canvas-js/okra
yarn add @canvas-js/okra
bun add @canvas-js/okra
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.7 |
| Published | 2025-03-19 |
| First published | 2023-05-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 42.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 34 |
| Author | Joel Gustafson |
| Maintainers | joelg, raykyri, rjwebb |

## Links

- npm: https://www.npmjs.com/package/@canvas-js/okra
- Repository: https://github.com/canvasxyz/okra-js
- Homepage: https://github.com/canvasxyz/okra-js#readme
- Issues: https://github.com/canvasxyz/okra-js/issues
- npm.io page: https://npm.io/package/@canvas-js/okra

## Dependencies (4)

- [weald](https://npm.io/package/weald.md) ^1.0.4
- [uint8arrays](https://npm.io/package/uint8arrays.md) ^5.1.0
- [@noble/hashes](https://npm.io/package/@noble/hashes.md) ^1.7.1
- [@canvas-js/utils](https://npm.io/package/@canvas-js/utils.md) ^1.0.0

## Recent versions

- 0.4.7 (latest) — 2025-03-19
- 0.4.6 — 2024-11-14
- 0.4.5 — 2024-09-08
- 0.4.4 — 2024-06-12
- 0.4.3 — 2024-06-12
- 0.4.2 — 2024-06-12
- 0.4.1 — 2024-06-10
- 0.4.0 — 2024-06-10
- 0.3.0 — 2024-03-25
- 0.2.0 — 2023-09-15
- 0.1.1 — 2023-08-20
- 0.1.0 — 2023-08-19
- 0.0.1 — 2023-05-04

## README

# `@canvas-js/okra`

[![NPM version](https://img.shields.io/npm/v/@canvas-js/okra)](https://www.npmjs.com/package/@canvas-js/okra) ![TypeScript types](https://img.shields.io/npm/types/@canvas-js/okra)

## Install

```
npm i @canvas-js/okra
```

## Usage

```ts
import { sync } from "@canvas-js/okra"
import { MemoryTree } from "@canvas-js/okra-memory"

const source = await MemoryTree.open()
const target = await MemoryTree.open()

const hex = (hex: string) => Buffer.from(hex, "hex")

await source.set(hex("00"), hex("aa"))
await target.set(hex("00"), hex("aa"))

await source.set(hex("01"), hex("bb"))

await source.set(hex("02"), hex("cc"))
await target.set(hex("02"), hex("dd"))

async function collect<T>(iter: AsyncIterable<T>): Promise<T[]> {
	const values = []
	for await (const value of iter) {
		values.push(value)
	}
	return values
}

const delta = await collect(sync(source, target))
console.log(delta)
// [
//   { key: <Buffer 01>, source: <Buffer bb>, target: null },
//   { key: <Buffer 02>, source: <Buffer cc>, target: <Buffer dd> }
// ]
```

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