diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index c53f0b880249a1..ec55e35ce16774 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -1416,9 +1416,13 @@ changes: -* `format` {string} One of either `'deflate'` or `'gzip'`. +* `format` {string} One of `'deflate'`, `'deflate-raw'`, or `'gzip'`. #### `compressionStream.readable` @@ -1450,9 +1454,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 cda3c4b08f3b5b..28b6dc8f7a41bf 100644 --- a/lib/internal/webstreams/compression.js +++ b/lib/internal/webstreams/compression.js @@ -51,7 +51,7 @@ function isDecompressionStream(value) { class CompressionStream { /** - * @param {'deflate'|'gzip'} format + * @param {'deflate'|'deflate-raw'|'gzip'} format */ constructor(format) { this[kType] = 'CompressionStream'; @@ -59,6 +59,9 @@ class CompressionStream { case 'deflate': this[kHandle] = lazyZlib().createDeflate(); break; + case 'deflate-raw': + this[kHandle] = lazyZlib().createDeflateRaw(); + break; case 'gzip': this[kHandle] = lazyZlib().createGzip(); break; @@ -100,7 +103,7 @@ class CompressionStream { class DecompressionStream { /** - * @param {'deflate'|'gzip'} format + * @param {'deflate'|'deflate-raw'|'gzip'} format */ constructor(format) { this[kType] = 'DecompressionStream'; @@ -108,6 +111,9 @@ class DecompressionStream { case 'deflate': this[kHandle] = lazyZlib().createInflate(); break; + case 'deflate-raw': + this[kHandle] = lazyZlib().createInflateRaw(); + break; case 'gzip': this[kHandle] = lazyZlib().createGunzip(); break; diff --git a/test/parallel/test-whatwg-webstreams-compression.js b/test/parallel/test-whatwg-webstreams-compression.js index f9ae8d87265b58..1d0882c4d1a681 100644 --- a/test/parallel/test-whatwg-webstreams-compression.js +++ b/test/parallel/test-whatwg-webstreams-compression.js @@ -41,7 +41,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), {