mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 05:21:19 +00:00

Up to now, `Z_FINISH` was always the flushing flag that was used for the last chunk of input data. This patch makes this choice configurable so that advanced users can perform e.g. decompression of partial data using `Z_SYNC_FLUSH`, if that suits their needs. Add tests to make sure that an error is thrown upon encountering invalid `flush` or `finishFlush` flags. Fixes: https://github.com/nodejs/node/issues/5761 PR-URL: https://github.com/nodejs/node/pull/6069 Reviewed-By: James M Snell <jasnell@gmail.com>
29 lines
662 B
JavaScript
29 lines
662 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const zlib = require('zlib');
|
|
|
|
assert.doesNotThrow(() => {
|
|
zlib.createGzip({ flush: zlib.Z_SYNC_FLUSH });
|
|
});
|
|
|
|
assert.throws(() => {
|
|
zlib.createGzip({ flush: 'foobar' });
|
|
}, /Invalid flush flag: foobar/);
|
|
|
|
assert.throws(() => {
|
|
zlib.createGzip({ flush: 10000 });
|
|
}, /Invalid flush flag: 10000/);
|
|
|
|
assert.doesNotThrow(() => {
|
|
zlib.createGzip({ finishFlush: zlib.Z_SYNC_FLUSH });
|
|
});
|
|
|
|
assert.throws(() => {
|
|
zlib.createGzip({ finishFlush: 'foobar' });
|
|
}, /Invalid flush flag: foobar/);
|
|
|
|
assert.throws(() => {
|
|
zlib.createGzip({ finishFlush: 10000 });
|
|
}, /Invalid flush flag: 10000/);
|