<!DOCTYPE html><htmlclass="default"lang="en"data-base="../"><head><metacharset="utf-8"/><metahttp-equiv="x-ua-compatible"content="IE=edge"/><title>EventEmitter | trilium</title><metaname="description"content="Documentation for trilium"/><metaname="viewport"content="width=device-width, initial-scale=1"/><linkrel="stylesheet"href="../assets/style.css"/><linkrel="stylesheet"href="../assets/highlight.css"/><scriptdefersrc="../assets/main.js"></script><scriptasyncsrc="../assets/icons.js"id="tsd-icons-script"></script><scriptasyncsrc="../assets/search.js"id="tsd-search-script"></script><scriptasyncsrc="../assets/navigation.js"id="tsd-nav-script"></script><scriptasyncsrc="../assets/hierarchy.js"id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme=localStorage.getItem("tsd-theme")||"os";document.body.style.display="none";setTimeout(()=>window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><headerclass="tsd-page-toolbar"><divclass="tsd-toolbar-contents container"><ahref="../index.html"class="title">trilium</a><divid="tsd-toolbar-links"></div><buttonid="tsd-search-trigger"class="tsd-widget"aria-label="Search"><svgwidth="16"height="16"viewBox="0 0 16 16"fill="none"aria-hidden="true"><usehref="../assets/icons.svg#icon-search"></use></svg></button><dialogid="tsd-search"aria-label="Search"><inputrole="combobox"id="tsd-search-input"aria-controls="tsd-search-results"aria-autocomplete="list"aria-expanded="true"autocapitalize="off"autocomplete="off"placeholder="Search the docs"maxLength="100"/><ulrole="listbox"id="tsd-search-results"></ul><divid="tsd-search-status"aria-live="polite"aria-atomic="true"><div>Preparing search index...</div></div></dialog><ahref="#"class="tsd-widget menu"id="tsd-toolbar-menu-trigger"data-toggle="menu"aria-label="Menu"><svgwidth="16"height="16"viewBox="0 0 16 16"fill="none"aria-hidden="true"><usehref="../assets/icons.svg#icon-menu"></use></svg></a></div></header><divclass="container container-main"><divclass="col-content"><divclass="tsd-page-title"><ulclass="tsd-breadcrumb"aria-label="Breadcrumb"><li><ahref="../modules/Backend_Script_API.html">Backend Script API</a></li><li><ahref="../modules/Backend_Script_API._internal_.html"><internal></a></li><li><ahref=""aria-current="page">EventEmitter</a></li></ul><h1>Class EventEmitter<T></h1></div><sectionclass="tsd-panel tsd-comment"><divclass="tsd-comment tsd-typography"><p>The <code>EventEmitter</code> class is defined and exposed by the <code>node:events</code> module:</p>
</div></div><asideclass="tsd-sources"><ul><li>Defined in node_modules/@types/node/events.d.ts:452</li></ul></aside></section><sectionclass="tsd-panel tsd-member tsd-is-external"><h3class="tsd-anchor-link"id="defaultmaxlisteners"><codeclass="tsd-tag">Static</code><span>default<wbr/>Max<wbr/>Listeners</span><ahref="#defaultmaxlisteners"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><divclass="tsd-signature"><spanclass="tsd-kind-property">defaultMaxListeners</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">number</span></div><divclass="tsd-comment tsd-typography"><p>By default, a maximum of <code>10</code> listeners can be registered for any single
event. This limit can be changed for individual <code>EventEmitter</code> instances
using the <code>emitter.setMaxListeners(n)</code> method. To change the default
for <em>all</em><code>EventEmitter</code> instances, the <code>events.defaultMaxListeners</code> property
can be used. If this value is not a positive number, a <code>RangeError</code> is thrown.</p>
<p>Take caution when setting the <code>events.defaultMaxListeners</code> because the
change affects <em>all</em><code>EventEmitter</code> instances, including those created before
the change is made. However, calling <code>emitter.setMaxListeners(n)</code> still has
precedence over <code>events.defaultMaxListeners</code>.</p>
<p>This is not a hard limit. The <code>EventEmitter</code> instance will allow
more listeners to be added but will output a trace warning to stderr indicating
that a "possible EventEmitter memory leak" has been detected. For any single
<code>EventEmitter</code>, the <code>emitter.getMaxListeners()</code> and <code>emitter.setMaxListeners()</code> methods can be used to
</div></div><asideclass="tsd-sources"><ul><li>Defined in node_modules/@types/node/events.d.ts:498</li></ul></aside></section><sectionclass="tsd-panel tsd-member tsd-is-external"><h3class="tsd-anchor-link"id="errormonitor"><codeclass="tsd-tag">Static</code><codeclass="tsd-tag">Readonly</code><span>error<wbr/>Monitor</span><ahref="#errormonitor"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><divclass="tsd-signature"><spanclass="tsd-kind-property">errorMonitor</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-keyword">typeof</span><ahref="#errormonitor"class="tsd-signature-type tsd-kind-property">errorMonitor</a></div><divclass="tsd-comment tsd-typography"><p>This symbol shall be used to install a listener for only monitoring <code>'error'</code> events. Listeners installed using this symbol are called before the regular <code>'error'</code> listeners are called.</p>
<p>Installing a listener using this symbol does not change the behavior once an <code>'error'</code> event is emitted. Therefore, the process will still crash if no
regular <code>'error'</code> listener is installed.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#addlistener">addListener</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:597</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="emit"><span>emit</span><ahref="#emit"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="emit-1"><spanclass="tsd-kind-call-signature">emit</span><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#emitk">K</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#emitk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-signature-symbol">...</span><spanclass="tsd-kind-parameter">args</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Args.html"class="tsd-signature-type tsd-kind-type-alias">Args</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#emitk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">boolean</span><ahref="#emit-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Synchronously calls each of the listeners registered for the event named <code>eventName</code>, in the order they were registered, passing the supplied arguments
<p>Returns <code>true</code> if the event had listeners, <code>false</code> otherwise.</p>
<pre><codeclass="js"><spanclass="hl-4">import</span><spanclass="hl-1"> { </span><spanclass="hl-5">EventEmitter</span><spanclass="hl-1"> } </span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:events'</span><spanclass="hl-1">;</span><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">myEmitter</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">EventEmitter</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-6">// First listener</span><br/><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">, </span><spanclass="hl-2">function</span><spanclass="hl-1"></span><spanclass="hl-0">firstListener</span><spanclass="hl-1">() {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">'Helloooo! first listener'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">});</span><br/><spanclass="hl-6">// Second listener</span><br/><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">, </span><spanclass="hl-2">function</span><spanclass="hl-1"></span><spanclass="hl-0">secondListener</span><spanclass="hl-1">(</span><spanclass="hl-5">arg1</span><spanclass="hl-1">, </span><spanclass="hl-5">arg2</span><spanclass="hl-1">) {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">`event with parameters </span><spanclass="hl-2">${</span><spanclass="hl-5">arg1</span><spanclass="hl-2">}</span><spanclass="hl-3">, </span><spanclass="hl-2">${</span><spanclass="hl-5">arg2</span><spanclass="hl-2">}</span><spanclass="hl-3"> in second listener`</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">});</span><br/><spanclass="hl-6">// Third listener</span><br/><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">, </span><spanclass="hl-2">function</span><spanclass="hl-1"></span><spanclass="hl-0">thirdListener</span><spanclass="hl-1">(...</span><spanclass="hl-5">args</span><spanclass="hl-1">) {</span><br/><spanclass="hl-1"></span><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">parameters</span><spanclass="hl-1"> = </span><spanclass="hl-5">args</span><spanclass="hl-1">.</span><spanclass="hl-0">join</span><spanclass="hl-1">(</span><spanclass="hl-3">', '</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">`event with parameters </span><spanclass="hl-2">${</span><spanclass="hl-5">parameters</span><spanclass="hl-2">}</span><spanclass="hl-3"> in third listener`</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">});</span><br/><br/><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">listeners</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">));</span><br/><br/><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">, </span><spanclass="hl-9">1</span><spanclass="hl-1">, </span><spanclass="hl-9">2</span><spanclass="hl-1">, </span><spanclass="hl-9">3</span><spanclass="hl-1">, </span><spanclass="hl-9">4</span><spanclass="hl-1">, </span><spanclass="hl-9">5</span><span
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#emit">emit</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:859</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="eventnames"><span>event<wbr/>Names</span><ahref="#eventnames"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="eventnames-1"><spanclass="tsd-kind-call-signature">eventNames</span><spanclass="tsd-signature-symbol">()</span><spanclass="tsd-signature-symbol">:</span> ((<spanclass="tsd-signature-type">string</span><spanclass="tsd-signature-symbol">|</span><spanclass="tsd-signature-type">symbol</span>) <spanclass="tsd-signature-symbol">&</span><ahref="../types/Backend_Script_API._internal_.Key2.html"class="tsd-signature-type tsd-kind-type-alias">Key2</a><spanclass="tsd-signature-symbol"><</span><spanclass="tsd-signature-type">unknown</span><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span>)<spanclass="tsd-signature-symbol">[]</span><ahref="#eventnames-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Returns an array listing the events for which the emitter has registered
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#eventnames">eventNames</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:922</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="getmaxlisteners"><span>get<wbr/>Max<wbr/>Listeners</span><ahref="#getmaxlisteners"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="getmaxlisteners-1"><spanclass="tsd-kind-call-signature">getMaxListeners</span><spanclass="tsd-signature-symbol">()</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">number</span><ahref="#getmaxlisteners-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Returns the current max listener value for the <code>EventEmitter</code> which is either
set by <code>emitter.setMaxListeners(n)</code> or defaults to <ahref="#defaultmaxlisteners"class="tsd-kind-property">EventEmitter.defaultMaxListeners</a>.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#getmaxlisteners">getMaxListeners</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:774</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="listenercount"><span>listener<wbr/>Count</span><ahref="#listenercount"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="listenercount-1"><spanclass="tsd-kind-call-signature">listenerCount</span><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#listenercountk">K</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">(</span><br/><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#listenercountk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-kind-parameter">listener</span><spanclass="tsd-signature-symbol">?:</span><ahref="../types/Backend_Script_API._internal_.Listener.html"class="tsd-signature-type tsd-kind-type-alias">Listener</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#listenercountk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-signature-type">Function</span><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">number</span><ahref="#listenercount-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Returns the number of listeners listening for the event named <code>eventName</code>.
</div><sectionclass="tsd-panel"><h4>Type Parameters</h4><ulclass="tsd-type-parameter-list"><li><spanid="listenercountk"><spanclass="tsd-kind-type-parameter">K</span></span></li></ul></section><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><span><spanclass="tsd-kind-parameter">eventName</span>: <ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#listenercountk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span></span><divclass="tsd-comment tsd-typography"><p>The name of the event being listened for</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#listenercount">listenerCount</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:868</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="listeners"><span>listeners</span><ahref="#listeners"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="listeners-1"><spanclass="tsd-kind-call-signature">listeners</span><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#listenersk">K</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#listenersk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Listener.html"class="tsd-signature-type tsd-kind-type-alias">Listener</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#listenersk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-signature-type">Function</span><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">[]</span><ahref="#listeners-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Returns a copy of the array of listeners for the event named <code>eventName</code>.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#off">off</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:747</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="on"><span>on</span><ahref="#on"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="on-1"><spanclass="tsd-kind-call-signature">on</span><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#onk">K</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#onk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-kind-parameter">listener</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Listener.html"class="tsd-signature-type tsd-kind-type-alias">Listener</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#onk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">this</span><ahref="#on-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Adds the <code>listener</code> function to the end of the listeners array for the event
<p>Returns a reference to the <code>EventEmitter</code>, so that calls can be chained.</p>
<p>By default, event listeners are invoked in the order they are added. The <code>emitter.prependListener()</code> method can be used as an alternative to add the
event listener to the beginning of the listeners array.</p>
</div><sectionclass="tsd-panel"><h4>Type Parameters</h4><ulclass="tsd-type-parameter-list"><li><spanid="onk"><spanclass="tsd-kind-type-parameter">K</span></span></li></ul></section><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><span><spanclass="tsd-kind-parameter">eventName</span>: <ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#onk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span></span><divclass="tsd-comment tsd-typography"><p>The name of the event.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#on">on</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:629</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="once"><span>once</span><ahref="#once"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="once-1"><spanclass="tsd-kind-call-signature">once</span><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#oncek">K</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#oncek">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-kind-parameter">listener</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Listener.html"class="tsd-signature-type tsd-kind-type-alias">Listener</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#oncek">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">this</span><ahref="#once-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Adds a <strong>one-time</strong><code>listener</code> function for the event named <code>eventName</code>. The
next time <code>eventName</code> is triggered, this listener is removed and then invoked.</p>
<pre><codeclass="js"><spanclass="hl-5">server</span><spanclass="hl-1">.</span><spanclass="hl-0">once</span><spanclass="hl-1">(</span><spanclass="hl-3">'connection'</span><spanclass="hl-1">, (</span><spanclass="hl-5">stream</span><spanclass="hl-1">) </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">'Ah, we have our first user!'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">});</span>
</code><buttontype="button">Copy</button></pre>
<p>Returns a reference to the <code>EventEmitter</code>, so that calls can be chained.</p>
<p>By default, event listeners are invoked in the order they are added. The <code>emitter.prependOnceListener()</code> method can be used as an alternative to add the
event listener to the beginning of the listeners array.</p>
</div><sectionclass="tsd-panel"><h4>Type Parameters</h4><ulclass="tsd-type-parameter-list"><li><spanid="oncek"><spanclass="tsd-kind-type-parameter">K</span></span></li></ul></section><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><span><spanclass="tsd-kind-parameter">eventName</span>: <ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#oncek">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span></span><divclass="tsd-comment tsd-typography"><p>The name of the event.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#once">once</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:659</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="prependlistener"><span>prepend<wbr/>Listener</span><ahref="#prependlistener"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="prependlistener-1"><spanclass="tsd-kind-call-signature">prependListener</span><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#prependlistenerk">K</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#prependlistenerk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-kind-parameter">listener</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Listener.html"class="tsd-signature-type tsd-kind-type-alias">Listener</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#prependlistenerk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">this</span><ahref="#prependlistener-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Adds the <code>listener</code> function to the <em>beginning</em> of the listeners array for the
</div><sectionclass="tsd-panel"><h4>Type Parameters</h4><ulclass="tsd-type-parameter-list"><li><spanid="prependlistenerk"><spanclass="tsd-kind-type-parameter">K</span></span></li></ul></section><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><span><spanclass="tsd-kind-parameter">eventName</span>: <ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#prependlistenerk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span></span><divclass="tsd-comment tsd-typography"><p>The name of the event.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#prependlistener">prependListener</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:886</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="prependoncelistener"><span>prepend<wbr/>Once<wbr/>Listener</span><ahref="#prependoncelistener"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="prependoncelistener-1"><spanclass="tsd-kind-call-signature">prependOnceListener</span><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#prependoncelistenerk">K</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#prependoncelistenerk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-kind-parameter">listener</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Listener.html"class="tsd-signature-type tsd-kind-type-alias">Listener</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#prependoncelistenerk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">this</span><ahref="#prependoncelistener-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Adds a <strong>one-time</strong><code>listener</code> function for the event named <code>eventName</code> to the <em>beginning</em> of the listeners array. The next time <code>eventName</code> is triggered, this
<pre><codeclass="js"><spanclass="hl-5">server</span><spanclass="hl-1">.</span><spanclass="hl-0">prependOnceListener</span><spanclass="hl-1">(</span><spanclass="hl-3">'connection'</span><spanclass="hl-1">, (</span><spanclass="hl-5">stream</span><spanclass="hl-1">) </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">'Ah, we have our first user!'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">});</span>
</code><buttontype="button">Copy</button></pre>
<p>Returns a reference to the <code>EventEmitter</code>, so that calls can be chained.</p>
</div><sectionclass="tsd-panel"><h4>Type Parameters</h4><ulclass="tsd-type-parameter-list"><li><spanid="prependoncelistenerk"><spanclass="tsd-kind-type-parameter">K</span></span></li></ul></section><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><span><spanclass="tsd-kind-parameter">eventName</span>: <ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#prependoncelistenerk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span></span><divclass="tsd-comment tsd-typography"><p>The name of the event.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#prependoncelistener">prependOnceListener</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:902</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="rawlisteners"><span>raw<wbr/>Listeners</span><ahref="#rawlisteners"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="rawlisteners-1"><spanclass="tsd-kind-call-signature">rawListeners</span><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#rawlistenersk">K</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#rawlistenersk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Listener.html"class="tsd-signature-type tsd-kind-type-alias">Listener</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#rawlistenersk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-signature-type">Function</span><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">[]</span><ahref="#rawlisteners-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Returns a copy of the array of listeners for the event named <code>eventName</code>,
including any wrappers (such as those created by <code>.once()</code>).</p>
<pre><codeclass="js"><spanclass="hl-4">import</span><spanclass="hl-1"> { </span><spanclass="hl-5">EventEmitter</span><spanclass="hl-1"> } </span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:events'</span><spanclass="hl-1">;</span><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">emitter</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">EventEmitter</span><spanclass="hl-1">();</span><br/><spanclass="hl-5">emitter</span><spanclass="hl-1">.</span><spanclass="hl-0">once</span><spanclass="hl-1">(</span><spanclass="hl-3">'log'</span><spanclass="hl-1">, () </span><spanclass="hl-2">=></span><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">'log once'</span><spanclass="hl-1">));</span><br/><br/><spanclass="hl-6">// Returns a new Array with a function `onceWrapper` which has a property</span><br/><spanclass="hl-6">// `listener` which contains the original listener bound above</span><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">listeners</span><spanclass="hl-1"> = </span><spanclass="hl-5">emitter</span><spanclass="hl-1">.</span><spanclass="hl-0">rawListeners</span><spanclass="hl-1">(</span><spanclass="hl-3">'log'</span><spanclass="hl-1">);</span><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">logFnWrapper</span><spanclass="hl-1"> = </span><spanclass="hl-5">listeners</span><spanclass="hl-1">[</span><spanclass="hl-9">0</span><spanclass="hl-1">];</span><br/><br/><spanclass="hl-6">// Logs "log once" to the console and does not unbind the `once` event</span><br/><spanclass="hl-5">logFnWrapper</span><spanclass="hl-1">.</span><spanclass="hl-0">listener</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-6">// Logs "log once" to the console and removes the listener</span><br/><spanclass="hl-0">logFnWrapper</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-5">emitter</span><spanclass="hl-1">.</span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-3">'log'</span><spanclass="hl-1">, () </span><spanclass="hl-2">=></span><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">'log persistently'</span><spanclass="hl-1">));</span><br/><spanclass="hl-6">// Will return a new Array with a single function bound by `.on()` above</span><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">newListeners</span><spanclass="hl-1"> = </span><spanclass="hl-5">emitter</span><spanclass="hl-1">.</span><spanclass="hl-0">rawListeners</span><spanclass="hl-1">(</span><spanclass="hl-3">'log'</span><spanclass="hl-1">);</span><br/><br/><spanclass="hl-6">// Logs "log persistently" twice</span><br/><spanclass="hl-5">newListeners</span><spanclass="hl-1">[</span><spanclass="hl-9">0</span><spanclass="hl-1">]();</span><br/><spanclass="hl-5">emitter</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'log'</span><spanclass="hl-1">);</span>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#rawlisteners">rawListeners</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:818</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="removealllisteners"><span>remove<wbr/>All<wbr/>Listeners</span><ahref="#removealllisteners"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="removealllisteners-1"><spanclass="tsd-kind-call-signature">removeAllListeners</span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">?:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><spanclass="tsd-signature-type">unknown</span><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">this</span><ahref="#removealllisteners-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Removes all listeners, or those of the specified <code>eventName</code>.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#removealllisteners">removeAllListeners</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:758</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="removelistener"><span>remove<wbr/>Listener</span><ahref="#removelistener"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="removelistener-1"><spanclass="tsd-kind-call-signature">removeListener</span><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#removelistenerk">K</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Key.html"class="tsd-signature-type tsd-kind-type-alias">Key</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#removelistenerk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-kind-parameter">listener</span><spanclass="tsd-signature-symbol">:</span><ahref="../types/Backend_Script_API._internal_.Listener.html"class="tsd-signature-type tsd-kind-type-alias">Listener</a><spanclass="tsd-signature-symbol"><</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="Backend_Script_API._internal_.node_modules__types_xml2js.Parser.html#removelistenerk">K</a><spanclass="tsd-signature-symbol">,</span><aclass="tsd-signature-type tsd-kind-type-parameter"href="#constructoreventemittert">T</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">this</span><ahref="#removelistener-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Removes the specified <code>listener</code> from the listener array for the event named <code>eventName</code>.</p>
<p><code>removeListener()</code> will remove, at most, one instance of a listener from the
listener array. If any single listener has been added multiple times to the
listener array for the specified <code>eventName</code>, then <code>removeListener()</code> must be
called multiple times to remove each instance.</p>
<p>Once an event is emitted, all listeners attached to it at the
time of emitting are called in order. This implies that any <code>removeListener()</code> or <code>removeAllListeners()</code> calls <em>after</em> emitting and <em>before</em> the last listener finishes execution
will not remove them from<code>emit()</code> in progress. Subsequent events behave as expected.</p>
<pre><codeclass="js"><spanclass="hl-4">import</span><spanclass="hl-1"> { </span><spanclass="hl-5">EventEmitter</span><spanclass="hl-1"> } </span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:events'</span><spanclass="hl-1">;</span><br/><spanclass="hl-2">class</span><spanclass="hl-1"></span><spanclass="hl-8">MyEmitter</span><spanclass="hl-1"></span><spanclass="hl-2">extends</span><spanclass="hl-1"></span><spanclass="hl-8">EventEmitter</span><spanclass="hl-1"> {}</span><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">myEmitter</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">MyEmitter</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-0">callbackA</span><spanclass="hl-1"> = () </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">'A'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"></span><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">removeListener</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">, </span><spanclass="hl-5">callbackB</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">};</span><br/><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-0">callbackB</span><spanclass="hl-1"> = () </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">'B'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">};</span><br/><br/><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">, </span><spanclass="hl-5">callbackA</span><spanclass="hl-1">);</span><br/><br/><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">, </span><spanclass="hl-5">callbackB</span><spanclass="hl-1">);</span><br/><br/><spanclass="hl-6">// callbackA removes listener callbackB but it will still be called.</span><br/><spanclass="hl-6">// Internal listener array at time of emit [callbackA, callbackB]</span><br/><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">);</span><br/><spanclass="hl-6">// Prints:</span><br/><spanclass="hl-6">// A</span><br/><spanclass="hl-6">// B</span><br/><br/><spanclass="hl-6">// callbackB is now removed.</span><br/><spanclass="hl-6">// Internal listener array [callbackA]</span><br/><spanclass="hl-5">myEmitter</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'event'</span><spanclass="hl-1">);</span><br/><spanclass="hl-6">// Prints:</span><br/><spanclass="hl-6">// A</span>
</code><buttontype="button">Copy</button></pre>
<p>Because listeners are managed using an internal array, calling this will
change the position indices of any listener registered <em>after</em> the listener
being removed. This will not impact the order in which listeners are called,
but it means that any copies of the listener array as returned by
the <code>emitter.listeners()</code> method will need to be recreated.</p>
<p>When a single function has been added as a handler multiple times for a single
event (as in the example below), <code>removeListener()</code> will remove the most
recently added instance. In the example the <code>once('ping')</code> listener is removed:</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#removelistener">removeListener</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:742</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="setmaxlisteners"><span>set<wbr/>Max<wbr/>Listeners</span><ahref="#setmaxlisteners"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="setmaxlisteners-1"><spanclass="tsd-kind-call-signature">setMaxListeners</span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">n</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">number</span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">this</span><ahref="#setmaxlisteners-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>By default <code>EventEmitter</code>s will print a warning if more than <code>10</code> listeners are
added for a particular event. This is a useful default that helps finding
memory leaks. The <code>emitter.setMaxListeners()</code> method allows the limit to be
modified for this specific <code>EventEmitter</code> instance. The value can be set to <code>Infinity</code> (or <code>0</code>) to indicate an unlimited number of listeners.</p>
<p>Returns a reference to the <code>EventEmitter</code>, so that calls can be chained.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from <ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html">EventEmitter</a>.<ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html#setmaxlisteners">setMaxListeners</a></p><ul><li>Defined in node_modules/@types/node/events.d.ts:768</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-external"><h3class="tsd-anchor-link"id="addabortlistener"><codeclass="tsd-tag">Static</code><span>add<wbr/>Abort<wbr/>Listener</span><ahref="#addabortlistener"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-external"><liclass="tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="addabortlistener-1"><spanclass="tsd-kind-call-signature">addAbortListener</span><spanclass="tsd-signature-symbol">(</span><br/><spanclass="tsd-kind-parameter">signal</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">AbortSignal</span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-kind-parameter">resource</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">event</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">Event</span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">=></span><spanclass="tsd-signature-type">void</span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><ahref="../interfaces/Backend_Script_API._internal_.Disposable.html"class="tsd-signature-type tsd-kind-interface">Disposable</a><ahref="#addabortlistener-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><codeclass="tsd-tag">Experimental</code><divclass="tsd-comment tsd-typography"><p>Listens once to the <code>abort</code> event on the provided <code>signal</code>.</p>
</div><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><span><spanclass="tsd-kind-parameter">signal</span>: <spanclass="tsd-signature-type">AbortSignal</span></span></li><li><span><spanclass="tsd-kind-parameter">resource</span>: <spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">event</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">Event</span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">=></span><spanclass="tsd-signature-type">void</span></span></li></ul></div><h4class="tsd-returns-title">Returns <ahref="../interfaces/Backend_Script_API._internal_.Disposable.html"class="tsd-signature-type tsd-kind-interface">Disposable</a></h4><p>Disposable that removes the <code>abort</code> listener.</p>
</div></div><asideclass="tsd-sources"><ul><li>Defined in node_modules/@types/node/events.d.ts:437</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-external"><h3class="tsd-anchor-link"id="geteventlisteners"><codeclass="tsd-tag">Static</code><span>get<wbr/>Event<wbr/>Listeners</span><ahref="#geteventlisteners"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-external"><liclass="tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="geteventlisteners-1"><spanclass="tsd-kind-call-signature">getEventListeners</span><spanclass="tsd-signature-symbol">(</span><br/><spanclass="tsd-kind-parameter">emitter</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">EventTarget</span><spanclass="tsd-signature-symbol">|</span><ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html"class="tsd-signature-type tsd-kind-interface">EventEmitter</a><spanclass="tsd-signature-symbol"><</span><ahref="../types/Backend_Script_API._internal_.DefaultEventMap.html"class="tsd-signature-type tsd-kind-type-alias">DefaultEventMap</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-kind-parameter">name</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">string</span><spanclass="tsd-signature-symbol">|</span><spanclass="tsd-signature-type">symbol</span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">Function</span><spanclass="tsd-signature-symbol">[]</span><ahref="#geteventlisteners-1"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Returns a copy of the array of listeners for the event named <code>eventName</code>.</p>
</div></div><asideclass="tsd-sources"><ul><li>Defined in node_modules/@types/node/events.d.ts:358</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="getmaxlisteners-2"><codeclass="tsd-tag">Static</code><span>get<wbr/>Max<wbr/>Listeners</span><ahref="#getmaxlisteners-2"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="getmaxlisteners-3"><spanclass="tsd-kind-call-signature">getMaxListeners</span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">emitter</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">EventTarget</span><spanclass="tsd-signature-symbol">|</span><ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html"class="tsd-signature-type tsd-kind-interface">EventEmitter</a><spanclass="tsd-signature-symbol"><</span><ahref="../types/Backend_Script_API._internal_.DefaultEventMap.html"class="tsd-signature-type tsd-kind-type-alias">DefaultEventMap</a><spanclass="tsd-signature-symbol">></span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">number</span><ahref="#getmaxlisteners-3"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Returns the currently set max amount of listeners.</p>
</div></div><asideclass="tsd-sources"><p>Inherited from NodeJS.EventEmitter.getMaxListeners</p><ul><li>Defined in node_modules/@types/node/events.d.ts:387</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="listenercount-2"><codeclass="tsd-tag">Static</code><spanclass="deprecated">listener<wbr/>Count</span><ahref="#listenercount-2"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="listenercount-3"><spanclass="tsd-kind-call-signature">listenerCount</span><spanclass="tsd-signature-symbol">(</span><spanclass="tsd-kind-parameter">emitter</span><spanclass="tsd-signature-symbol">:</span><ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html"class="tsd-signature-type tsd-kind-interface">EventEmitter</a><spanclass="tsd-signature-symbol">,</span><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">string</span><spanclass="tsd-signature-symbol">|</span><spanclass="tsd-signature-type">symbol</span><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">number</span><ahref="#listenercount-3"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>A class method that returns the number of listeners for the given <code>eventName</code> registered on the given <code>emitter</code>.</p>
<p>Returns an <code>AsyncIterator</code> that iterates <code>eventName</code> events. It will throw
if the <code>EventEmitter</code> emits <code>'error'</code>. It removes all listeners when
exiting the loop. The <code>value</code> returned by each iteration is an array
composed of the emitted event arguments.</p>
<p>An <code>AbortSignal</code> can be used to cancel waiting on events:</p>
<pre><codeclass="js"><spanclass="hl-4">import</span><spanclass="hl-1"> { </span><spanclass="hl-5">on</span><spanclass="hl-1">, </span><spanclass="hl-5">EventEmitter</span><spanclass="hl-1"> } </span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:events'</span><spanclass="hl-1">;</span><br/><spanclass="hl-4">import</span><spanclass="hl-1"></span><spanclass="hl-5">process</span><spanclass="hl-1"></span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:process'</span><spanclass="hl-1">;</span><br/><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">ac</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">AbortController</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-1">(</span><spanclass="hl-2">async</span><spanclass="hl-1"> () </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">ee</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">EventEmitter</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-1"></span><spanclass="hl-6">// Emit later on</span><br/><spanclass="hl-1"></span><spanclass="hl-5">process</span><spanclass="hl-1">.</span><spanclass="hl-0">nextTick</span><spanclass="hl-1">(() </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-3">'bar'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-9">42</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"> });</span><br/><br/><spanclass="hl-1"></span><spanclass="hl-4">for</span><spanclass="hl-1"></span><spanclass="hl-4">await</span><spanclass="hl-1"> (</span><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">event</span><spanclass="hl-1"></span><spanclass="hl-2">of</span><spanclass="hl-1"></span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-5">ee</span><spanclass="hl-1">, </span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, { </span><spanclass="hl-5">signal:</span><spanclass="hl-1"></span><spanclass="hl-5">ac</span><spanclass="hl-1">.</span><spanclass="hl-5">signal</span><spanclass="hl-1"> })) {</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// The execution of this inner block is synchronous and it</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// processes one event at a time (even with await). Do not use</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// if concurrent execution is required.</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-5">event</span><spanclass="hl-1">); </span><spanclass="hl-6">// prints ['bar'] [42]</span><br/><spanclass="hl-1"> }</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// Unreachable here</span><br/><spanclass="hl-1">})();</span><br/><br/><spanclass="hl-5">process</span><spanclass="hl-1">.</span><spanclass="hl-0">nextTick</span><spanclass="hl-1">(() </span><spanclass="hl-2">=></span><spanclass="hl-1"></span><spanclass="hl-5">ac</span><spanclass="hl-1">.</span><spanclass="hl-0">abort</span><spanclass="hl-1">());</span>
</code><buttontype="button">Copy</button></pre>
<p>Use the <code>close</code> option to specify an array of event names that will end the iteration:</p>
<pre><codeclass="js"><spanclass="hl-4">import</span><spanclass="hl-1"> { </span><spanclass="hl-5">on</span><spanclass="hl-1">, </span><spanclass="hl-5">EventEmitter</span><spanclass="hl-1"> } </span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:events'</span><spanclass="hl-1">;</span><br/><spanclass="hl-4">import</span><spanclass="hl-1"></span><spanclass="hl-5">process</span><spanclass="hl-1"></span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:process'</span><spanclass="hl-1">;</span><br/><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">ee</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">EventEmitter</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-6">// Emit later on</span><br/><spanclass="hl-5">process</span><spanclass="hl-1">.</span><spanclass="hl-0">nextTick</span><spanclass="hl-1">(() </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-3">'bar'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-9">42</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'close'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">});</span><br/><br/><spanclass="hl-4">for</span><spanclass="hl-1"></span><spanclass="hl-4">await</span><spanclass="hl-1"> (</span><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">event</span><spanclass="hl-1"></span><spanclass="hl-2">of</span><spanclass="hl-1"></span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-5">ee</span><spanclass="hl-1">, </span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, { </span><spanclass="hl-5">close:</span><spanclass="hl-1"> [</span><spanclass="hl-3">'close'</span><spanclass="hl-1">] })) {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-5">event</span><spanclass="hl-1">); </span><spanclass="hl-6">// prints ['bar'] [42]</span><br/><spanclass="hl-1">}</span><br/><spanclass="hl-6">// the loop will exit after 'close' is emitted</span><br/><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">'done'</span><spanclass="hl-1">); </span><spanclass="hl-6">// prints 'done'</span>
</div></div><asideclass="tsd-sources"><p>Inherited from NodeJS.EventEmitter.on</p><ul><li>Defined in node_modules/@types/node/events.d.ts:303</li></ul></aside></div></li><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="on-4"><spanclass="tsd-kind-call-signature">on</span><spanclass="tsd-signature-symbol">(</span><br/><spanclass="tsd-kind-parameter">emitter</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">EventTarget</span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">string</span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-kind-parameter">options</span><spanclass="tsd-signature-symbol">?:</span><ahref="../interfaces/Backend_Script_API._internal_.StaticEventEmitterIteratorOptions.html"class="tsd-signature-type tsd-kind-interface">StaticEventEmitterIteratorOptions</a><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">AsyncIterator</span><spanclass="tsd-signature-symbol"><</span><spanclass="tsd-signature-type">any</span><spanclass="tsd-signature-symbol">[]</span><spanclass="tsd-signature-symbol">></span><ahref="#on-4"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><pre><codeclass="js"><spanclass="hl-4">import</span><spanclass="hl-1"> { </span><spanclass="hl-5">on</span><spanclass="hl-1">, </span><spanclass="hl-5">EventEmitter</span><spanclass="hl-1"> } </span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:events'</span><spanclass="hl-1">;</span><br/><spanclass="hl-4">import</span><spanclass="hl-1"></span><spanclass="hl-5">process</span><spanclass="hl-1"></span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:process'</span><spanclass="hl-1">;</span><br/><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">ee</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">EventEmitter</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-6">// Emit later on</span><br/><spanclass="hl-5">process</span><spanclass="hl-1">.</span><spanclass="hl-0">nextTick</span><spanclass="hl-1">(() </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-3">'bar'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-9">42</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">});</span><br/><br/><spanclass="hl-4">for</span><spanclass="hl-1"></span><spanclass="hl-4">await</span><spanclass="hl-1"> (</span><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">event</span><spanclass="hl-1"></span><spanclass="hl-2">of</span><spanclass="hl-1"></span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-5">ee</span><spanclass="hl-1">, </span><spanclass="hl-3">'foo'</span><spanclass="hl-1">)) {</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// The execution of this inner block is synchronous and it</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// processes one event at a time (even with await). Do not use</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// if concurrent executio
<p>Returns an <code>AsyncIterator</code> that iterates <code>eventName</code> events. It will throw
if the <code>EventEmitter</code> emits <code>'error'</code>. It removes all listeners when
exiting the loop. The <code>value</code> returned by each iteration is an array
composed of the emitted event arguments.</p>
<p>An <code>AbortSignal</code> can be used to cancel waiting on events:</p>
<pre><codeclass="js"><spanclass="hl-4">import</span><spanclass="hl-1"> { </span><spanclass="hl-5">on</span><spanclass="hl-1">, </span><spanclass="hl-5">EventEmitter</span><spanclass="hl-1"> } </span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:events'</span><spanclass="hl-1">;</span><br/><spanclass="hl-4">import</span><spanclass="hl-1"></span><spanclass="hl-5">process</span><spanclass="hl-1"></span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:process'</span><spanclass="hl-1">;</span><br/><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">ac</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">AbortController</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-1">(</span><spanclass="hl-2">async</span><spanclass="hl-1"> () </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">ee</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">EventEmitter</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-1"></span><spanclass="hl-6">// Emit later on</span><br/><spanclass="hl-1"></span><spanclass="hl-5">process</span><spanclass="hl-1">.</span><spanclass="hl-0">nextTick</span><spanclass="hl-1">(() </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-3">'bar'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-9">42</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"> });</span><br/><br/><spanclass="hl-1"></span><spanclass="hl-4">for</span><spanclass="hl-1"></span><spanclass="hl-4">await</span><spanclass="hl-1"> (</span><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">event</span><spanclass="hl-1"></span><spanclass="hl-2">of</span><spanclass="hl-1"></span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-5">ee</span><spanclass="hl-1">, </span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, { </span><spanclass="hl-5">signal:</span><spanclass="hl-1"></span><spanclass="hl-5">ac</span><spanclass="hl-1">.</span><spanclass="hl-5">signal</span><spanclass="hl-1"> })) {</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// The execution of this inner block is synchronous and it</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// processes one event at a time (even with await). Do not use</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// if concurrent execution is required.</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-5">event</span><spanclass="hl-1">); </span><spanclass="hl-6">// prints ['bar'] [42]</span><br/><spanclass="hl-1"> }</span><br/><spanclass="hl-1"></span><spanclass="hl-6">// Unreachable here</span><br/><spanclass="hl-1">})();</span><br/><br/><spanclass="hl-5">process</span><spanclass="hl-1">.</span><spanclass="hl-0">nextTick</span><spanclass="hl-1">(() </span><spanclass="hl-2">=></span><spanclass="hl-1"></span><spanclass="hl-5">ac</span><spanclass="hl-1">.</span><spanclass="hl-0">abort</span><spanclass="hl-1">());</span>
</code><buttontype="button">Copy</button></pre>
<p>Use the <code>close</code> option to specify an array of event names that will end the iteration:</p>
<pre><codeclass="js"><spanclass="hl-4">import</span><spanclass="hl-1"> { </span><spanclass="hl-5">on</span><spanclass="hl-1">, </span><spanclass="hl-5">EventEmitter</span><spanclass="hl-1"> } </span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:events'</span><spanclass="hl-1">;</span><br/><spanclass="hl-4">import</span><spanclass="hl-1"></span><spanclass="hl-5">process</span><spanclass="hl-1"></span><spanclass="hl-4">from</span><spanclass="hl-1"></span><spanclass="hl-3">'node:process'</span><spanclass="hl-1">;</span><br/><br/><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">ee</span><spanclass="hl-1"> = </span><spanclass="hl-2">new</span><spanclass="hl-1"></span><spanclass="hl-0">EventEmitter</span><spanclass="hl-1">();</span><br/><br/><spanclass="hl-6">// Emit later on</span><br/><spanclass="hl-5">process</span><spanclass="hl-1">.</span><spanclass="hl-0">nextTick</span><spanclass="hl-1">(() </span><spanclass="hl-2">=></span><spanclass="hl-1"> {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-3">'bar'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, </span><spanclass="hl-9">42</span><spanclass="hl-1">);</span><br/><spanclass="hl-1"></span><spanclass="hl-5">ee</span><spanclass="hl-1">.</span><spanclass="hl-0">emit</span><spanclass="hl-1">(</span><spanclass="hl-3">'close'</span><spanclass="hl-1">);</span><br/><spanclass="hl-1">});</span><br/><br/><spanclass="hl-4">for</span><spanclass="hl-1"></span><spanclass="hl-4">await</span><spanclass="hl-1"> (</span><spanclass="hl-2">const</span><spanclass="hl-1"></span><spanclass="hl-7">event</span><spanclass="hl-1"></span><spanclass="hl-2">of</span><spanclass="hl-1"></span><spanclass="hl-0">on</span><spanclass="hl-1">(</span><spanclass="hl-5">ee</span><spanclass="hl-1">, </span><spanclass="hl-3">'foo'</span><spanclass="hl-1">, { </span><spanclass="hl-5">close:</span><spanclass="hl-1"> [</span><spanclass="hl-3">'close'</span><spanclass="hl-1">] })) {</span><br/><spanclass="hl-1"></span><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-5">event</span><spanclass="hl-1">); </span><spanclass="hl-6">// prints ['bar'] [42]</span><br/><spanclass="hl-1">}</span><br/><spanclass="hl-6">// the loop will exit after 'close' is emitted</span><br/><spanclass="hl-5">console</span><spanclass="hl-1">.</span><spanclass="hl-0">log</span><spanclass="hl-1">(</span><spanclass="hl-3">'done'</span><spanclass="hl-1">); </span><spanclass="hl-6">// prints 'done'</span>
</div><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><span><spanclass="tsd-kind-parameter">emitter</span>: <spanclass="tsd-signature-type">EventTarget</span></span></li><li><span><spanclass="tsd-kind-parameter">eventName</span>: <spanclass="tsd-signature-type">string</span></span></li><li><span><codeclass="tsd-tag">Optional</code><spanclass="tsd-kind-parameter">options</span>: <ahref="../interfaces/Backend_Script_API._internal_.StaticEventEmitterIteratorOptions.html"class="tsd-signature-type tsd-kind-interface">StaticEventEmitterIteratorOptions</a></span></li></ul></div><h4class="tsd-returns-title">Returns <spanclass="tsd-signature-type">AsyncIterator</span><spanclass="tsd-signature-symbol"><</span><spanclass="tsd-signature-type">any</span><spanclass="tsd-signature-symbol">[]</span><spanclass="tsd-signature-symbol">></span></h4><p>An <code>AsyncIterator</code> that iterates <code>eventName</code> events emitted by the <code>emitter</code></p>
</div></div><asideclass="tsd-sources"><p>Inherited from NodeJS.EventEmitter.on</p><ul><li>Defined in node_modules/@types/node/events.d.ts:308</li></ul></aside></div></li></ul></section><sectionclass="tsd-panel tsd-member tsd-is-inherited tsd-is-external"><h3class="tsd-anchor-link"id="once-2"><codeclass="tsd-tag">Static</code><span>once</span><ahref="#once-2"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ulclass="tsd-signatures tsd-is-inherited tsd-is-external"><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="once-3"><spanclass="tsd-kind-call-signature">once</span><spanclass="tsd-signature-symbol">(</span><br/><spanclass="tsd-kind-parameter">emitter</span><spanclass="tsd-signature-symbol">:</span><ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html"class="tsd-signature-type tsd-kind-interface">EventEmitter</a><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">string</span><spanclass="tsd-signature-symbol">|</span><spanclass="tsd-signature-type">symbol</span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-kind-parameter">options</span><spanclass="tsd-signature-symbol">?:</span><ahref="../interfaces/Backend_Script_API._internal_.StaticEventEmitterOptions.html"class="tsd-signature-type tsd-kind-interface">StaticEventEmitterOptions</a><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">Promise</span><spanclass="tsd-signature-symbol"><</span><spanclass="tsd-signature-type">any</span><spanclass="tsd-signature-symbol">[]</span><spanclass="tsd-signature-symbol">></span><ahref="#once-3"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Creates a <code>Promise</code> that is fulfilled when the <code>EventEmitter</code> emits the given
event or that is rejected if the <code>EventEmitter</code> emits <code>'error'</code> while waiting.
The <code>Promise</code> will resolve with an array of all the arguments emitted to the
given event.</p>
<p>This method is intentionally generic and works with the web platform <ahref="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a> interface, which has no special<code>'error'</code> event
semantics and does not listen to the <code>'error'</code> event.</p>
<p>The special handling of the <code>'error'</code> event is only used when <code>events.once()</code> is used to wait for another event. If <code>events.once()</code> is used to wait for the
'<code>error'</code> event itself, then it is treated as any other kind of event without
</div></div><asideclass="tsd-sources"><p>Inherited from NodeJS.EventEmitter.once</p><ul><li>Defined in node_modules/@types/node/events.d.ts:217</li></ul></aside></div></li><liclass="tsd-is-inherited tsd-is-external"><divclass="tsd-signature tsd-anchor-link"id="once-4"><spanclass="tsd-kind-call-signature">once</span><spanclass="tsd-signature-symbol">(</span><br/><spanclass="tsd-kind-parameter">emitter</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">EventTarget</span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-kind-parameter">eventName</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">string</span><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-kind-parameter">options</span><spanclass="tsd-signature-symbol">?:</span><ahref="../interfaces/Backend_Script_API._internal_.StaticEventEmitterOptions.html"class="tsd-signature-type tsd-kind-interface">StaticEventEmitterOptions</a><spanclass="tsd-signature-symbol">,</span><br/><spanclass="tsd-signature-symbol">)</span><spanclass="tsd-signature-symbol">:</span><spanclass="tsd-signature-type">Promise</span><spanclass="tsd-signature-symbol"><</span><spanclass="tsd-signature-type">any</span><spanclass="tsd-signature-symbol">[]</span><spanclass="tsd-signature-symbol">></span><ahref="#once-4"aria-label="Permalink"class="tsd-anchor-icon"><svgviewBox="0 0 24 24"aria-hidden="true"><usehref="../assets/icons.svg#icon-anchor"></use></svg></a></div><divclass="tsd-description"><divclass="tsd-comment tsd-typography"><p>Creates a <code>Promise</code> that is fulfilled when the <code>EventEmitter</code> emits the given
event or that is rejected if the <code>EventEmitter</code> emits <code>'error'</code> while waiting.
The <code>Promise</code> will resolve with an array of all the arguments emitted to the
given event.</p>
<p>This method is intentionally generic and works with the web platform <ahref="https://dom.spec.whatwg.org/#interface-eventtarget">EventTarget</a> interface, which has no special<code>'error'</code> event
semantics and does not listen to the <code>'error'</code> event.</p>
<p>The special handling of the <code>'error'</code> event is only used when <code>events.once()</code> is used to wait for another event. If <code>events.once()</code> is used to wait for the
'<code>error'</code> event itself, then it is treated as any other kind of event without
</div><divclass="tsd-parameters"><h4class="tsd-parameters-title">Parameters</h4><ulclass="tsd-parameter-list"><li><span><codeclass="tsd-tag">Optional</code><spanclass="tsd-kind-parameter">n</span>: <spanclass="tsd-signature-type">number</span></span><divclass="tsd-comment tsd-typography"><p>A non-negative number. The maximum number of listeners per <code>EventTarget</code> event.</p>
</div><divclass="tsd-comment tsd-typography"></div></li><li><span><spanclass="tsd-signature-symbol">...</span><spanclass="tsd-kind-parameter">eventTargets</span>: (<spanclass="tsd-signature-type">EventTarget</span><spanclass="tsd-signature-symbol">|</span><ahref="../interfaces/Backend_Script_API._internal_.EventEmitter.html"class="tsd-signature-type tsd-kind-interface">EventEmitter</a><spanclass="tsd-signature-symbol"><</span><ahref="../types/Backend_Script_API._internal_.DefaultEventMap.html"class="tsd-signature-type tsd-kind-type-alias">DefaultEventMap</a><spanclass="tsd-signature-symbol">></span>)<spanclass="tsd-signature-symbol">[]</span></span><divclass="tsd-comment tsd-typography"><p>Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, <code>n</code> is set as the default max for all newly created {EventTarget} and {EventEmitter}