mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
d77754bfc7
PR-URL: https://github.com/nodejs/node/pull/41614 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
28 lines
700 B
JavaScript
28 lines
700 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const zlib = require('zlib');
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const file = fixtures.readSync('person.jpg');
|
|
const chunkSize = 16;
|
|
const deflater = new zlib.BrotliCompress();
|
|
|
|
const chunk = file.slice(0, chunkSize);
|
|
const expectedFull = Buffer.from('iweA/9j/4AAQSkZJRgABAQEASA==', 'base64');
|
|
let actualFull;
|
|
|
|
deflater.write(chunk, function() {
|
|
deflater.flush(function() {
|
|
const bufs = [];
|
|
let buf;
|
|
while ((buf = deflater.read()) !== null)
|
|
bufs.push(buf);
|
|
actualFull = Buffer.concat(bufs);
|
|
});
|
|
});
|
|
|
|
process.once('exit', function() {
|
|
assert.deepStrictEqual(actualFull, expectedFull);
|
|
});
|