Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

fruition

perry-mitchell536MIT0.2.2TypeScript support: included

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

executuion, path, explain, result, outcome, describe

readme

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

changelog

Fruition

v0.2.2

2023-11-02

  • Bugfix:
    • Branch node value encoding shows stringified results instead of JSON encoded

v0.2.1

2023-09-11

  • Bugfix:
    • Encoding for complex values would fall back to [object Object] etc.

v0.2.0

2023-09-10

  • createEmptyRealisation helper for empty Realisations

v0.1.0

2023-09-06

  • Initial release