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
PR-URL: https://github.com/nodejs/node/pull/50097
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
Damian Krzeminski
2023-11-09 12:18:57 +01:00
committed by GitHub
parent bb2dd0e90c
commit 3e14cfbbcf
3 changed files with 19 additions and 5 deletions

View File

@@ -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;