concat-stream
Writable stream that concatenates strings or binary data and calls a callback with the result. Not a transform stream -- more of a stream sink.
examples
var concat = require('concat-stream')
var fs = require('fs')
var read = fs.createReadStream('readme.md')
var write = concat(function(data) {})
read.pipe(write)
works with arrays too!
var write = concat({ encoding: 'array' }, function(data) {})
write.write([1,2,3])
write.write([4,5,6])
write.end()
works with buffers too! can't believe the deals!
var write = concat(function(data) {})
write.write(new Buffer('hello '))
write.write(new Buffer('world'))
write.end()
or if you want a Uint8Array, you can have those too!
var write = concat({ encoding: 'u8' }, function(data) {})
var a = new Uint8Array(3)
a[0] = 97; a[1] = 98; a[2] = 99
write.write(a)
write.write('!')
write.end(Buffer('!!1'))
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.
Use opts.encoding
to control what format data
should be:
- string - get a string
- buffer - get back a Buffer (this is the default encoding)
- array - get an array of byte integers
- uint8array, u8, uint8 - get back a Uint8Array
license
MIT LICENSE