@@ -243,7 +243,7 @@ BlockDecoder.prototype._writeChunk = function (chunk, encoding, cb) {
243
243
nBlocks ++ ;
244
244
this . _decompress (
245
245
block . data ,
246
- this . _createBlockCallback ( block . count , chunkCb )
246
+ this . _createBlockCallback ( block . data . length , block . count , chunkCb )
247
247
) ;
248
248
}
249
249
chunkCb ( ) ;
@@ -255,7 +255,7 @@ BlockDecoder.prototype._writeChunk = function (chunk, encoding, cb) {
255
255
}
256
256
} ;
257
257
258
- BlockDecoder . prototype . _createBlockCallback = function ( count , cb ) {
258
+ BlockDecoder . prototype . _createBlockCallback = function ( size , count , cb ) {
259
259
var self = this ;
260
260
var index = this . _index ++ ;
261
261
@@ -266,6 +266,7 @@ BlockDecoder.prototype._createBlockCallback = function (count, cb) {
266
266
self . emit ( 'error' , err ) ;
267
267
cb ( ) ;
268
268
} else {
269
+ self . emit ( 'block' , new BlockInfo ( count , data . length , size ) ) ;
269
270
self . _queue . push ( new BlockData ( index , data , cb , count ) ) ;
270
271
if ( self . _needPush ) {
271
272
self . _read ( ) ;
@@ -525,7 +526,7 @@ BlockEncoder.prototype._write = function (val, encoding, cb) {
525
526
BlockEncoder . prototype . _flushChunk = function ( pos , cb ) {
526
527
var tap = this . _tap ;
527
528
pos = pos || tap . pos ;
528
- this . _compress ( tap . buf . slice ( 0 , pos ) , this . _createBlockCallback ( cb ) ) ;
529
+ this . _compress ( tap . buf . slice ( 0 , pos ) , this . _createBlockCallback ( pos , cb ) ) ;
529
530
this . _blockCount = 0 ;
530
531
} ;
531
532
@@ -551,7 +552,7 @@ BlockEncoder.prototype._read = function () {
551
552
}
552
553
} ;
553
554
554
- BlockEncoder . prototype . _createBlockCallback = function ( cb ) {
555
+ BlockEncoder . prototype . _createBlockCallback = function ( size , cb ) {
555
556
var self = this ;
556
557
var index = this . _index ++ ;
557
558
var count = this . _blockCount ;
@@ -565,6 +566,7 @@ BlockEncoder.prototype._createBlockCallback = function (cb) {
565
566
return ;
566
567
}
567
568
self . _pending -- ;
569
+ self . emit ( 'block' , new BlockInfo ( count , size , data . length ) ) ;
568
570
self . _queue . push ( new BlockData ( index , data , cb , count ) ) ;
569
571
if ( self . _needPush ) {
570
572
self . _needPush = false ;
@@ -576,6 +578,13 @@ BlockEncoder.prototype._createBlockCallback = function (cb) {
576
578
577
579
// Helpers.
578
580
581
+ /** Summary information about a block. */
582
+ function BlockInfo ( count , raw , compressed ) {
583
+ this . valueCount = count ;
584
+ this . rawDataLength = raw ;
585
+ this . compressedDataLength = compressed ;
586
+ }
587
+
579
588
/**
580
589
* An indexed block.
581
590
*
0 commit comments