docs(api): pin common classes

This commit is contained in:
Elian Doran
2025-04-13 18:48:04 +03:00
parent c8860ea25a
commit 84c2ebd7f3
197 changed files with 1815 additions and 1686 deletions

View File

@@ -6,7 +6,7 @@ own resources.</p>
<pre><code class="js"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">AsyncResource</span><span class="hl-1">, </span><span class="hl-5">executionAsyncId</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-3">&#39;node:async_hooks&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-6">// AsyncResource() is meant to be extended. Instantiating a</span><br/><span class="hl-6">// new AsyncResource() also triggers init. If triggerAsyncId is omitted then</span><br/><span class="hl-6">// async_hook.executionAsyncId() is used.</span><br/><span class="hl-2">const</span><span class="hl-1"> </span><span class="hl-7">asyncResource</span><span class="hl-1"> = </span><span class="hl-2">new</span><span class="hl-1"> </span><span class="hl-0">AsyncResource</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-5">type</span><span class="hl-1">, { </span><span class="hl-5">triggerAsyncId:</span><span class="hl-1"> </span><span class="hl-0">executionAsyncId</span><span class="hl-1">(), </span><span class="hl-5">requireManualDestroy:</span><span class="hl-1"> </span><span class="hl-2">false</span><span class="hl-1"> },</span><br/><span class="hl-1">);</span><br/><br/><span class="hl-6">// Run a function in the execution context of the resource. This will</span><br/><span class="hl-6">// * establish the context of the resource</span><br/><span class="hl-6">// * trigger the AsyncHooks before callbacks</span><br/><span class="hl-6">// * call the provided function `fn` with the supplied arguments</span><br/><span class="hl-6">// * trigger the AsyncHooks after callbacks</span><br/><span class="hl-6">// * restore the original execution context</span><br/><span class="hl-5">asyncResource</span><span class="hl-1">.</span><span class="hl-0">runInAsyncScope</span><span class="hl-1">(</span><span class="hl-5">fn</span><span class="hl-1">, </span><span class="hl-5">thisArg</span><span class="hl-1">, ...</span><span class="hl-5">args</span><span class="hl-1">);</span><br/><br/><span class="hl-6">// Call AsyncHooks destroy callbacks.</span><br/><span class="hl-5">asyncResource</span><span class="hl-1">.</span><span class="hl-0">emitDestroy</span><span class="hl-1">();</span><br/><br/><span class="hl-6">// Return the unique ID assigned to the AsyncResource instance.</span><br/><span class="hl-5">asyncResource</span><span class="hl-1">.</span><span class="hl-0">asyncId</span><span class="hl-1">();</span><br/><br/><span class="hl-6">// Return the trigger ID for the AsyncResource instance.</span><br/><span class="hl-5">asyncResource</span><span class="hl-1">.</span><span class="hl-0">triggerAsyncId</span><span class="hl-1">();</span>
</code><button type="button">Copy</button></pre>
</div><div class="tsd-comment tsd-typography"></div></section><section class="tsd-panel tsd-hierarchy" data-refl="4396"><h4>Hierarchy (<a href="../hierarchy.html#Backend Script API.<internal>.AsyncResource">View Summary</a>)</h4><ul class="tsd-hierarchy"><li class="tsd-hierarchy-item"><span class="tsd-hierarchy-target">AsyncResource</span><ul class="tsd-hierarchy"><li class="tsd-hierarchy-item"><a href="../interfaces/Backend_Script_API._internal_.EventEmitter.EventEmitterReferencingAsyncResource.html" class="tsd-signature-type tsd-kind-interface">EventEmitterReferencingAsyncResource</a></li></ul></li></ul></section><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/async_hooks.d.ts:263</li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="#constructor" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
</div><div class="tsd-comment tsd-typography"></div></section><section class="tsd-panel tsd-hierarchy" data-refl="5246"><h4>Hierarchy (<a href="../hierarchy.html#Backend Script API.<internal>.AsyncResource">View Summary</a>)</h4><ul class="tsd-hierarchy"><li class="tsd-hierarchy-item"><span class="tsd-hierarchy-target">AsyncResource</span><ul class="tsd-hierarchy"><li class="tsd-hierarchy-item"><a href="../interfaces/Backend_Script_API._internal_.EventEmitter.EventEmitterReferencingAsyncResource.html" class="tsd-signature-type tsd-kind-interface">EventEmitterReferencingAsyncResource</a></li></ul></li></ul></section><aside class="tsd-sources"><ul><li>Defined in node_modules/@types/node/async_hooks.d.ts:263</li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="#constructor" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Methods</h3><div class="tsd-index-list"><a href="#asyncid" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>async<wbr/>Id</span></a>
<a href="#bind" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>bind</span></a>
<a href="#emitdestroy" class="tsd-index-link tsd-is-external"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>emit<wbr/>Destroy</span></a>