Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 1.92 KB

File metadata and controls

36 lines (27 loc) · 1.92 KB

Documentation

Complete API documentation for @neabyte/typebox.

Concepts

  • Define - Build contracts and stateful contract builders.
  • Loader - Activate a contract map into a live callable facade.
  • State - Reducer-style stateful contracts with deep-immutable reads.
  • Validation - Guards, verdicts, and fail-closed rejection.
  • Types - Compile-time shapes exported for advanced usage.

Quick Reference

Name Purpose Form
Define Build a contract Define(contract, guard?)
Define.state Build a stateful contract Define.state(initialState, stepFn)
Loader Activate a contract map Loader(contractMap)
StateHandle Live stateful entry handle(payload?) / handle.get()

The Atom

type ContractFn = (input: never) => unknown

Every face of Typebox is the same atom in a different role:

Face Form Description
Operation Define((props) => result) A plain contract
Data Define(() => value) A contract with no meaningful input
State Define.state(initial, (state, payload) => next) A contract whose output becomes the next input
Validation Define(fn, guard) A contract with a guard
Async Define(async (props) => value) A contract returning a promise