Sugar
@mantaq/sugar wraps core primitives with convenience helpers. Every helper
compiles to the same behavior you could write yourself.
Helpers
Section titled “Helpers”| Helper | Purpose |
|---|---|
states(), events() | Batch create states/events |
matches(), isIn(), activeLeaves(), tag() | State matching and grouping |
ActorMap, broadcast() | Dynamic child management |
withPromise(), withTimeout() | Effect helpers |
actorSpec, definePart, withParts | Split setup across files |
Install
Section titled “Install”npm install @mantaq/sugarRequires @mantaq/core. Single entry point:
import { matches, states, events } from "@mantaq/sugar";When to use
Section titled “When to use”Use sugar when many states/events, frequent state checks, dynamic children, or promise effects. Skip when few states, minimal checks, no dynamic children, or custom effect patterns.
Core is sufficient for everything. Sugar saves typing.
- Batch Creation:
states()andevents() - Matching:
matches(),isIn(),activeLeaves(),tag() - Composition:
actorSpec,definePart,withParts - Dynamic Children:
ActorMapandbroadcast() - Effect Helpers:
withPromise()andwithTimeout() - Request / Response: short-lived request handlers