-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zlib: Add support for info: true option #2691
Conversation
881252b
to
6f7deda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're diverging from node.js zlib implementation and it is producing different states for info: true
.
For example, on Node.js
> require('zlib').brotliCompressSync('aaa', { info: true })
{
buffer: <Buffer 0b 01 80 61 61 61 03>,
engine: BrotliCompress {
_writeState: Uint32Array(2) [ 16377, 0 ],
but calling initializing BrotliCompress directly produces different results on writeState
> require('zlib').BrotliCompress({ info: true })
<ref *1> BrotliCompress {
_writeState: Uint32Array(2) [ 0, 0 ],
6f7deda
to
d2dfc0c
Compare
d2dfc0c
to
ab30798
Compare
src/node/internal/zlib.d.ts
Outdated
@@ -250,3 +248,13 @@ export class BrotliEncoder extends CompressionStream { | |||
): boolean; | |||
public params(): void; | |||
} | |||
|
|||
export const enum ZlibMode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum values are not 1 to 1 representably js. We should avoid using them. Can we convert this to an object and move this to the file where it is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this enum to internal_zlib.ts, but I was not sure how to replace it with an object, because keyof typeof CLASS_BY_MODE
would just be number
.
ab30798
to
b17aa29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait for @jasnell to review, before landing.
This PR implements the
{info: true}
option for zlib. It's not documented for brotli, but the unit tests expect it there too. We return an engine, and the buffer.However, the engine we're returning isn't really legit - we just create it on the fly to return it. Should we fall back to the streaming path whenNow going whole-hog and falling back to the streaming implementation wheninfo: true
, for more fidelity with NodeJS or is this close enough?info: true