npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yaos-git/flow-lib

v226.0.1

Published

Schema-first flow orchestration library with pattern-based events.

Downloads

75

Readme

Node Version TypeScript Version Uses Vitest Uses Biome


Table of Contents

Overview

@yaos-git/flow solves the problem of "Callback/Promise Hell" in complex business logic by treating workflows as a Directed Graph of Validated Transitions. By using JavaScript Generators, it provides a clean, readable syntax for handling jumps (GOTO), subroutines (CALL/BACK), and robust error recovery without recursive nesting.

Key Features

  • Deterministic State Machine: Explicitly manage linear and global transitions.
  • Generator Powered: Use yield to signal transitions while keeping logic readable.
  • Schema-First: Built-in Zod validation for every step input.
  • Immutable Context: Strictly enforced immutable state snapshots for pure logical transitions.
  • Event Lifecycle: Intercept failure, yields, and interruptions with .on() handlers.

Installation

npm install @yaos-git/flow-lib

Quick Start

import { createFlow, z } from '@yaos-git/flow';

const flow = createFlow({ count: 0 })
  .step('start', function* (_, { step }) {
    yield step.next(10);
  })
  .step('double', {
    input: z.number(),
    action: function* (n, { step, updateContext, context }) {
      updateContext({ count: context.count + 1 });
      yield step.next(n * 2);
    }
  });

const result = await flow.run();
// result: { ok: true, data: 20 }

Core Concepts

FlowBuilder

The fluent API used to define your workflow.

  • .step(name, action): Adds a linear step to the main execution chain.
  • .global(name, action): Adds a named step available for .jump() from anywhere.
  • .on(event, handler): Attaches a lifecycle listener.

FlowApi

Every step action receives an API object:

  • step: Factory for signals (next, jump, back, halt, fail, retry).
  • context: Readonly access to the current state.
  • updateContext(patch): Returns a new frozen context snapshot.

Control Flow

Jumps & Subroutines

  • yield step.jump('linearStep', data): A GOTO transition. Terminates the current step and moves the execution pointer.
  • yield step.jump('globalStep', data): A CALL transition. Pushes the global step onto the call stack.
  • yield step.back(data): Returns from a global step, injecting data back into the caller.

Event Interception

Recover from failures or handle interruptions gracefully:

flow.on('fail', async (err, { step }) => {
  if (err.message === 'RETRY_ME') {
    return step.jump('recovery_step', null);
  }
});

Tech Stack

  • TypeScript 5.9 (ESM only)
  • Zod (Validation)
  • Vitest (Unit & E2E Testing)
  • esbuild (Bundling)
  • Biome (Linting & Formatting)

Project Structure

flow-lib/
├── dist/                # Compiled ESM bundle and declarations
├── examples/            # Standardized usage examples
│   ├── basic/           # Simple linear flows
│   ├── custom/          # Custom handlers and recovery
│   └── integration/     # Subroutines and complex logic
├── src/                 # Core source code
│   ├── core/            # Modular engine components
│   │   ├── FlowBuilder/
│   │   ├── FlowRunner/
│   │   ├── StepRegistry/
│   │   └── StepResolver/
│   ├── types/           # Granular type definitions
│   │   ├── FlowSignal/
│   │   ├── FlowAction/
│   │   └── ...
│   └── index.ts         # Main entry point
├── package.json         # Project metadata
└── README.md            # Documentation

Versioning

YAOS standard: MAJORYY.MINOR.PATCH (e.g., 126.0.0).

Style Guide

Follows YAOS-Git AGENTS.md conventions.

License

ISC