mirror of
https://github.com/denoland/deno.git
synced 2025-02-07 23:06:50 -05:00
fix(ext/node): fix async variant of brotliDecompress (#27815)
Fixes https://github.com/denoland/deno/issues/27729
This commit is contained in:
parent
802b9d6309
commit
a2d0872225
2 changed files with 12 additions and 3 deletions
|
@ -181,7 +181,6 @@ export function brotliCompress(
|
|||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
const { quality, lgwin, mode } = oneOffCompressOptions(options);
|
||||
PromisePrototypeCatch(
|
||||
PromisePrototypeThen(
|
||||
|
@ -204,8 +203,13 @@ 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 = {};
|
||||
}
|
||||
return PromisePrototypeCatch(
|
||||
PromisePrototypeThen(
|
||||
op_brotli_decompress_async(buf),
|
||||
|
|
|
@ -5,6 +5,7 @@ import { fromFileUrl, relative } from "@std/path";
|
|||
import {
|
||||
brotliCompress,
|
||||
brotliCompressSync,
|
||||
brotliDecompress,
|
||||
brotliDecompressSync,
|
||||
constants,
|
||||
crc32,
|
||||
|
@ -35,7 +36,11 @@ Deno.test("brotli compression async", async () => {
|
|||
})
|
||||
);
|
||||
assertEquals(compressed instanceof Buffer, true);
|
||||
const decompressed = brotliDecompressSync(compressed);
|
||||
const decompressed: Buffer = await new Promise((resolve) =>
|
||||
brotliDecompress(compressed, (_, res) => {
|
||||
return resolve(res);
|
||||
})
|
||||
);
|
||||
assertEquals(decompressed.toString(), "hello world");
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue