mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 04:52:26 -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:
parent
3946956b8c
commit
09576d7ddc
1 changed files with 12 additions and 1 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Reference in a new issue