Version 1.0.0
@stackline/concat-stream
writable stream that concatenates strings or binary data and calls a callback with the result
Independent maintenance of concat-stream 2.0.0. Original authors and licenses are retained.
Installation
# Preserve existing imports with an npm alias
npm install concat-stream@npm:@stackline/concat-stream@1.0.0
# Or use the scoped package name in your imports
npm install @stackline/concat-stream@1.0.0Node.js: ['node >= 6.0']. Read the compatibility and maintenance notes before migrating.
Usage and API
The reference below may retain upstream package names. Use the alias installation above to run those imports with this Stackline release.
concat-stream
Writable stream that concatenates all the data from a stream and calls a callback with the result. Use this when you want to collect all the data from a stream into a single buffer.
description
Streams emit many buffers. If you want to collect all of the buffers, and when the stream ends concatenate all of the buffers together and receive a single buffer then this is the module for you.
Only use this if you know you can fit all of the output of your stream into a single Buffer (e.g. in RAM).
There are also objectMode streams that emit things other than Buffers, and you can concatenate these too. See below for details.
Related
concat-stream is part of the mississippi stream utility collection which includes more useful stream modules similar to this one.
examples
Buffers
var fs = require('fs')
var concat = require('concat-stream')
var readStream = fs.createReadStream('cat.png')
var concatStream = concat(gotPicture)
readStream.on('error', handleError)
readStream.pipe(concatStream)
function gotPicture(imageBuffer) {
// imageBuffer is all of `cat.png` as a node.js Buffer
}
function handleError(err) {
// handle your error appropriately here, e.g.:
console.error(err) // print the error to STDERR
process.exit(1) // exit program with non-zero exit code
}
Arrays
var write = concat(function(data) {})
write.write([1,2,3])
write.write([4,5,6])
write.end()
// data will be [1,2,3,4,5,6] in the above callback
Uint8Arrays
var write = concat(function(data) {})
var a = new Uint8Array(3)
a[0] = 97; a[1] = 98; a[2] = 99
write.write(a)
write.write('!')
write.end(Buffer.from('!!1'))
See test/ for more examples
methods
var concat = require('concat-stream')
var writable = concat(opts={}, cb)
Return a writable stream that will fire cb(data) with all of the data that
was written to the stream. Data can be written to writable as strings,
Buffers, arrays of byte integers, and Uint8Arrays.
By default concat-stream will give you back the same data type as the type of the first buffer written to the stream. Use opts.encoding to set what format data should be returned as, e.g. if you if you don't want to rely on the built-in type checking or for some other reason.
string- get a stringbuffer- get back a Bufferarray- get an array of byte integersuint8array,u8,uint8- get back a Uint8Arrayobject, get back an array of Objects
If you don't specify an encoding, and the types can't be inferred (e.g. you write things that aren't in the list above), it will try to convert concat them into a Buffer.
If nothing is written to writable then data will be an empty array [].
error handling
concat-stream does not handle errors for you, so you must handle errors on whatever streams you pipe into concat-stream. This is a general rule when programming with node.js streams: always handle errors on each and every stream. Since concat-stream is not itself a stream it does not emit errors.
We recommend using end-of-stream or pump for writing error tolerant stream code.
license
MIT LICENSE
Upstream issues and maintenance review
Upstream origin and triage
- Original package:
concat-stream@2.0.0 - Repository: https://github.com/maxogden/concat-stream
- Source commit: https://github.com/maxogden/concat-stream/commit/ceaa101bd2e19c5878a98dd6cb875108f49bf5c5
- Source directory:
. - npm tarball: https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz
- SHA512 integrity:
sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A== - npm last-release age selects maintenance scope; it does not imply no ongoing source development.
Reviewed issues
Primary-source snapshot: 2026-09-29T00:21:59.613145+00:00. Most recently updated 100 open and 30 closed issue/PR entries; PRs removed. This is triage evidence, not a claim of exhaustive review.
Maintenance adoption with preserved runtime payload. No runtime defect correction is claimed. Reports remain visible for subsequent targeted reproduction.
- 69: Drop polyfills in a next semver major?
- 68: Stream consumers: Alternative builtin nodejs solution
- 64: How big is the difference from 1.6.* to 2.* ?
- 42: Convert to real stream
- 58: Buffer constructor runtime deprecation - this package emits a warning on Node 10
- 57: Buffer overread vulnerability
- 37: Use standard, error-first callbacks
- 41: Use end-of-stream to determine end
- 15: v2 ideas
- 31: concat-stream - buffer object in callback is empty.
- 19: New encoding auto-detection + streams2 change problem case
The structured snapshot in .stackline/issue-triage.json also records recently closed reports. Issues for unrelated packages in shared monorepositories were qualified as outside this fork’s runtime scope. No maintainer was contacted.
Release files and references
Package bytes, npm provenance and the immutable GitHub release were verified for this version. Security checks describe the reviewed release; documented compatibility risks and upstream reports are not blanket claims of resolution.
