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

stagepipe

v0.0.5

Published

[![Build Status](https://travis-ci.org/delta62/stagepipe.svg?branch=master)](https://travis-ci.org/delta62/stagepipe)

Readme

Stagepipe

Build Status

Stagepipe is an asynchronous flow control library for JavaScript applications.

Application code is organized into "stages" and "pipes", represented by a multidimensional array. You can think of stages as the rows of the array and pipes as the columns. The entire data structure is caled a "pipeline".

//    Pipe 1         Pipe 2
//      |              |
//      V              V
[
  [ getFirstName, getEmail      ], // <-- Stage 1
  [ upperCase,    validateEmail ], // <-- Stage 2
  [ greetUser,    sendPromo     ]  // <-- Stage 3
]

Each stage is executed in sequence until all stages are completed or an unhandled exception occurs. Subsequent stages are not started until all pipes in the current stage are completed. For example, suppose that getEmail in the above example returned a promise that resolves after making an HTTP call to a remote server. Stage 2 will not begin until that HTTP call comes back and the data is ready.

The previous example could be called from code like so:

const { stagepipe } = require('stagepipe')

const pipes = // Contents from the previous example
const pipeline = stagepipe(pipes)

// Invoke the pipeline with a user ID as input
pipeline(userId)
  .then(() => console.log('Done!'))
  .catch(err => console.error(err))

Pipelines always have exactly one input and produce exactly one output. Because of this, the first example is not valid and needs to be rewritten like so:

[
  [ split()                     ],
  [ getFirstName, getEmail      ],
  [ upperCase,    validateEmail ],
  [ greetUser,    sendPromo     ]
]

This pipeline takes its input and splits it into two pipes which produce the same result. In the next stage, both getFirstName and validateEmail will receive as input the data passed to the pipeline.

You can split streams into as many concurrent pipes as you'd like:

[
  [ split(4)                                               ],
  [ getFirstName, getEmail, getFavoriteColor, getBirthDate ]
]

Note that it is valid to terminate a pipeline with multiple pipes even though only one output will be produced. In the previous example, the output of the pipeline would be the output of the getFirstName function.

Stages

Each stage is an array of pipes to execute. If a stage consists of only one pipe you can omit the array notation for convenience:

[
  split(), // <-- There is only one pipe in this stage, don't need [ ]
  [ getFirstName, getEmail ] // <-- Multiple pipes, must wrap in [ ]!
]

Pipes

Pipe elements are just functions. If a function returns a promise, the current stage of the pipe will not be completed until the promise resolves. For any other return value (including undefined), the result will be synchronously passed to the next stage. In other words, if you're doing something async, you need to return a Promise.

Data is fed through each pipe top to bottom, left to right. By default, each function is assumed to have an arity of 1. If you need to call a function with more than one argument (thus merging two pipes from the previous stage), use the arity function.

[
  [ split()    ],
//   |\
//   |  \
//   |    \
  [ foo,   bar ],
//   |      |
  [ baz,   qux ],
//   |     /
//   |   /
//   |/
  arity(2, myFunc)
]

API

  • stagepipe(pipeline) Returns a function that will execute the given pipeline. The function takes as input the starting state of the pipeline and returns a promise that will resolve to the output value of the pipeline.
  • split([count=2]) Splits a pipe into count pipes.
  • pass() A noop function that passes its input out to the next stage
  • arity(count, fn) Joins two or more pipes into one by calling fn with outputs of the previous stage. If there are not enough outputs in the previous stage, undefined will be passed as the remaining argument values.
  • print([count=1]) A debugging utility. Prints the state of count pipes and passes the data along to the next stage.

License

MIT