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

@maysale01/flowjs

v0.0.8

Published

A simple library for executing in-memory workflows.

Readme

FlowJS

A simple in-memory framework for creating workflows in JS.

Very much WIP. Tests incoming.

Flows

A workflow or Flow is a composition of Activities that are executed sequentially, with a Decider determining the next Activity upon completion. The Context represents the state of the workflow and is the only stateful component. The Decider depends solely on the Context to determine the next activity - in the example we simply map the flow states to different activities.

A workflow is composed of four implementation-specific components:

  • Decider
  • Context
  • A set of logical workflow states
  • A set of Activities

And a Flow executor that steps through the workflow and handles exceptions.

Workflow States

The Flow executor expects a map of Symbols that represent the possible states in the workflow. Two default states must exists: START and END.

    var flowStates = {
        START : Symbol("START"),
        A : Symbol("A"),
        B : Symbol("B"),
        END : Symbol("END")
    }

Activities

At the core of the workflow, are Activities. Each Activity is single logical step in the workflow and is ideally idempotent. Activities are stateless, they are passed the workflow's Context during execution. To pass state between activities, subclass the context for your workflow to set/get state.

The Activity class only has two properties:

  • Name, and
  • A function that accepts a context and executes the activity's business logic.

Note: Currently, the activity is responsible for setting the next state. The core logic in the Flow will retry activites that throw exceptions if the instanceof RetryableException => true.

Example:

  var ActivityA = new Activity("ActivityA", function (context) {
      console.log("Executing ActivityA");
      context.setState(context._states.B);
  });

  var ActivityB = new Activity("ActivityB", function (context) {
      console.log("Executing ActivityB");
      // Will retry until it exhausts attempts
      throw new RetryableException();
      context.setState(context._states.END);
  });

Decider

The Decider is responsible for taking a context and returning the next Activity to execute. Note in the example, we define a starting activity -- this is required at the moment.

Example:

    var decider = new Decider(function(context){
        switch(context.getState()) {
            case flowStates.START: return ActivityA;
            case flowStates.A: return ActivityA;
            case flowStates.B: return ActivityB;
        }
    });

Debug

Set DEBUG=flowjs:* to get debug output.

Events

  • success (Flow)
  • failure (Flow)
  • complete (Flow)
  • error (Error, Flow)