fruition
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

Fruition

Track execution paths and outcomes to form an explanation for understanding what happened

About

Fruition is a simple harness to record steps of execution by making "notes" (Nodes), which some of these being able to mark branching or measurements. It outputs a handy string description so application flow debugging can be improved.

NodeJS v16 and up is supported. Types are provided.

Usage

To get started, import the Fruition class:

import { Fruition } from "fruition";

function someFlow(): [number, Fruition] {
    const fruition = new Fruition("some-flow");
    // <some functionality>
    fruition.mark("db lookups");
    // <some functionality>
    if (true) {
        fruition.branch("dev mode", {
            dev: true,
            code: 123
        });
    }
    // Done
    return [1, fruition];
}

// Later
const [result, trace] = someFlow();
console.log(trace.toString());

Flow can be improved by adding the Realisation class:

import { Fruition, Realisation } from "fruition";

function someFlow(): Realisation<number> {
    const fruition = new Fruition("some-flow");
    // <snip>
    return new Realisation(1, fruition);
}

// Later
const realisation = someFlow();
console.log(trace.explain());

realisation.result // 1
realisation.trace // Fruition

TBC

Package Sidebar

Install

npm i fruition

Weekly Downloads

321

Version

0.2.2

License

MIT

Unpacked Size

14.7 kB

Total Files

17

Last publish

Collaborators

  • perrymitchell