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 🙏

© 2025 – Pkg Stats / Ryan Hefner

flowsteps

v0.0.2

Published

A flexible, type-safe workflow orchestration library for Node.js

Downloads

14

Readme

FlowSteps

A flexible, type-safe workflow automation library for Node.js.

Features

🚀 Core Capabilities

  • Step-based workflow execution
  • Conditional branching
  • Parallel execution
  • Type-safe context passing

Advanced Features

  • Input validation (Zod integration)
  • Retry mechanisms with backoff strategies
  • Built-in metrics collection
  • Lifecycle hooks
  • Error handling and recovery

Installation

npm install flowsteps

Quick Start

import { Workflow, WorkflowContext } from "flowsteps";

interface OnboardingContext extends WorkflowContext {
  userId: string;
  email: string;
  userProfile?: {
    name: string;
    preferences: {
      theme: "light" | "dark";
      newsletter: boolean;
    };
  };
  welcomeEmailSent?: boolean;
  analyticsTracked?: boolean;
  error?: string;
}

const onboardingWorkflow = new Workflow<OnboardingContext>({
  name: "user-onboarding",
  hooks: {
    onError: ({ error, stepName }) => {
      console.error(`Error during ${stepName}:`, error);
    },
  },
})
  .addStep({
    fn: async ({ context }) => {
      context.userProfile = {
        name: context.email.split("@")[0],
        preferences: {
          theme: "light",
          newsletter: true,
        },
      };
    },
    config: { name: "create-profile" },
  })
  .addStep({
    fn: async ({ context }) => {
      await sendWelcomeEmail(context.email, context.userProfile);
      context.welcomeEmailSent = true;
    },
    config: {
      name: "send-welcome-email",
      retries: { maxAttempts: 2, backoff: { type: "fixed", delay: 2000 } },
    },
  })
  .addStep({
    fn: async ({ context }) => {
      await trackSignup(context.userId, context.userProfile);
      context.analyticsTracked = true;
    },
    config: { name: "track-analytics" },
  });

const result = await onboardingWorkflow.execute({
  context: {
    userId: "user_123",
    email: "[email protected]",
  },
});

Core Concepts

Conditional Branching

Create dynamic workflows with condition-based execution paths:

workflow.addCondition({
  branches: [
    {
      name: "premium-user",
      condition: ({ context }) => context.userData?.isPremium,
      workflow: premiumWorkflow,
    },
    {
      name: "regular-user",
      condition: ({ context }) => !context.userData?.isPremium,
      workflow: regularWorkflow,
    },
  ],
});

Parallel Execution

Run multiple workflows concurrently for improved performance:

const mainWorkflow = new Workflow().parallel([
  notificationWorkflow,
  dataProcessingWorkflow,
  analyticsWorkflow,
]);

Input Validation

Ensure data integrity with Zod schema validation:

import { z } from "zod";
import { ZodValidator } from "flowsteps";

const userSchema = z.object({
  userId: z.number(),
  email: z.string().email(),
  age: z.number().min(18),
});

const workflow = new Workflow({
  validator: new ZodValidator(userSchema),
});

Lifecycle hooks

Control workflow execution with fine-grained hooks to add custom behavior at various stages of the workflow.

const workflow = new Workflow<WorkflowContext>({
  hooks: {
    beforeWorkflow: ({ context }) => {
      console.log("Starting workflow with context:", context);
    },
    beforeStep: ({ stepName, context }) => {
      console.log(`Starting step: ${stepName}`);
    },
    afterStep: ({ stepName, context }) => {
      console.log(`Completed step: ${stepName}`);
    },
    afterWorkflow: ({ context }) => {
      console.log("Workflow completed with context:", context);
    },
    onError: ({ error, stepName, context }) => {
      console.error(`Error in step ${stepName}:`, error);
    },
  },
});

API Reference

Workflow

Constructor Options

| Option | Type | Description | | ------------------ | ------------------ | ---------------------------- | | name | string | Optional workflow identifier | | validator | Validator<T> | Input validation handler | | metricsCollector | MetricsCollector | Custom metrics collection | | hooks | WorkflowHooks<T> | Lifecycle event handlers |

Methods

| Method | Description | | ------------------------------------------- | ------------------------------ | | addStep(params: StepConstructorParams<T>) | Add a new step to the workflow | | addCondition(config: ConditionConfig<T>) | Add conditional branching | | parallel(workflows: Workflow<T>[]) | Execute workflows in parallel | | execute(params: { context: T }) | Run the workflow |

Contributing

We welcome contributions! Please see our Contributing Guide for details on how to:

  • Submit issues
  • Create pull requests
  • Follow our coding standards

License

This project is licensed under the MIT License - see the LICENSE file for details.