Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eventemitter2

Package Overview
Dependencies
Maintainers
2
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventemitter2 - npm Package Compare versions

Comparing version 6.4.8 to 6.4.9

43

eventemitter2.d.ts
export type event = (symbol|string);
export type eventNS = string|event[];
export type typeSafeEvents = {
[key: event]: (...args: any[]) => void
}

@@ -124,60 +121,28 @@ export interface ConstructorOptions {

export declare class EventEmitter2<TypeSafeEvents extends typeSafeEvents = { [key: event]: (...args: any[]) => void }> {
export declare class EventEmitter2 {
constructor(options?: ConstructorOptions)
emit<Event extends keyof TypeSafeEvents>(event: Event | Event[], ...values: Parameters<TypeSafeEvents[Event]>): boolean;
emitAsync<Event extends keyof TypeSafeEvents>(event: Event | Event[], ...values: Parameters<TypeSafeEvents[Event]>): Promise<any[]>;
addListener<Event extends keyof TypeSafeEvents>(event: Event | Event, listener: TypeSafeEvents[Event]): this|Listener;
emit(event: event | eventNS, ...values: any[]): boolean;
emitAsync(event: event | eventNS, ...values: any[]): Promise<any[]>;
addListener(event: event | eventNS, listener: ListenerFn): this|Listener;
on<Event extends keyof TypeSafeEvents>(event: Event | Event, listener: TypeSafeEvents[Event]): this|Listener;
on(event: event | eventNS, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
prependListener<Event extends keyof TypeSafeEvents>(event: Event | Event, listener: TypeSafeEvents[Event], options?: boolean|OnOptions): this|Listener;
prependListener(event: event | eventNS, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
once<Event extends keyof TypeSafeEvents>(event: Event | Event, listener: TypeSafeEvents[Event], options?: true|OnOptions): this|Listener;
once(event: event | eventNS, listener: ListenerFn, options?: true|OnOptions): this|Listener;
prependOnceListener<Event extends keyof TypeSafeEvents>(event: Event | Event, listener: TypeSafeEvents[Event], options?: boolean|OnOptions): this|Listener;
prependOnceListener(event: event | eventNS, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
many<Event extends keyof TypeSafeEvents>(event: Event | Event, timesToListen: number, listener: TypeSafeEvents[Event], options?: boolean|OnOptions): this|Listener;
many(event: event | eventNS, timesToListen: number, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
prependMany<Event extends keyof TypeSafeEvents>(event: Event | Event, timesToListen: number, listener: TypeSafeEvents[Event], options?: boolean|OnOptions): this|Listener;
prependMany(event: event | eventNS, timesToListen: number, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
onAny(listener: EventAndListener): this;
prependAny(listener: EventAndListener): this;
offAny(listener: ListenerFn): this;
removeListener<Event extends keyof TypeSafeEvents>(event: Event | Event, listener: TypeSafeEvents[Event]): this;
removeListener(event: event | eventNS, listener: ListenerFn): this;
off<Event extends keyof TypeSafeEvents>(event: Event | Event, listener: TypeSafeEvents[Event]): this;
off(event: event | eventNS, listener: ListenerFn): this;
removeAllListeners<Event extends keyof TypeSafeEvents>(event?: Event | Event[] | eventNS): this;
removeAllListeners(event?: event | eventNS): this;
setMaxListeners(n: number): void;
getMaxListeners(): number;
eventNames(nsAsArray?: boolean): (event|eventNS)[];
listenerCount<Event extends keyof TypeSafeEvents>(event?: Event | Event[]): number
listenerCount(event?: event | eventNS): number
listeners<Event extends keyof TypeSafeEvents>(event?: Event): Array<TypeSafeEvents[Event]>
listeners(event?: event | eventNS): ListenerFn[]
listenersAny(): ListenerFn[]
waitFor<Event extends keyof TypeSafeEvents>(event: Event, timeout?: number): CancelablePromise<any[]>
waitFor(event: event | eventNS, timeout?: number): CancelablePromise<any[]>
waitFor<Event extends keyof TypeSafeEvents>(event: Event, filter?: WaitForFilter): CancelablePromise<any[]>
waitFor(event: event | eventNS, filter?: WaitForFilter): CancelablePromise<any[]>
waitFor<Event extends keyof TypeSafeEvents>(event: Event, options?: WaitForOptions): CancelablePromise<any[]>
waitFor(event: event | eventNS, options?: WaitForOptions): CancelablePromise<any[]>
listenTo(target: GeneralEventEmitter, events: event | eventNS, options?: ListenToOptions): this;

@@ -184,0 +149,0 @@ listenTo(target: GeneralEventEmitter, events: event[], options?: ListenToOptions): this;

2

package.json
{
"name": "eventemitter2",
"version": "6.4.8",
"version": "6.4.9",
"description": "A feature-rich Node.js event emitter implementation with namespaces, wildcards, TTL, async listeners and browser/worker support.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -810,23 +810,1 @@ [![Build Status](https://travis-ci.org/EventEmitter2/EventEmitter2.svg?branch=master)](https://travis-ci.org/EventEmitter2/EventEmitter2)

Sets default max listeners count globally for all instances, including those created before the change is made.
### Strongly typed events
For using strongly type events (_available only in `TypeScript`_) you can create a new `EventEmitter` instance like this:
```ts
import EventEmitter2 from "eventemitter2";
type events = {
error: (err: Error) => void
message: (sender: string, msg: string) => void
}
const emitter = new EventEmitter2<events>()
// Ok
emitter.emit("error", new Error("example"))
emitter.emit("message", "someone", "hello")
// TypeScript catches mistakes
emitter.emit("error", true)
emitter.emit("message", 1, "hello")
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc