Skip to content

Commit

Permalink
chore(release): Update API docs [skip release]
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-amplify-bot committed Oct 15, 2024
1 parent 2361fcc commit 554c3d5
Show file tree
Hide file tree
Showing 81 changed files with 373 additions and 1,152 deletions.
2 changes: 1 addition & 1 deletion docs/api/assets/navigation.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/assets/search.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
control stream destruction using an <code>AbortController</code>.</p>
<p>Calling <code>abort</code> on the <code>AbortController</code> corresponding to the passed <code>AbortSignal</code> will behave the same way as calling <code>.destroy(new AbortError())</code> on the
stream, and <code>controller.error(new AbortError())</code> for webstreams.</p>
<pre><code class="language-js"><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">fs</span><span class="hl-2"> = </span><span class="hl-3">require</span><span class="hl-2">(</span><span class="hl-5">&#39;node:fs&#39;</span><span class="hl-2">);</span><br/><br/><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">controller</span><span class="hl-2"> = </span><span class="hl-6">new</span><span class="hl-2"> </span><span class="hl-3">AbortController</span><span class="hl-2">();</span><br/><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">read</span><span class="hl-2"> = </span><span class="hl-3">addAbortSignal</span><span class="hl-2">(</span><br/><span class="hl-2"> </span><span class="hl-4">controller</span><span class="hl-2">.</span><span class="hl-4">signal</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-4">fs</span><span class="hl-2">.</span><span class="hl-3">createReadStream</span><span class="hl-2">((</span><span class="hl-5">&#39;object.json&#39;</span><span class="hl-2">)),</span><br/><span class="hl-2">);</span><br/><span class="hl-0">// Later, abort the operation closing the stream</span><br/><span class="hl-4">controller</span><span class="hl-2">.</span><span class="hl-3">abort</span><span class="hl-2">();</span>
<pre><code class="language-js"><span class="hl-1">import</span><span class="hl-2"> </span><span class="hl-4">fs</span><span class="hl-2"> </span><span class="hl-1">from</span><span class="hl-2"> </span><span class="hl-5">&#39;node:fs&#39;</span><span class="hl-2">;</span><br/><br/><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">controller</span><span class="hl-2"> = </span><span class="hl-6">new</span><span class="hl-2"> </span><span class="hl-3">AbortController</span><span class="hl-2">();</span><br/><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">read</span><span class="hl-2"> = </span><span class="hl-3">addAbortSignal</span><span class="hl-2">(</span><br/><span class="hl-2"> </span><span class="hl-4">controller</span><span class="hl-2">.</span><span class="hl-4">signal</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-4">fs</span><span class="hl-2">.</span><span class="hl-3">createReadStream</span><span class="hl-2">((</span><span class="hl-5">&#39;object.json&#39;</span><span class="hl-2">)),</span><br/><span class="hl-2">);</span><br/><span class="hl-0">// Later, abort the operation closing the stream</span><br/><span class="hl-4">controller</span><span class="hl-2">.</span><span class="hl-3">abort</span><span class="hl-2">();</span>
</code><button>Copy</button></pre>
<p>Or using an <code>AbortSignal</code> with a readable stream as an async iterable:</p>
<pre><code class="language-js"><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">controller</span><span class="hl-2"> = </span><span class="hl-6">new</span><span class="hl-2"> </span><span class="hl-3">AbortController</span><span class="hl-2">();</span><br/><span class="hl-3">setTimeout</span><span class="hl-2">(() </span><span class="hl-6">=&gt;</span><span class="hl-2"> </span><span class="hl-4">controller</span><span class="hl-2">.</span><span class="hl-3">abort</span><span class="hl-2">(), </span><span class="hl-8">10_000</span><span class="hl-2">); </span><span class="hl-0">// set a timeout</span><br/><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">stream</span><span class="hl-2"> = </span><span class="hl-3">addAbortSignal</span><span class="hl-2">(</span><br/><span class="hl-2"> </span><span class="hl-4">controller</span><span class="hl-2">.</span><span class="hl-4">signal</span><span class="hl-2">,</span><br/><span class="hl-2"> </span><span class="hl-4">fs</span><span class="hl-2">.</span><span class="hl-3">createReadStream</span><span class="hl-2">((</span><span class="hl-5">&#39;object.json&#39;</span><span class="hl-2">)),</span><br/><span class="hl-2">);</span><br/><span class="hl-2">(</span><span class="hl-6">async</span><span class="hl-2"> () </span><span class="hl-6">=&gt;</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">try</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">for</span><span class="hl-2"> </span><span class="hl-1">await</span><span class="hl-2"> (</span><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">chunk</span><span class="hl-2"> </span><span class="hl-6">of</span><span class="hl-2"> </span><span class="hl-4">stream</span><span class="hl-2">) {</span><br/><span class="hl-2"> </span><span class="hl-1">await</span><span class="hl-2"> </span><span class="hl-3">process</span><span class="hl-2">(</span><span class="hl-4">chunk</span><span class="hl-2">);</span><br/><span class="hl-2"> }</span><br/><span class="hl-2"> } </span><span class="hl-1">catch</span><span class="hl-2"> (</span><span class="hl-4">e</span><span class="hl-2">) {</span><br/><span class="hl-2"> </span><span class="hl-1">if</span><span class="hl-2"> (</span><span class="hl-4">e</span><span class="hl-2">.</span><span class="hl-4">name</span><span class="hl-2"> === </span><span class="hl-5">&#39;AbortError&#39;</span><span class="hl-2">) {</span><br/><span class="hl-2"> </span><span class="hl-0">// The operation was cancelled</span><br/><span class="hl-2"> } </span><span class="hl-1">else</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">throw</span><span class="hl-2"> </span><span class="hl-4">e</span><span class="hl-2">;</span><br/><span class="hl-2"> }</span><br/><span class="hl-2"> }</span><br/><span class="hl-2">})();</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
</head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"><a href="https://docs.amplify.aws/">Library Documentation</a><a href="https://www.npmjs.com/package/aws-amplify">NPM</a><a href="https://github.com/aws-amplify/amplify-js">GitHub</a></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">Amplify JS API Documentation</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../index.html">Amplify JS API Documentation</a></li><li><a href="../modules/_aws_amplify_adapter_nextjs.html">@aws-amplify/adapter-nextjs</a></li><li><a href="../modules/_aws_amplify_adapter_nextjs.index.html">index</a></li><li><a href="../modules/_aws_amplify_adapter_nextjs.index._Reference_Types_.html">&lt;Reference Types&gt;</a></li><li><a href="../modules/_aws_amplify_adapter_nextjs.index._Reference_Types_.internal.html">internal</a></li><li><a href="_aws_amplify_adapter_nextjs.index._Reference_Types_.internal.finished-1.html">finished</a></li></ul><h1>Function finished</h1></div><section class="tsd-panel"><ul class="tsd-signatures tsd-is-external"><li class="tsd-signature tsd-anchor-link"><a id="finished" class="tsd-anchor"></a><span class="tsd-kind-call-signature">finished</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">stream</span>, <span class="tsd-kind-parameter">options</span>, <span class="tsd-kind-parameter">callback</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">(</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol"> =&gt; </span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">)</span><a href="#finished" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>A readable and/or writable stream/webstream.</p>
<p>A function to get notified when a stream is no longer readable, writable
or has experienced an error or a premature close event.</p>
<pre><code class="language-js"><span class="hl-6">const</span><span class="hl-2"> { </span><span class="hl-7">finished</span><span class="hl-2"> } = </span><span class="hl-3">require</span><span class="hl-2">(</span><span class="hl-5">&#39;node:stream&#39;</span><span class="hl-2">);</span><br/><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">fs</span><span class="hl-2"> = </span><span class="hl-3">require</span><span class="hl-2">(</span><span class="hl-5">&#39;node:fs&#39;</span><span class="hl-2">);</span><br/><br/><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">rs</span><span class="hl-2"> = </span><span class="hl-4">fs</span><span class="hl-2">.</span><span class="hl-3">createReadStream</span><span class="hl-2">(</span><span class="hl-5">&#39;archive.tar&#39;</span><span class="hl-2">);</span><br/><br/><span class="hl-3">finished</span><span class="hl-2">(</span><span class="hl-4">rs</span><span class="hl-2">, (</span><span class="hl-4">err</span><span class="hl-2">) </span><span class="hl-6">=&gt;</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">if</span><span class="hl-2"> (</span><span class="hl-4">err</span><span class="hl-2">) {</span><br/><span class="hl-2"> </span><span class="hl-4">console</span><span class="hl-2">.</span><span class="hl-3">error</span><span class="hl-2">(</span><span class="hl-5">&#39;Stream failed.&#39;</span><span class="hl-2">, </span><span class="hl-4">err</span><span class="hl-2">);</span><br/><span class="hl-2"> } </span><span class="hl-1">else</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-4">console</span><span class="hl-2">.</span><span class="hl-3">log</span><span class="hl-2">(</span><span class="hl-5">&#39;Stream is done reading.&#39;</span><span class="hl-2">);</span><br/><span class="hl-2"> }</span><br/><span class="hl-2">});</span><br/><br/><span class="hl-4">rs</span><span class="hl-2">.</span><span class="hl-3">resume</span><span class="hl-2">(); </span><span class="hl-0">// Drain the stream.</span>
<pre><code class="language-js"><span class="hl-1">import</span><span class="hl-2"> { </span><span class="hl-4">finished</span><span class="hl-2"> } </span><span class="hl-1">from</span><span class="hl-2"> </span><span class="hl-5">&#39;node:stream&#39;</span><span class="hl-2">;</span><br/><span class="hl-1">import</span><span class="hl-2"> </span><span class="hl-4">fs</span><span class="hl-2"> </span><span class="hl-1">from</span><span class="hl-2"> </span><span class="hl-5">&#39;node:fs&#39;</span><span class="hl-2">;</span><br/><br/><span class="hl-6">const</span><span class="hl-2"> </span><span class="hl-7">rs</span><span class="hl-2"> = </span><span class="hl-4">fs</span><span class="hl-2">.</span><span class="hl-3">createReadStream</span><span class="hl-2">(</span><span class="hl-5">&#39;archive.tar&#39;</span><span class="hl-2">);</span><br/><br/><span class="hl-3">finished</span><span class="hl-2">(</span><span class="hl-4">rs</span><span class="hl-2">, (</span><span class="hl-4">err</span><span class="hl-2">) </span><span class="hl-6">=&gt;</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-1">if</span><span class="hl-2"> (</span><span class="hl-4">err</span><span class="hl-2">) {</span><br/><span class="hl-2"> </span><span class="hl-4">console</span><span class="hl-2">.</span><span class="hl-3">error</span><span class="hl-2">(</span><span class="hl-5">&#39;Stream failed.&#39;</span><span class="hl-2">, </span><span class="hl-4">err</span><span class="hl-2">);</span><br/><span class="hl-2"> } </span><span class="hl-1">else</span><span class="hl-2"> {</span><br/><span class="hl-2"> </span><span class="hl-4">console</span><span class="hl-2">.</span><span class="hl-3">log</span><span class="hl-2">(</span><span class="hl-5">&#39;Stream is done reading.&#39;</span><span class="hl-2">);</span><br/><span class="hl-2"> }</span><br/><span class="hl-2">});</span><br/><br/><span class="hl-4">rs</span><span class="hl-2">.</span><span class="hl-3">resume</span><span class="hl-2">(); </span><span class="hl-0">// Drain the stream.</span>
</code><button>Copy</button></pre>
<p>Especially useful in error handling scenarios where a stream is destroyed
prematurely (like an aborted HTTP request), and will not emit <code>&#39;end&#39;</code> or <code>&#39;finish&#39;</code>.</p>
Expand Down
Loading

0 comments on commit 554c3d5

Please sign in to comment.