• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2require('../common');
3const assert = require('assert');
4const zlib = require('zlib');
5const fixtures = require('../common/fixtures');
6
7const file = fixtures.readSync('person.jpg');
8const chunkSize = 16;
9const deflater = new zlib.BrotliCompress();
10
11const chunk = file.slice(0, chunkSize);
12const expectedFull = Buffer.from('iweA/9j/4AAQSkZJRgABAQEASA==', 'base64');
13let actualFull;
14
15deflater.write(chunk, function() {
16  deflater.flush(function() {
17    const bufs = [];
18    let buf;
19    while (buf = deflater.read())
20      bufs.push(buf);
21    actualFull = Buffer.concat(bufs);
22  });
23});
24
25process.once('exit', function() {
26  assert.deepStrictEqual(actualFull, expectedFull);
27});
28