Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cf06e74

Browse filesBrowse files
KhafraDevrichardlau
authored andcommitted
stream: add brotli support to CompressionStream and DecompressionStream
Refs: whatwg/compression#34 PR-URL: #59464 Reviewed-By: Mattias Buelens <mattias@buelens.com> Reviewed-By: Jason Zhang <xzha4350@gmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
1 parent d22f113 commit cf06e74
Copy full SHA for cf06e74

File tree

Expand file treeCollapse file tree

4 files changed

+24
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+24
-5
lines changed
Open diff view settings
Collapse file

‎doc/api/globals.md‎

Copy file name to clipboardExpand all lines: doc/api/globals.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,9 @@ added: v0.0.1
319319
<!-- YAML
320320
added: v18.0.0
321321
changes:
322+
- version: REPLACEME
323+
pr-url: https://github.com/nodejs/node/pull/59464
324+
description: format now accepts `brotli` value.
322325
- version: v22.15.0
323326
pr-url: https://github.com/nodejs/node/pull/57510
324327
description: Marking the API stable.
@@ -427,6 +430,9 @@ A browser-compatible implementation of {CustomEvent}.
427430
<!-- YAML
428431
added: v18.0.0
429432
changes:
433+
- version: REPLACEME
434+
pr-url: https://github.com/nodejs/node/pull/59464
435+
description: format now accepts `brotli` value.
430436
- version: v22.15.0
431437
pr-url: https://github.com/nodejs/node/pull/57510
432438
description: Marking the API stable.
Collapse file

‎doc/api/webstreams.md‎

Copy file name to clipboardExpand all lines: doc/api/webstreams.md
+8-2Lines changed: 8 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1478,14 +1478,17 @@ changes:
14781478
<!-- YAML
14791479
added: v17.0.0
14801480
changes:
1481+
- version: REPLACEME
1482+
pr-url: https://github.com/nodejs/node/pull/59464
1483+
description: format now accepts `brotli` value.
14811484
- version:
14821485
- v21.2.0
14831486
- v20.12.0
14841487
pr-url: https://github.com/nodejs/node/pull/50097
14851488
description: format now accepts `deflate-raw` value.
14861489
-->
14871490
1488-
* `format` {string} One of `'deflate'`, `'deflate-raw'`, or `'gzip'`.
1491+
* `format` {string} One of `'deflate'`, `'deflate-raw'`, `'gzip'`, or `'brotli'`.
14891492
14901493
#### `compressionStream.readable`
14911494
@@ -1518,14 +1521,17 @@ changes:
15181521
<!-- YAML
15191522
added: v17.0.0
15201523
changes:
1524+
- version: REPLACEME
1525+
pr-url: https://github.com/nodejs/node/pull/59464
1526+
description: format now accepts `brotli` value.
15211527
- version:
15221528
- v21.2.0
15231529
- v20.12.0
15241530
pr-url: https://github.com/nodejs/node/pull/50097
15251531
description: format now accepts `deflate-raw` value.
15261532
-->
15271533
1528-
* `format` {string} One of `'deflate'`, `'deflate-raw'`, or `'gzip'`.
1534+
* `format` {string} One of `'deflate'`, `'deflate-raw'`, `'gzip'`, or `'brotli'`.
15291535
15301536
#### `decompressionStream.readable`
15311537
Collapse file

‎lib/internal/webstreams/compression.js‎

Copy file name to clipboardExpand all lines: lib/internal/webstreams/compression.js
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const formatConverter = createEnumConverter('CompressionFormat', [
2828
'deflate',
2929
'deflate-raw',
3030
'gzip',
31+
'brotli',
3132
]);
3233

3334
/**
@@ -40,7 +41,7 @@ class CompressionStream {
4041
#transform;
4142

4243
/**
43-
* @param {'deflate'|'deflate-raw'|'gzip'} format
44+
* @param {'deflate'|'deflate-raw'|'gzip'|'brotli'} format
4445
*/
4546
constructor(format) {
4647
format = formatConverter(format, {
@@ -57,6 +58,9 @@ class CompressionStream {
5758
case 'gzip':
5859
this.#handle = lazyZlib().createGzip();
5960
break;
61+
case 'brotli':
62+
this.#handle = lazyZlib().createBrotliCompress();
63+
break;
6064
}
6165
this.#transform = newReadableWritablePairFromDuplex(this.#handle);
6266
}
@@ -90,7 +94,7 @@ class DecompressionStream {
9094
#transform;
9195

9296
/**
93-
* @param {'deflate'|'deflate-raw'|'gzip'} format
97+
* @param {'deflate'|'deflate-raw'|'gzip'|'brotli'} format
9498
*/
9599
constructor(format) {
96100
format = formatConverter(format, {
@@ -111,6 +115,9 @@ class DecompressionStream {
111115
rejectGarbageAfterEnd: true,
112116
});
113117
break;
118+
case 'brotli':
119+
this.#handle = lazyZlib().createBrotliDecompress();
120+
break;
114121
}
115122
this.#transform = newReadableWritablePairFromDuplex(this.#handle);
116123

Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-whatwg-webstreams-compression.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function test(format) {
4141
]);
4242
}
4343

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

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.