- From: Takeshi Yoshino <notifications@github.com>
- Date: Tue, 17 Oct 2017 13:04:25 +0000 (UTC)
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/811/review/69870994@github.com>
tyoshino commented on this pull request. > @@ -3763,10 +3772,653 @@ nothrow>WritableStreamDefaultControllerError ( <var>controller</var>, <var>error <h2 id="ts">Transform Streams</h2> -Transform streams have been developed in the testable implementation, but not yet re-encoded in spec language. -We are waiting to validate their design before doing so. In the meantime, see <a -href="https://github.com/whatwg/streams/blob/master/reference-implementation/lib/transform-stream.js">reference-implementation/lib/transform-stream.js</a>. +<h3 id="ts-intro">Using Transform Streams</h3> + +<div class="example" id="example-basic-pipe-through"> + The natural way to use a transform stream is place it in a <a lt="piping">pipe</a> between a <a>readable stream</a> place -> placing? > - constructor. One use of identity transforms is to add additional buffering to a pipe. In this example we add extra - buffering between <code>readableStream</code> and <code>writableStream</code>. + One use of <a>identity transform streams</a> is to easily convert between readable and writable streams. For example, + the {{fetch()}} API accepts a readable stream <a for="request" lt="body">request body</a>, but it can be more + convenient to write data for uploading via a writable stream interface. Using an identity transform stream addresses + this: + + <pre><code class="lang-javascript"> + const { writable, readable } = new TransformStream(); + fetch("...", { body: readable }).then(response => /* ... */); + + writable.write(new Uint8Array([0x73, 0x74, 0x72, 0x65, 0x61, 0x6D, 0x73, 0x21])); + writable.close(); + </code></pre> + + Another use of identity transform streams is to add additional buffering to a <a>pipe</a>. In this example we add +1 -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/pull/811#pullrequestreview-69870994
Received on Tuesday, 17 October 2017 13:04:54 UTC