Skip to content

mccraigmccraig/object-chains-ts

Repository files navigation

object-chains-ts

CI GitHub Contributors Deno Starter TypeScript semantic-release

⭐ Getting started

object-chains creates data-driven programs to process messages or events.

ObjectChain

An individual ObjectChain is a program to process a single type of value, and is built from a chain of steps (defined by a list of ObjectStepSpecs) into which an object is fed.

Each step in an ObjectChain has a key K and is either pure (having a pure function (arg: A) => V), or effectful (having both an input-transform (arg: A) => D and an FxFn - (d: D) => Effect.Effect<R, E, V>).

The output value V from a step's function will be appended to the step's input object at key K, forming an output object value which extends A & {K: V}. Requirements and Errors of the FxFns of effectful steps propagate upwards to the ObjectChain (or MultiChain).

The input type A of each step in a chain is constrained by the output value of the prior step and the output value of a step constrains the input of the succeeding step. The output of the final step in an ObjectChain is returned as the result.

An ObjectChain can be invoked as an FxFn i.e. (d: D) => Effect.Effect<R, E, V>

MultiChain

Multiple ObjectChains can be combined into a MultiChain, which can also be invoked as an FxFn.

ObjectChains in a MultiChain can invoke other ObjectChains in the same MultiChain (i.e. a DAG of function dependencies), but immediate recursion (i.e. cyclic function dependencies) is not possible.

upcoming

  • execution control - uniform tracing, logging, and error-handling (including retry-from-failure-point) using the ObjectStepSpec data-structures

genesis

object-chains is built with Effect and began life as an attempt to port a-frame to TypeScript

📄 License

MIT © mccraigmccraig of the clan mccraig

About

effectful data-driven chains to run computations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published