Skip to content

Commit 9fbd7f8

Browse files
committed
stream: add deflate-raw to De/CompressionStream
1 parent 95534ad commit 9fbd7f8

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

doc/api/webstreams.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,9 @@ added: v16.6.0
14111411
<!-- YAML
14121412
added: v17.0.0
14131413
changes:
1414+
- version: REPLACEME
1415+
pr-url: https://github.com/nodejs/node/pull/50631
1416+
description: Added 'deflate-raw' format.
14141417
- version: v18.0.0
14151418
pr-url: https://github.com/nodejs/node/pull/42225
14161419
description: This class is now exposed on the global object.
@@ -1422,7 +1425,7 @@ changes:
14221425
added: v17.0.0
14231426
-->
14241427
1425-
* `format` {string} One of either `'deflate'` or `'gzip'`.
1428+
* `format` {string} One of either `'deflate'`, `'deflate-raw'` or `'gzip'`.
14261429
14271430
#### `compressionStream.readable`
14281431
@@ -1445,6 +1448,9 @@ added: v17.0.0
14451448
<!-- YAML
14461449
added: v17.0.0
14471450
changes:
1451+
- version: REPLACEME
1452+
pr-url: https://github.com/nodejs/node/pull/50631
1453+
description: Added 'deflate-raw' format.
14481454
- version: v18.0.0
14491455
pr-url: https://github.com/nodejs/node/pull/42225
14501456
description: This class is now exposed on the global object.
@@ -1456,7 +1462,7 @@ changes:
14561462
added: v17.0.0
14571463
-->
14581464
1459-
* `format` {string} One of either `'deflate'` or `'gzip'`.
1465+
* `format` {string} One of either `'deflate'`, `'deflate-raw'` or `'gzip'`.
14601466
14611467
#### `decompressionStream.readable`
14621468

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

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

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

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

0 commit comments

Comments
 (0)