eventemitter2
- Version 6.4.9
- Published
- 81.3 kB
- No dependencies
- MIT license
Install
npm i eventemitter2
yarn add eventemitter2
pnpm add eventemitter2
Overview
A feature-rich Node.js event emitter implementation with namespaces, wildcards, TTL, async listeners and browser/worker support.
Index
Classes
EventEmitter2
- addListener()
- defaultMaxListeners
- emit()
- emitAsync()
- eventNames()
- getMaxListeners()
- hasListeners()
- listenerCount()
- listeners()
- listenersAny()
- listenTo()
- many()
- off()
- offAny()
- on()
- onAny()
- once()
- prependAny()
- prependListener()
- prependMany()
- prependOnceListener()
- removeAllListeners()
- removeListener()
- setMaxListeners()
- stopListeningTo()
- waitFor()
Interfaces
Type Aliases
Classes
class EventEmitter2
class EventEmitter2 {}
constructor
constructor(options?: ConstructorOptions);
property defaultMaxListeners
static defaultMaxListeners: number;
method addListener
addListener: (event: event | eventNS, listener: ListenerFn) => this | Listener;
method emit
emit: (event: event | eventNS, ...values: any[]) => boolean;
method emitAsync
emitAsync: (event: event | eventNS, ...values: any[]) => Promise<any[]>;
method eventNames
eventNames: (nsAsArray?: boolean) => (event | eventNS)[];
method getMaxListeners
getMaxListeners: () => number;
method hasListeners
hasListeners: (event?: String) => Boolean;
method listenerCount
listenerCount: (event?: event | eventNS) => number;
method listeners
listeners: (event?: event | eventNS) => ListenerFn[];
method listenersAny
listenersAny: () => ListenerFn[];
method listenTo
listenTo: { ( target: GeneralEventEmitter, events: event | eventNS, options?: ListenToOptions ): this; ( target: GeneralEventEmitter, events: event[], options?: ListenToOptions ): this; ( target: GeneralEventEmitter, events: Object, options?: ListenToOptions ): this;};
method many
many: ( event: event | eventNS, timesToListen: number, listener: ListenerFn, options?: boolean | OnOptions) => this | Listener;
method off
off: (event: event | eventNS, listener: ListenerFn) => this;
method offAny
offAny: (listener: ListenerFn) => this;
method on
on: ( event: event | eventNS, listener: ListenerFn, options?: boolean | OnOptions) => this | Listener;
method onAny
onAny: (listener: EventAndListener) => this;
method once
static once: ( emitter: EventEmitter2, event: event | eventNS, options?: OnceOptions) => CancelablePromise<any[]>;
method prependAny
prependAny: (listener: EventAndListener) => this;
method prependListener
prependListener: ( event: event | eventNS, listener: ListenerFn, options?: boolean | OnOptions) => this | Listener;
method prependMany
prependMany: ( event: event | eventNS, timesToListen: number, listener: ListenerFn, options?: boolean | OnOptions) => this | Listener;
method prependOnceListener
prependOnceListener: ( event: event | eventNS, listener: ListenerFn, options?: boolean | OnOptions) => this | Listener;
method removeAllListeners
removeAllListeners: (event?: event | eventNS) => this;
method removeListener
removeListener: (event: event | eventNS, listener: ListenerFn) => this;
method setMaxListeners
setMaxListeners: (n: number) => void;
method stopListeningTo
stopListeningTo: ( target?: GeneralEventEmitter, event?: event | eventNS) => Boolean;
method waitFor
waitFor: { (event: event | eventNS, timeout?: number): CancelablePromise<any[]>; ( event: string | symbol | event[], filter?: WaitForFilter ): CancelablePromise<any[]>; ( event: string | symbol | event[], options?: WaitForOptions ): CancelablePromise<any[]>;};
Interfaces
interface CancelablePromise
interface CancelablePromise<T> extends Promise<T> {}
method cancel
cancel: (reason: string) => undefined;
interface ConstructorOptions
interface ConstructorOptions {}
property delimiter
delimiter?: string;
'.' the delimiter used to segment namespaces.
property ignoreErrors
ignoreErrors?: boolean;
false disable throwing uncaughtException if an error event is emitted and it has no listeners
property maxListeners
maxListeners?: number;
10 the maximum amount of listeners that can be assigned to an event.
property newListener
newListener?: boolean;
false set this to
true
if you want to emit the newListener events.
property removeListener
removeListener?: boolean;
false set this to
true
if you want to emit the removeListener events.
property verboseMemoryLeak
verboseMemoryLeak?: boolean;
false show event name in memory leak message when more than maximum amount of listeners is assigned, default false
property wildcard
wildcard?: boolean;
false set this to
true
to use wildcards.
interface EventAndListener
interface EventAndListener {}
call signature
(event: string | string[], ...values: any[]): void;
interface GeneralEventEmitter
interface GeneralEventEmitter {}
method addEventListener
addEventListener: (event: event, handler: ListenerFn) => this;
method addListener
addListener: (event: event, handler: ListenerFn) => this;
method off
off: (event: event, handler: ListenerFn) => this;
method on
on: (event: event, handler: ListenerFn) => this;
method removeEventListener
removeEventListener: (event: event, handler: ListenerFn) => this;
method removeListener
removeListener: (event: event, handler: ListenerFn) => this;
interface Listener
interface Listener {}
interface ListenerFn
interface ListenerFn {}
call signature
(...values: any[]): void;
interface ListenToOptions
interface ListenToOptions {}
interface OnceOptions
interface OnceOptions {}
interface OnOptions
interface OnOptions {}
interface WaitForFilter
interface WaitForFilter {}
call signature
(...values: any[]): boolean;
interface WaitForOptions
interface WaitForOptions {}
property filter
filter: WaitForFilter;
null
property handleError
handleError: boolean;
false
property overload
overload: boolean;
false
property Promise
Promise: Function;
Promise
property timeout
timeout: number;
0
Type Aliases
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (6)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/eventemitter2
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/eventemitter2)
- HTML<a href="https://www.jsdocs.io/package/eventemitter2"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2054 ms. - Missing or incorrect documentation? Open an issue for this package.