Skip to content
Eugene Lazutkin edited this page Jun 6, 2026 · 37 revisions

This is the home of the 4.x version. Upgrading from 3.x? See the Migration guide. The home for 2.x is here.

Node.js CI NPM version

stream-chain builds object-processing pipelines from plain functions, generators, and existing streams — handling backpressure for you — on Node streams, Web streams, or neither. This page routes you to the right doc; for the 30-second pitch, see the README.

Search

🔍 Search this wiki — ranked, deep-linked search via wiki-search; install the bookmarklet to search in place. Fallback: GitHub wiki search.

Start here

New to stream-chain? Read in this order, then dip into the reference sections below:

  1. Concepts — the model (one input → zero-to-many outputs), why streams, and how performance shaped the design.
  2. Intro by examples — those concepts as runnable pipelines; the quickest way to see how it feels.
  3. Performance — once it works, how to keep it fast and how to package reusable components.

API

  • chain() — the heart of the package (imported as stream-chain). Choose a substrate by import path:
    • stream-chain / stream-chain/node — Node streams (default).
    • stream-chain/web — native Web streams; browser-safe.
    • stream-chain/core — substrate-free async iterables; the leanest option.
  • Transducers — compose functions into one fused stage:
    • gen() — async generator; the memory-flat default.
    • fun() — function returning a batch; faster on sync pipelines, but holds outputs in memory (explicit import).
  • Adapters — wrap a function as a standalone stream:
  • defs — the special values (none, stop, many, finalValue, flushable) and stream type guards.

I/O and utilities

  • JSONL — batteries-included object I/O: parser / stringer for both substrates, plus the fused parseFile / stringerToFile file-edge composites.
  • utils — the helper catalog: slicing (take / skip / …), folding (fold / scan / reduceStream), stream adapters (readableFrom, …), line / UTF-8 / batch helpers, block file I/O, and the pipe / drain drivers.
  • streamPuller / webStreamPuller — consume a Node Readable / Web ReadableStream as a non-destructive async iterator.

Tuning and internals

For when it already works and you want more speed or more leverage:

  • highWaterMark — tuning flow and backpressure.
  • Benchmarks — how performance is measured, and how to run them.
  • Typed streams — the TypeScript machinery behind pipeline I/O types.

Reference

Clone this wiki locally