11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst zlib = require('zlib'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst data = Buffer.concat([ 71cb0ef41Sopenharmony_ci zlib.gzipSync('abc'), 81cb0ef41Sopenharmony_ci zlib.gzipSync('def'), 91cb0ef41Sopenharmony_ci]); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst resultBuffers = []; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst unzip = zlib.createUnzip() 141cb0ef41Sopenharmony_ci .on('error', (err) => { 151cb0ef41Sopenharmony_ci assert.ifError(err); 161cb0ef41Sopenharmony_ci }) 171cb0ef41Sopenharmony_ci .on('data', (data) => resultBuffers.push(data)) 181cb0ef41Sopenharmony_ci .on('finish', common.mustCall(() => { 191cb0ef41Sopenharmony_ci const unzipped = Buffer.concat(resultBuffers).toString(); 201cb0ef41Sopenharmony_ci assert.strictEqual(unzipped, 'abcdef', 211cb0ef41Sopenharmony_ci `'${unzipped}' should match 'abcdef' after zipping ` + 221cb0ef41Sopenharmony_ci 'and unzipping'); 231cb0ef41Sopenharmony_ci })); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_cifor (let i = 0; i < data.length; i++) { 261cb0ef41Sopenharmony_ci // Write each single byte individually. 271cb0ef41Sopenharmony_ci unzip.write(Buffer.from([data[i]])); 281cb0ef41Sopenharmony_ci} 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ciunzip.end(); 31