Comparing version 0.3.5 to 0.3.6
@@ -43,3 +43,3 @@ 'use strict'; | ||
buffer: function (arrData) { return Buffer.concat(arrData.map(ensureBuffer)); }, | ||
string: function (arrData, encoding) { return arrData.map(ensureString.bind(null, encoding)).join(''); }, | ||
string: function (arrData, encoding) { return Buffer.concat(arrData.map(ensureBuffer)).toString(encoding); }, | ||
array: function (arrData) { return arrData; } | ||
@@ -46,0 +46,0 @@ }; |
{ | ||
"name": "accum", | ||
"description": "accum - Simple write stream which accumulates or collects the data from a stream. Pipe your stream into this to get all the data as buffer, string, or raw array. (streams2)", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"author": "Jeff Barczewski <jeff.barczewski@gmail.com>", | ||
"repository": { "type": "git", "url": "http://github.com/jeffbski/accum.git" }, | ||
"bugs" : { "url": "http://github.com/jeffbski/accum/issues" }, | ||
"licenses": [{ "type": "MIT", "url" : "http://github.com/jeffbski/accum/raw/master/LICENSE" }], | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/jeffbski/accum.git" | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/jeffbski/accum/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://github.com/jeffbski/accum/raw/master/LICENSE" | ||
} | ||
], | ||
"main": "lib/accum", | ||
"engines": { "node": ">=0.8" }, | ||
"engines": { | ||
"node": ">=0.8" | ||
}, | ||
"dependencies": { | ||
@@ -12,0 +24,0 @@ "readable-stream": "https://github.com/jeffbski/readable-stream/archive/v1.0.2-object-transform2-ret-self.tar.gz" |
@@ -65,2 +65,24 @@ /*global suite:false test:false */ | ||
test('accum.string("utf8", listenerFn) with Buffer data having multibyte utf8 split into separate packets, Buffer.concat before convert', function (done) { | ||
// http://en.wikipedia.org/wiki/UTF-8 \u20ac is € euro sign | ||
var DATA = '\u20ac'; // multibyte | ||
var stream = passStream(); | ||
stream | ||
.pipe(accum.string({ encoding: 'utf8' }, function (alldata) { | ||
t.typeOf(alldata, 'string'); | ||
t.equal(alldata.length, DATA.length); | ||
t.equal(alldata, DATA); | ||
done(); | ||
})); | ||
process.nextTick(function () { | ||
var fullBuffer = new Buffer('\u20ac', 'utf8'); | ||
t.ok(fullBuffer.length > 1); | ||
// make buffer packets split the multibyte string | ||
var firstPacket = fullBuffer.slice(0, 1); | ||
var secondPacket = fullBuffer.slice(1); | ||
stream.write(firstPacket); | ||
stream.end(secondPacket); | ||
}); | ||
}); | ||
test('accum.string(listenerFn) with throws to domain', function (done) { | ||
@@ -67,0 +89,0 @@ var d = domain.create(); |
22647
443