Pipeline

noun

say it: “PYPE-lyne” /ˈpaɪpˌlaɪn/

A Node function that connects streams so data flows from a source to a destination piece by piece, waiting for slow writers and handling errors.

What does Node's pipeline function do?

pipeline, from node:stream/promises, joins streams so data flows from one to the next, such as a file being read into a file being written. It pauses the reader when the writer falls behind, passes any error on, and its promise finishes when the copy is done.

import { pipeline } from "node:stream/promises";
import { createReadStream, createWriteStream } from "node:fs";
import { createGzip } from "node:zlib";

await pipeline(
  createReadStream("sales-2026.csv"),
  createGzip(),
  createWriteStream("sales-2026.csv.gz"),
);

In a sentence

  • “Wrap pipeline in try/catch: if the disk fills up, its promise rejects with the error.”
  • “Using pipeline, the server copied a 2 GB video to disk without ever holding it all in memory.”

Level: Freelancer · More Node.js terms at this level

Updated

In other subjects