-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zlib: Make the finish flush flag configurable
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: #5761 PR-URL: #6069 Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
4 changed files
with
91 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'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/); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters