Open this example in the interactive library
Source code
import {
Readable,
Writable,
Transform,
PassThrough,
isReadable,
isWritable,
} from "node:stream";
import { text, json, arrayBuffer } from "node:stream/consumers";
import { pipeline, finished } from "node:stream/promises";
console.log(
await Readable.from([1, 2, 3])
.filter((n) => n % 2)
.toArray(),
);
Sample output
[ 1, 3 ]
