stream-to-promise
June 19, 2026 ยท View on GitHub
Warning
Deprecated. Node.js now ships promise-based stream helpers in core, so this package is no longer needed. It will receive no further updates. See the migration guide below.
Migrating
Node 16+ covers everything this package did with the built-in
node:stream/promises
and node:stream/consumers modules.
Readable Streams
Collect a readable stream into a Buffer with
consumers.buffer,
or into a string with
consumers.text:
const { buffer, text } = require('node:stream/consumers')
const buf = await buffer(readableStream)
const str = await text(readableStream)
For object-mode streams, use
Readable.prototype.toArray:
const parts = await readableStream.toArray()
Writable Streams
Wait for a writable (or any) stream to finish with
finished:
const { finished } = require('node:stream/promises')
writableStream.write('data')
writableStream.end()
await finished(writableStream)
To run data through a pipeline and await completion, use
pipeline:
const { pipeline } = require('node:stream/promises')
await pipeline(source, transform, destination)