stream-chunker
Advanced tools
Comparing version 1.1.8 to 1.2.7
@@ -48,2 +48,9 @@ /** | ||
flushFunction = function (next) { | ||
if (opts.align) { | ||
var remaining = new Buffer(chunkSize - buffer.length); | ||
remaining.fill(0); | ||
buffer = Buffer.concat([ buffer, remaining ], chunkSize); | ||
} | ||
this.push(buffer); | ||
@@ -50,0 +57,0 @@ next(); |
{ | ||
"name": "stream-chunker", | ||
"version": "1.1.8", | ||
"version": "1.2.7", | ||
"description": "A transform stream which chunks incoming data into chunkSize byte chunks", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,2 +23,3 @@ # stream-chunker | ||
- `flush`: `boolean` - Optional. Flush incomplete chunk data on stream end. Default is `false`. | ||
- `align`: `boolean` - Optional. Pad incomplete chunk data on stream end. Should be used in combination with `flush`. Default is `false`. | ||
- `encoding`: `string` - Optional. Encoding of String chunks. Must be a valid Buffer encoding, such as `utf8` or `ascii`. | ||
@@ -25,0 +26,0 @@ |
@@ -41,2 +41,24 @@ var Chunker = require('../index.js'); | ||
}); | ||
}); | ||
test('Test align option', function (t) { | ||
t.plan(1); | ||
var optsFlushAlign = { | ||
flush: true, | ||
align: true, | ||
encoding: 'utf8' | ||
} | ||
function checkFlushAlign(data) { | ||
t.equals(data, '12345\0\0\0', 'Received flush data'); | ||
} | ||
var chunkerFlushAlign = Chunker(4, optsFlushAlign); | ||
var concatStreamFlushAlign = concat(checkFlushAlign); | ||
chunkerFlushAlign.pipe(concatStreamFlushAlign); | ||
chunkerFlushAlign.write('12'); | ||
chunkerFlushAlign.write('34'); | ||
chunkerFlushAlign.write('5'); | ||
chunkerFlushAlign.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10032
156
66