11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst zlib = require('zlib'); 51cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst file = fixtures.readSync('person.jpg'); 81cb0ef41Sopenharmony_ciconst chunkSize = 16; 91cb0ef41Sopenharmony_ciconst deflater = new zlib.BrotliCompress(); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciconst chunk = file.slice(0, chunkSize); 121cb0ef41Sopenharmony_ciconst expectedFull = Buffer.from('iweA/9j/4AAQSkZJRgABAQEASA==', 'base64'); 131cb0ef41Sopenharmony_cilet actualFull; 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_cideflater.write(chunk, function() { 161cb0ef41Sopenharmony_ci deflater.flush(function() { 171cb0ef41Sopenharmony_ci const bufs = []; 181cb0ef41Sopenharmony_ci let buf; 191cb0ef41Sopenharmony_ci while ((buf = deflater.read()) !== null) 201cb0ef41Sopenharmony_ci bufs.push(buf); 211cb0ef41Sopenharmony_ci actualFull = Buffer.concat(bufs); 221cb0ef41Sopenharmony_ci }); 231cb0ef41Sopenharmony_ci}); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciprocess.once('exit', function() { 261cb0ef41Sopenharmony_ci assert.deepStrictEqual(actualFull, expectedFull); 271cb0ef41Sopenharmony_ci}); 28