1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-21 04:52:26 -05:00

Compare commits

...

2 commits

Author SHA1 Message Date
Philipp Claßen
5300923828
Merge 09576d7ddc into e4a16e91fa 2025-01-20 07:03:49 +01:00
Philipp Claßen
09576d7ddc fix: Improve brotliDecompress.
Fixes: Uncaught (in promise) ReferenceError: callback is not defined

Test program that should then pass:

    import zlib from 'node:zlib';
    import { promisify } from 'node:util';
    import { Buffer } from 'node:buffer';
    const brotliDecompress = promisify(zlib.brotliDecompress);

    (async () => {
      const result = await brotliDecompress(Buffer.from([0x21, 0x0c, 0x00, 0x04, 0x74, 0x65, 0x73, 0x74, 0x03]));
      console.log(result.toString()); // should print "test"
    })();
2024-12-13 19:20:34 +01:00

View file

@ -204,8 +204,19 @@ export function brotliCompressSync(
return Buffer.from(TypedArrayPrototypeSubarray(output, 0, len));
}
export function brotliDecompress(input) {
export function brotliDecompress(
input,
options,
callback,
) {
const buf = toU8(input);
if (typeof options === "function") {
callback = options;
options = {};
}
// note: `options` argument is currently not used
return PromisePrototypeCatch(
PromisePrototypeThen(
op_brotli_decompress_async(buf),