concat-stream
Advanced tools
Comparing version 0.0.4 to 0.0.5
var stream = require('stream') | ||
var util = require('util') | ||
var bufferjoiner = require('bufferjoiner') | ||
@@ -29,3 +30,9 @@ function ConcatStream(cb) { | ||
} | ||
if (this.body.length === 1) return this.body[0] | ||
if (typeof(Buffer) !== "undefined" && Buffer.isBuffer(this.body[0])) { | ||
var buffs = new BufferJoiner() | ||
this.body.forEach(function(buf) { | ||
buffs.add(buf) | ||
}) | ||
return buffs.join() | ||
} | ||
return this.body | ||
@@ -32,0 +39,0 @@ } |
{ "name" : "concat-stream" | ||
, "description" : "writable stream that concatenates strings or data and calls a callback with the result" | ||
, "tags" : ["stream", "simple", "util", "utility"] | ||
, "version" : "0.0.4" | ||
, "version" : "0.0.5" | ||
, "author" : "Max Ogden <max@maxogden.com>" | ||
@@ -13,2 +13,5 @@ , "repository" : | ||
, "engines" : ["node >= 0.4.0"] | ||
, "dependencies": { | ||
"bufferjoiner": "0.1.3" | ||
} | ||
} |
@@ -22,3 +22,11 @@ # concat-stream | ||
// data will be [1,2,3,4,5,6] in the above callback | ||
works with buffers too! can't believe the deals! | ||
var write = concat(function(err, data) {}) | ||
write.write(new Buffer('hello ')) | ||
write.write(new Buffer('world')) | ||
write.end() | ||
// data will be a buffer that toString()s to 'hello world' in the above callback | ||
MIT LICENSE |
2559
49
32
1
+ Addedbufferjoiner@0.1.3
+ Addedbufferjoiner@0.1.3(transitive)