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

eventemitter3

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventemitter3 - npm Package Compare versions

Comparing version 3.1.2 to 4.0.0

31

index.d.ts

@@ -0,1 +1,4 @@

type EventNames<T extends string | symbol | { [K in string | symbol]: any[] }> = T extends string | symbol ? T : keyof T;
type EventArgs<T extends string | symbol | { [K in string | symbol]: any[] }, K extends EventNames<T>> = T extends string | symbol ? any[] : K extends keyof T ? T[K] : never;
/**

@@ -5,3 +8,3 @@ * Minimal `EventEmitter` interface that is molded against the Node.js

*/
declare class EventEmitter<EventTypes extends string | symbol = string | symbol> {
declare class EventEmitter<EventTypes extends string | symbol | { [K in keyof EventTypes]: any[] } = string | symbol> {
static prefixed: string | boolean;

@@ -13,3 +16,3 @@

*/
eventNames(): Array<EventTypes>;
eventNames(): Array<EventNames<EventTypes>>;

@@ -19,3 +22,3 @@ /**

*/
listeners(event: EventTypes): Array<EventEmitter.ListenerFn>;
listeners<T extends EventNames<EventTypes>>(event: T): Array<EventEmitter.ListenerFn<EventArgs<EventTypes, T>>>;

@@ -25,3 +28,3 @@ /**

*/
listenerCount(event: EventTypes): number;
listenerCount(event: EventNames<EventTypes>): number;

@@ -31,3 +34,3 @@ /**

*/
emit(event: EventTypes, ...args: Array<any>): boolean;
emit<T extends EventNames<EventTypes>>(event: T, ...args: EventArgs<EventTypes, T>): boolean;

@@ -37,4 +40,4 @@ /**

*/
on(event: EventTypes, fn: EventEmitter.ListenerFn, context?: any): this;
addListener(event: EventTypes, fn: EventEmitter.ListenerFn, context?: any): this;
on<T extends EventNames<EventTypes>>(event: T, fn: EventEmitter.ListenerFn<EventArgs<EventTypes, T>>, context?: any): this;
addListener<T extends EventNames<EventTypes>>(event: T, fn: EventEmitter.ListenerFn<EventArgs<EventTypes, T>>, context?: any): this;

@@ -44,3 +47,3 @@ /**

*/
once(event: EventTypes, fn: EventEmitter.ListenerFn, context?: any): this;
once<T extends EventNames<EventTypes>>(event: T, fn: EventEmitter.ListenerFn<EventArgs<EventTypes, T>>, context?: any): this;

@@ -50,4 +53,4 @@ /**

*/
removeListener(event: EventTypes, fn?: EventEmitter.ListenerFn, context?: any, once?: boolean): this;
off(event: EventTypes, fn?: EventEmitter.ListenerFn, context?: any, once?: boolean): this;
removeListener<T extends EventNames<EventTypes>>(event: T, fn?: EventEmitter.ListenerFn<EventArgs<EventTypes, T>>, context?: any, once?: boolean): this;
off<T extends EventNames<EventTypes>>(event: T, fn?: EventEmitter.ListenerFn<EventArgs<EventTypes, T>>, context?: any, once?: boolean): this;

@@ -57,12 +60,12 @@ /**

*/
removeAllListeners(event?: EventTypes): this;
removeAllListeners(event?: EventNames<EventTypes>): this;
}
declare namespace EventEmitter {
export interface ListenerFn {
(...args: Array<any>): void;
export interface ListenerFn<Args extends any[] = any[]> {
(...args: Args): void;
}
export interface EventEmitterStatic {
new<EventTypes extends string | symbol = string | symbol>(): EventEmitter<EventTypes>;
new<EventTypes extends string | symbol | { [K in keyof EventTypes]: any[] } = string | symbol>(): EventEmitter<EventTypes>;
}

@@ -69,0 +72,0 @@

{
"name": "eventemitter3",
"version": "3.1.2",
"version": "4.0.0",
"description": "EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.",

@@ -50,8 +50,8 @@ "main": "index.js",

"mocha": "~6.1.0",
"nyc": "~14.0.0",
"nyc": "~14.1.0",
"pre-commit": "~1.2.0",
"sauce-browsers": "~2.0.0",
"sauce-test": "~1.3.3",
"uglify-js": "~3.5.0"
"uglify-js": "~3.6.0"
}
}
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