-
Notifications
You must be signed in to change notification settings - Fork 358
zlib one-shot methods #2533
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 one-shot methods #2533
Conversation
npaun
commented
Aug 14, 2024
•
edited
Loading
edited
- Reuses ZlibContext from @anonrig's implementation of the stream-based API.
- Sends the entire input buffer at once, and uses only the finishFlush flag, like Node's does.
- Uses GrowableBuffer to collect the output as it's generated. This is basically kj::Vector, but it can be limited to a maximum size and adds some methods to make usage as a buffer more ergonomic.
5b51813
to
84338b1
Compare
62e82ed
to
bd9fee7
Compare
bd9fee7
to
9b128cd
Compare
781b791
to
e3a9696
Compare
@jasnell Do we want to respect |
e3a9696
to
cb724a4
Compare
@@ -41,19 +285,6 @@ Object.defineProperties( | |||
) | |||
); | |||
|
|||
export function crc32( |
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 think we should move this function change to a different pull-request.
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.
Normally I'm in favour of splitting PRs into small chunks, however, this time I think the changes are OK to go together, because I'm reusing the input source stuff between zlibsync and crc32sync
src/node/internal/internal_zlib.ts
Outdated
import { Zlib } from 'node-internal:internal_zlib_base'; | ||
|
||
type CompressCallback = (error: Error | null, result: Buffer | null) => void; |
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.
This type is wrong. Technically this supports (null, null), but it is not possible.
type CompressCallback = (error: Error | null, result: Buffer | null) => void; | |
type CompressCallback = ((error: Error, result: null) => void) | ((null, result: Buffer) => void) |
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.
Thanks, that's much better.
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.
Hmm, I'm not sure the new type is right either. To me it says "a function that handles errors" OR "a function that handles results". You can't pass in a function that handles both with that type. FWIW, DefinitelyTyped uses a type like the one I had originally.
cb724a4
to
96f41bb
Compare
Addressed the latest round of suggestions; thanks everyone. Please have another look. |
96f41bb
to
c340054
Compare
@npaun just fyi: merged commit has |