Skip to main content
import * as BinaryTree from 'voltaire-effect/primitives/BinaryTree'
import { Effect } from 'effect'

const program = Effect.gen(function* () {
  const tree = yield* BinaryTree.init()
  
  const key = new Uint8Array([1, 2, 3])
  const value = new Uint8Array([10, 20, 30])
  
  const updated = yield* BinaryTree.insert(tree, key, value)
  const retrieved = yield* BinaryTree.get(updated, key)
  const root = BinaryTree.rootHash(updated)
  
  return { root, retrieved }
})

API

FunctionSignature
init() => Effect<BinaryTreeType>
insert(tree, key, value) => Effect<BinaryTreeType, Error>
get(tree, key) => Effect<Uint8Array | null>
rootHash(tree) => Uint8Array (pure, 32 bytes)
SchemaEffect Schema for validation