diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index 03f95b87ff0b3c..3d0ba237fe7fea 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -1420,9 +1420,13 @@ changes: -* `format` {string} One of either `'deflate'` or `'gzip'`. +* `format` {string} One of `'deflate'`, `'deflate-raw'`, or `'gzip'`. #### `compressionStream.readable` @@ -1454,9 +1458,13 @@ changes: -* `format` {string} One of either `'deflate'` or `'gzip'`. +* `format` {string} One of `'deflate'`, `'deflate-raw'`, or `'gzip'`. #### `decompressionStream.readable` diff --git a/lib/internal/webstreams/compression.js b/lib/internal/webstreams/compression.js index 6cbaa3f3250e73..d912959e29fd23 100644 --- a/lib/internal/webstreams/compression.js +++ b/lib/internal/webstreams/compression.js @@ -35,13 +35,16 @@ class CompressionStream { #transform; /** - * @param {'deflate'|'gzip'} format + * @param {'deflate'|'deflate-raw'|'gzip'} format */ constructor(format) { switch (format) { case 'deflate': this.#handle = lazyZlib().createDeflate(); break; + case 'deflate-raw': + this.#handle = lazyZlib().createDeflateRaw(); + break; case 'gzip': this.#handle = lazyZlib().createGzip(); break; @@ -80,13 +83,16 @@ class DecompressionStream { #transform; /** - * @param {'deflate'|'gzip'} format + * @param {'deflate'|'deflate-raw'|'gzip'} format */ constructor(format) { switch (format) { case 'deflate': this.#handle = lazyZlib().createInflate(); break; + case 'deflate-raw': + this.#handle = lazyZlib().createInflateRaw(); + break; case 'gzip': this.#handle = lazyZlib().createGunzip(); break; diff --git a/test/parallel/test-whatwg-webstreams-compression.js b/test/parallel/test-whatwg-webstreams-compression.js index c527fc1f13d10e..fb20801543bff6 100644 --- a/test/parallel/test-whatwg-webstreams-compression.js +++ b/test/parallel/test-whatwg-webstreams-compression.js @@ -38,7 +38,7 @@ async function test(format) { ]); } -Promise.all(['gzip', 'deflate'].map((i) => test(i))).then(common.mustCall()); +Promise.all(['gzip', 'deflate', 'deflate-raw'].map((i) => test(i))).then(common.mustCall()); [1, 'hello', false, {}].forEach((i) => { assert.throws(() => new CompressionStream(i), {