Skip to content

Commit 6d344f7

Browse files
authored
Introduce "deflate-raw" algorithm (#43)
Add the "deflate-raw" algorithm for DEFLATE with no header or footer.
1 parent 805fc62 commit 6d344f7

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

index.bs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ urlPrefix: http://www.ecma-international.org/ecma-262/6.0/index.html; spec: ECMA
3232

3333
*This section is non-normative.*
3434

35-
The APIs specified in this specification are used to compress and decompress streams of data. They support "deflate" and "gzip" as compression algorithms. They are widely used by web developers.
35+
The APIs specified in this specification are used to compress and decompress streams of data. They support "deflate", "deflate-raw" and "gzip" as compression algorithms. They are widely used by web developers.
3636

3737
# Conformance # {#conformance}
3838

@@ -79,6 +79,12 @@ A <dfn>compression context</dfn> is the internal state maintained by a compressi
7979
* It is an error for DecompressionStream if the `ADLER32` checksum is not correct.
8080
* It is an error if there is additional input data after the `ADLER32` checksum.
8181

82+
: `deflate-raw`
83+
:: "The DEFLATE algorithm" [[!RFC1951]]
84+
85+
* Implementations must be "compliant" as described in [[!RFC1951]] section 1.4.
86+
* Non-[[!RFC1951]]-conforming blocks must not be created by CompressionStream, and are errors for DecompressionStream.
87+
8288
: `gzip`
8389
:: "GZIP file format" [[!RFC1952]]
8490

index.html

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
<title>Compression Streams</title>
55
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
66
<link href="https://www.w3.org/StyleSheets/TR/2021/cg-draft" rel="stylesheet">
7-
<meta content="Bikeshed version 15125077e, updated Fri Jan 14 14:49:38 2022 -0800" name="generator">
7+
<meta content="Bikeshed version fb1e763a4, updated Tue Mar 1 13:13:50 2022 -0800" name="generator">
88
<link href="https://wicg.github.io/compression/" rel="canonical">
9-
<meta content="03341243b006ef0244f4c687b60eccdb37329e5c" name="document-revision">
109
<style>/* style-autolinks */
1110

1211
.css.css, .property.property, .descriptor.descriptor {
@@ -633,7 +632,7 @@
633632
<div class="head">
634633
<p data-fill-with="logo"><a class="logo" href="https://www.w3.org/"> <img alt="W3C" height="48" src="https://www.w3.org/StyleSheets/TR/2021/logos/W3C" width="72"> </a> </p>
635634
<h1 class="p-name no-ref" id="title">Compression Streams</h1>
636-
<p id="w3c-state"><a href="https://www.w3.org/standards/types#CG-DRAFT">Draft Community Group Report</a>, <time class="dt-updated" datetime="2022-01-18">18 January 2022</time></p>
635+
<p id="w3c-state"><a href="https://www.w3.org/standards/types#CG-DRAFT">Draft Community Group Report</a>, <time class="dt-updated" datetime="2022-03-28">28 March 2022</time></p>
637636
<div data-fill-with="spec-metadata">
638637
<dl>
639638
<dt>This version:
@@ -704,7 +703,7 @@ <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
704703
<main>
705704
<h2 class="heading settled" data-level="1" id="introduction"><span class="secno">1. </span><span class="content">Introduction</span><a class="self-link" href="#introduction"></a></h2>
706705
<p><em>This section is non-normative.</em></p>
707-
<p>The APIs specified in this specification are used to compress and decompress streams of data. They support "deflate" and "gzip" as compression algorithms. They are widely used by web developers.</p>
706+
<p>The APIs specified in this specification are used to compress and decompress streams of data. They support "deflate", "deflate-raw" and "gzip" as compression algorithms. They are widely used by web developers.</p>
708707
<h2 class="heading settled" data-level="2" id="conformance"><span class="secno">2. </span><span class="content">Conformance</span><a class="self-link" href="#conformance"></a></h2>
709708
<p>As well as sections marked as non-normative, all authoring guidelines,
710709
diagrams, examples, and notes in this specification are non-normative.
@@ -746,6 +745,15 @@ <h2 class="heading settled" data-level="4" id="supported-formats"><span class="s
746745
<li data-md>
747746
<p>It is an error if there is additional input data after the <code>ADLER32</code> checksum.</p>
748747
</ul>
748+
<dt data-md><code>deflate-raw</code>
749+
<dd data-md>
750+
<p>"The DEFLATE algorithm" <a data-link-type="biblio" href="#biblio-rfc1951">[RFC1951]</a></p>
751+
<ul>
752+
<li data-md>
753+
<p>Implementations must be "compliant" as described in <a data-link-type="biblio" href="#biblio-rfc1951">[RFC1951]</a> section 1.4.</p>
754+
<li data-md>
755+
<p>Non-<a data-link-type="biblio" href="#biblio-rfc1951">[RFC1951]</a>-conforming blocks must not be created by CompressionStream, and are errors for DecompressionStream.</p>
756+
</ul>
749757
<dt data-md><code>gzip</code>
750758
<dd data-md>
751759
<p>"GZIP file format" <a data-link-type="biblio" href="#biblio-rfc1952">[RFC1952]</a></p>
@@ -942,11 +950,11 @@ <h2 class="heading settled" data-level="7" id="privacy-security"><span class="se
942950
<h2 class="heading settled" data-level="8" id="examples"><span class="secno">8. </span><span class="content">Examples</span><a class="self-link" href="#examples"></a></h2>
943951
<h3 class="heading settled" data-level="8.1" id="example-gzip-compress-stream"><span class="secno">8.1. </span><span class="content">Gzip-compress a stream</span><a class="self-link" href="#example-gzip-compress-stream"></a></h3>
944952
<pre class="example highlight" id="example-470647ba"><a class="self-link" href="#example-470647ba"></a><c- a>const</c-> compressedReadableStream
945-
<c- o>=</c-> inputReadableStream<c- p>.</c->pipeThrough<c- p>(</c-><c- k>new</c-> CompressionStream<c- p>(</c-><c- t>'gzip'</c-><c- p>));</c->
953+
<c- o>=</c-> inputReadableStream<c- p>.</c->pipeThrough<c- p>(</c-><c- ow>new</c-> CompressionStream<c- p>(</c-><c- t>'gzip'</c-><c- p>));</c->
946954
</pre>
947955
<h3 class="heading settled" data-level="8.2" id="example-deflate-compress"><span class="secno">8.2. </span><span class="content">Deflate-compress an ArrayBuffer to a Uint8Array</span><a class="self-link" href="#example-deflate-compress"></a></h3>
948956
<pre class="example highlight" id="example-09e4ae49"><a class="self-link" href="#example-09e4ae49"></a><c- k>async</c-> <c- a>function</c-> compressArrayBuffer<c- p>(</c->input<c- p>)</c-> <c- p>{</c->
949-
<c- a>const</c-> cs <c- o>=</c-> <c- k>new</c-> CompressionStream<c- p>(</c-><c- t>'deflate'</c-><c- p>);</c->
957+
<c- a>const</c-> cs <c- o>=</c-> <c- ow>new</c-> CompressionStream<c- p>(</c-><c- t>'deflate'</c-><c- p>);</c->
950958
<c- a>const</c-> writer <c- o>=</c-> cs<c- p>.</c->writable<c- p>.</c->getWriter<c- p>();</c->
951959
writer<c- p>.</c->write<c- p>(</c->input<c- p>);</c->
952960
writer<c- p>.</c->close<c- p>();</c->
@@ -960,7 +968,7 @@ <h3 class="heading settled" data-level="8.2" id="example-deflate-compress"><span
960968
output<c- p>.</c->push<c- p>(</c->value<c- p>);</c->
961969
totalSize <c- o>+=</c-> value<c- p>.</c->byteLength<c- p>;</c->
962970
<c- p>}</c->
963-
<c- a>const</c-> concatenated <c- o>=</c-> <c- k>new</c-> Uint8Array<c- p>(</c->totalSize<c- p>);</c->
971+
<c- a>const</c-> concatenated <c- o>=</c-> <c- ow>new</c-> Uint8Array<c- p>(</c->totalSize<c- p>);</c->
964972
<c- a>let</c-> offset <c- o>=</c-> <c- mf>0</c-><c- p>;</c->
965973
<c- k>for</c-> <c- p>(</c-><c- a>const</c-> array <c- k>of</c-> output<c- p>)</c-> <c- p>{</c->
966974
concatenated<c- p>.</c->set<c- p>(</c->array<c- p>,</c-> offset<c- p>);</c->
@@ -971,9 +979,9 @@ <h3 class="heading settled" data-level="8.2" id="example-deflate-compress"><span
971979
</pre>
972980
<h3 class="heading settled" data-level="8.3" id="example-gzip-decompress"><span class="secno">8.3. </span><span class="content">Gzip-decompress a Blob to Blob</span><a class="self-link" href="#example-gzip-decompress"></a></h3>
973981
<pre class="example highlight" id="example-4d353c2c"><a class="self-link" href="#example-4d353c2c"></a><c- a>function</c-> decompressBlob<c- p>(</c->blob<c- p>)</c-> <c- p>{</c->
974-
<c- a>const</c-> ds <c- o>=</c-> <c- k>new</c-> DecompressionStream<c- p>(</c-><c- t>'gzip'</c-><c- p>);</c->
982+
<c- a>const</c-> ds <c- o>=</c-> <c- ow>new</c-> DecompressionStream<c- p>(</c-><c- t>'gzip'</c-><c- p>);</c->
975983
<c- a>const</c-> decompressionStream <c- o>=</c-> blob<c- p>.</c->stream<c- p>().</c->pipeThrough<c- p>(</c->ds<c- p>);</c->
976-
<c- k>return</c-> <c- k>new</c-> Response<c- p>(</c->decompressedStream<c- p>).</c->blob<c- p>();</c->
984+
<c- k>return</c-> <c- ow>new</c-> Response<c- p>(</c->decompressedStream<c- p>).</c->blob<c- p>();</c->
977985
<c- p>}</c->
978986
</pre>
979987
<h2 class="heading settled" data-level="9" id="acknowledgments"><span class="secno">9. </span><span class="content">Acknowledgments</span><a class="self-link" href="#acknowledgments"></a></h2>
@@ -1148,6 +1156,8 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N
11481156
<dl>
11491157
<dt id="biblio-rfc1950">[RFC1950]
11501158
<dd>P. Deutsch; J-L. Gailly. <a href="https://www.rfc-editor.org/rfc/rfc1950"><cite>ZLIB Compressed Data Format Specification version 3.3</cite></a>. May 1996. Informational. URL: <a href="https://www.rfc-editor.org/rfc/rfc1950">https://www.rfc-editor.org/rfc/rfc1950</a>
1159+
<dt id="biblio-rfc1951">[RFC1951]
1160+
<dd>P. Deutsch. <a href="https://www.rfc-editor.org/rfc/rfc1951"><cite>DEFLATE Compressed Data Format Specification version 1.3</cite></a>. May 1996. Informational. URL: <a href="https://www.rfc-editor.org/rfc/rfc1951">https://www.rfc-editor.org/rfc/rfc1951</a>
11511161
<dt id="biblio-rfc1952">[RFC1952]
11521162
<dd>P. Deutsch. <a href="https://www.rfc-editor.org/rfc/rfc1952"><cite>GZIP file format specification version 4.3</cite></a>. May 1996. Informational. URL: <a href="https://www.rfc-editor.org/rfc/rfc1952">https://www.rfc-editor.org/rfc/rfc1952</a>
11531163
<dt id="biblio-rfc2119">[RFC2119]

0 commit comments

Comments
 (0)