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

@hautechai/pipelines

v2.0.3

Published

Framework to build and run pipelines in JavaScript

Readme

Pipeline Task Orchestration Library

Overview

A TypeScript library for creating, managing, and orchestrating asynchronous tasks in a dependency-aware "pipeline." This library allows you to:

  • Define methods (async functions) that can be queued as tasks.
  • Chain tasks by referencing the output of other tasks.
  • Automatically resolve dependencies and run tasks in the correct order.
  • Inspect task statuses (pending, in-progress, completed, failed).
  • Retrieve (unwrap) final results from tasks.

Table of Contents

  1. Installation

  2. Key Concepts

  3. Usage

  4. API Reference

Installation

To install this package, you can use npm or yarn:

npm install @hautechai/pipelines

or

yarn add @hautechai/pipelines

Key Concepts

Tasks

  • Each task is associated with one of your defined methods.
  • A task can depend on other tasks. The library automatically ensures that dependent tasks only start once all of their dependencies have completed.
  • Each task has a status: pending, completed, or failed.

References

  • If Task A depends on the result of Task B, you can reference Task B’s result in Task A’s arguments.
  • Internally, this reference is a kind of "placeholder" that will be resolved when the pipeline runs.

Pipeline

  • A Pipeline manages tasks, maintains state, and orchestrates the execution order.
  • You queue tasks using either pipeline.defer or pipeline.after(...taskIds).
  • The pipeline runs tasks in topological order (i.e., respecting dependencies).

Usage

Basic Example

import { Pipeline, Methods } from "@hautechai/pipelines";

// Define your methods
const Methods = {
  async generateNumber() {
    return 42;
  },
  async multiply(number, factor) {
    return number * factor;
  },
};

// Create a new pipeline
const pipeline = new Pipeline(Methods);

// Add tasks to the pipeline
const task1 = pipeline.defer.generateNumber();
const task2 = pipeline.defer.multiply(task1.result, 2);

// Run the pipeline
(async () => {
  await pipeline.run();
  console.log(`Result: ${await pipeline.unwrap(task2.result)}`); // Result should be 84
})();

Error Handling

The pipeline can gracefully handle errors:

import { Pipeline, Methods } from "@hautechai/pipelines";

// Define your methods
const Methods = {
  async generateNumber() {
    return 42;
  },
  async methodWithError() {
    throw new Error("Error in method");
  },
};

// Create a new pipeline
const pipeline = new Pipeline(Methods);

const task1 = pipeline.defer.generateNumber();
const task2 = pipeline.defer.methodWithError(task1.result);

(async () => {
  await pipeline.run();
  if (pipeline.status === PipelineStatus.FAILED) {
    console.error("Pipeline failed:", pipeline.state);
  }
})();

API Reference

Constructor

  • new Pipeline(methods: Methods, options?: { onChangeState?: Function; serializeError?: Function; state?: PipelineState; tasks?: Task[]; })
    • methods: An object defining methods the pipeline can execute.
    • options: Optional settings for the pipeline.

Methods

  • after(...taskIds: string[]): Create deferred methods that depend on the completion of specified tasks.
  • run(): Start executing the pipeline.
  • status: Get the current pipeline status.
  • state: Get the current state of the pipeline.
  • tasks: Get the list of current tasks.
  • loadState(state: PipelineState): Load a previously saved state into the pipeline.
  • unwrap(value: T): Unwrap reference values to their actual results.