Skip to content

Commit 80e9be3

Browse files
committed
stream: add support for deflate-raw format to webstreams compression
this change makes `deflate-raw` a valid parameter for both CompressionStream and DecompressionStream constructors it makes node's implementation consistent with what modern browsers support and what specification calls for see: https://wicg.github.io/compression/#compression-stream
1 parent 387e292 commit 80e9be3

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

doc/api/webstreams.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ changes:
14221422
added: v17.0.0
14231423
-->
14241424
1425-
* `format` {string} One of either `'deflate'` or `'gzip'`.
1425+
* `format` {string} One of `'deflate'`, `'deflate-raw'`, or `'gzip'`.
14261426
14271427
#### `compressionStream.readable`
14281428
@@ -1456,7 +1456,7 @@ changes:
14561456
added: v17.0.0
14571457
-->
14581458
1459-
* `format` {string} One of either `'deflate'` or `'gzip'`.
1459+
* `format` {string} One of `'deflate'`, `'deflate-raw'`, or `'gzip'`.
14601460
14611461
#### `decompressionStream.readable`
14621462

lib/internal/webstreams/compression.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ class CompressionStream {
3535
#transform;
3636

3737
/**
38-
* @param {'deflate'|'gzip'} format
38+
* @param {'deflate'|'deflate-raw'|'gzip'} format
3939
*/
4040
constructor(format) {
4141
switch (format) {
4242
case 'deflate':
4343
this.#handle = lazyZlib().createDeflate();
4444
break;
45+
case 'deflate-raw':
46+
this.#handle = lazyZlib().createDeflateRaw();
47+
break;
4548
case 'gzip':
4649
this.#handle = lazyZlib().createGzip();
4750
break;
@@ -80,13 +83,16 @@ class DecompressionStream {
8083
#transform;
8184

8285
/**
83-
* @param {'deflate'|'gzip'} format
86+
* @param {'deflate'|'deflate-raw'|'gzip'} format
8487
*/
8588
constructor(format) {
8689
switch (format) {
8790
case 'deflate':
8891
this.#handle = lazyZlib().createInflate();
8992
break;
93+
case 'deflate-raw':
94+
this.#handle = lazyZlib().createInflateRaw();
95+
break;
9096
case 'gzip':
9197
this.#handle = lazyZlib().createGunzip();
9298
break;

test/parallel/test-whatwg-webstreams-compression.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async function test(format) {
3838
]);
3939
}
4040

41-
Promise.all(['gzip', 'deflate'].map((i) => test(i))).then(common.mustCall());
41+
Promise.all(['gzip', 'deflate', 'deflate-raw'].map((i) => test(i))).then(common.mustCall());
4242

4343
[1, 'hello', false, {}].forEach((i) => {
4444
assert.throws(() => new CompressionStream(i), {

0 commit comments

Comments
 (0)