11package io .scalajs .nodejs .events
22
33import com .thoughtworks .enableIf
4+ import net .exoego .scalajs .types .util .Factory
45
56import scala .scalajs .js
67import scala .scalajs .js .annotation .JSImport
@@ -15,7 +16,22 @@ import scala.scalajs.js.annotation.JSImport
1516 */
1617@ js.native
1718@ JSImport (" events" , " EventEmitter" )
18- class EventEmitter extends IEventEmitter
19+ class EventEmitter () extends IEventEmitter {
20+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
21+ def this (options : EventEmitterOptions ) = this ()
22+ }
23+
24+ @ Factory
25+ trait EventEmitterOptions extends js.Object {
26+
27+ /** It enables automatic capturing of promise rejection.
28+ * Default: false.
29+ *
30+ * Experimental !
31+ */
32+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
33+ var captureRejections : Boolean
34+ }
1935
2036/**
2137 * EventEmitter Interface
@@ -148,8 +164,29 @@ object EventEmitter extends js.Object {
148164 */
149165 var defaultMaxListeners : Int = js.native
150166
167+ /** Change the default captureRejections option on all new EventEmitter objects.
168+ *
169+ * experimental!
170+ */
171+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
172+ var captureRejections : Boolean = js.native
173+
174+ /** experimental! */
175+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
176+ var captureRejectionSymbol : js.Symbol = js.native
177+
151178 @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
152179 def once (emitter : IEventEmitter , eventName : String ): js.Promise [js.Array [js.Any ]] = js.native
180+ // TODO: Return AsyncIterator
181+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
182+ def on (emitter : IEventEmitter , eventName : String ): js.Any = js.native
183+
184+ // TODO: Return AsyncIterator
185+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
186+ def on (emitter : IEventEmitter , eventName : js.Symbol ): js.Any = js.native
187+
188+ @ enableIf(io.scalajs.nodejs.internal.CompilerSwitches .gteNodeJs12)
189+ var errorMonitor : js.Symbol = js.native
153190}
154191
155192@ js.native
0 commit comments