1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-20 20:42:19 -05:00

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"
    })();
This commit is contained in:
Philipp Claßen 2024-12-13 18:57:49 +01:00
parent 3946956b8c
commit 09576d7ddc

View file

@ -193,8 +193,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),