0.3.0 • Published 2 months ago

@canvas-js/okra-idb v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@canvas-js/okra-idb

NPM version TypeScript types

Install

npm i @canvas-js/okra-idb

Usage

import { openDB } from "idb"
import { IDBTree } from "@canvas-js/okra-idb"

const tree = await MemoryTree.open()

// ...

API

type Key = Uint8Array | null
type Node = { level: number; key: Key; hash: Uint8Array; value?: Uint8Array }
type Bound<T> = { key: T; inclusive: boolean }

declare class IDBTree {
	public static open(db: IDBPDatabase, storeName: string, options?: Partial<Metadata>): Promise<IDBTree>

	private constructor()

	public get(key: Uint8Array): Promise<Uint8Array | null>
	public set(key: Uint8Array, value: Uint8Array): Promise<void>
	public delete(key: Uint8Array): Promise<void>

	public entries(
		lowerBound?: Bound<Uint8Array> | null,
		upperBound?: Bound<Uint8Array> | null,
		options: { reverse?: boolean }
	): AsyncGenerator<[Uint8Array, Uint8Array]>

	public getRoot(): Promise<Node>
	public getNode(level: number, key: Key): Promise<Node | null>
	public getChildren(level: number, key: Key): Promise<Node[]>

	public nodes(
		level: number,
		lowerBound?: Bound<Key> | null,
		upperBound?: Bound<Key> | null,
		options: { reverse?: boolean }
	): AsyncGenerator<Node>
}
0.3.0

2 months ago

0.2.4

5 months ago

0.2.3

5 months ago

0.1.0

9 months ago

0.2.1

8 months ago

0.2.0

8 months ago

0.1.1

9 months ago

0.2.2

6 months ago

0.0.2

1 year ago

0.0.1

1 year ago