diff --git a/ext/node/polyfills/_zlib.mjs b/ext/node/polyfills/_zlib.mjs index bb6bac1bd0bebd..61d2ecebcf2434 100644 --- a/ext/node/polyfills/_zlib.mjs +++ b/ext/node/polyfills/_zlib.mjs @@ -654,4 +654,4 @@ util.inherits(DeflateRaw, Zlib); util.inherits(InflateRaw, Zlib); util.inherits(Unzip, Zlib); -export { Deflate, DeflateRaw, Gunzip, Gzip, Inflate, InflateRaw, Unzip }; +export { Deflate, DeflateRaw, Gunzip, Gzip, Inflate, InflateRaw, Unzip, Zlib }; diff --git a/ext/node/polyfills/zlib.ts b/ext/node/polyfills/zlib.ts index d7ba8aaf546e88..278cb883cef56a 100644 --- a/ext/node/polyfills/zlib.ts +++ b/ext/node/polyfills/zlib.ts @@ -33,8 +33,10 @@ import { unzipSync, } from "ext:deno_node/_zlib.mjs"; import { + BrotliCompress, brotliCompress, brotliCompressSync, + BrotliDecompress, brotliDecompress, brotliDecompressSync, createBrotliCompress, @@ -113,21 +115,7 @@ export class BrotliOptions { notImplemented("BrotliOptions.prototype.constructor"); } } -export class BrotliCompress { - constructor() { - notImplemented("BrotliCompress.prototype.constructor"); - } -} -export class BrotliDecompress { - constructor() { - notImplemented("BrotliDecompress.prototype.constructor"); - } -} -export class ZlibBase { - constructor() { - notImplemented("ZlibBase.prototype.constructor"); - } -} + export { constants }; export default { @@ -216,12 +204,13 @@ export default { Z_SYNC_FLUSH: constants.Z_SYNC_FLUSH, Z_VERSION_ERROR: constants.Z_VERSION_ERROR, ZLIB_VERNUM: constants.ZLIB_VERNUM, - ZlibBase, }; export { + BrotliCompress, brotliCompress, brotliCompressSync, + BrotliDecompress, brotliDecompress, brotliDecompressSync, codes, diff --git a/tests/unit_node/zlib_test.ts b/tests/unit_node/zlib_test.ts index 07e5beed97ec0b..9f040bc39d0f65 100644 --- a/tests/unit_node/zlib_test.ts +++ b/tests/unit_node/zlib_test.ts @@ -3,8 +3,10 @@ import { assert, assertEquals, assertThrows } from "@std/assert"; import { fromFileUrl, relative } from "@std/path"; import { + BrotliCompress, brotliCompress, brotliCompressSync, + BrotliDecompress, brotliDecompress, brotliDecompressSync, constants, @@ -237,3 +239,28 @@ Deno.test("crc32()", () => { // @ts-expect-error: passing an object assertThrows(() => crc32({}), TypeError); }); + +Deno.test("BrotliCompress", async () => { + const deffered = Promise.withResolvers(); + // @ts-ignore: BrotliCompress is not typed + const brotliCompress = new BrotliCompress(); + // @ts-ignore: BrotliDecompress is not typed + const brotliDecompress = new BrotliDecompress(); + + brotliCompress.pipe(brotliDecompress); + + let data = ""; + brotliDecompress.on("data", (v: Buffer) => { + data += v.toString(); + }); + + brotliDecompress.on("end", () => { + deffered.resolve(); + }); + + brotliCompress.write("hello"); + brotliCompress.end(); + + await deffered.promise; + assertEquals(data, "hello"); +});