1'use strict'; 2const common = require('../common'); 3const assert = require('assert'); 4const zlib = require('zlib'); 5 6const data = Buffer.concat([ 7 zlib.gzipSync('abc'), 8 zlib.gzipSync('def'), 9]); 10 11const resultBuffers = []; 12 13const unzip = zlib.createUnzip() 14 .on('error', (err) => { 15 assert.ifError(err); 16 }) 17 .on('data', (data) => resultBuffers.push(data)) 18 .on('finish', common.mustCall(() => { 19 assert.deepStrictEqual(Buffer.concat(resultBuffers).toString(), 'abcdef', 20 `'${Buffer.concat(resultBuffers).toString()}' ` + 21 'should match \'abcdef\' after ' + 22 'zipping and unzipping'); 23 })); 24 25for (let i = 0; i < data.length; i++) { 26 // Write each single byte individually. 27 unzip.write(Buffer.from([data[i]])); 28} 29 30unzip.end(); 31