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 4.0.0 to 4.0.1

83

index.d.ts

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

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;
type ValidEventTypes<T = any> = string | symbol | T extends {
[K in keyof T]: any[] | ((...args: any[]) => void);
}
? T
: never;
type EventNames<T extends ValidEventTypes> = T extends string | symbol
? T
: keyof T;
type Handler<
T extends any[] | ((...args: any[]) => R),
R = any
> = T extends any[] ? (...args: T) => R : T;
type EventListener<
T extends ValidEventTypes,
K extends EventNames<T>
> = T extends string | symbol
? (...args: any[]) => void
: K extends keyof T
? Handler<T[K], void>
: never;
type EventArgs<T extends ValidEventTypes, K extends EventNames<T>> = Parameters<
EventListener<T, K>
>;
/**

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

*/
declare class EventEmitter<EventTypes extends string | symbol | { [K in keyof EventTypes]: any[] } = string | symbol> {
declare class EventEmitter<
EventTypes extends
| string
| symbol
| {}
| { [K in keyof EventTypes]: any[] | ((...args: any[]) => void) } =
| string
| symbol,
Context extends any = any
> {
static prefixed: string | boolean;

@@ -21,3 +55,5 @@

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

@@ -32,3 +68,6 @@ /**

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

@@ -38,4 +77,12 @@ /**

*/
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;
on<T extends EventNames<EventTypes>>(
event: T,
fn: EventListener<EventTypes, T>,
context?: Context
): this;
addListener<T extends EventNames<EventTypes>>(
event: T,
fn: EventListener<EventTypes, T>,
context?: Context
): this;

@@ -45,3 +92,7 @@ /**

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

@@ -51,4 +102,14 @@ /**

*/
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;
removeListener<T extends EventNames<EventTypes>>(
event: T,
fn?: EventListener<EventTypes, T>,
context?: Context,
once?: boolean
): this;
off<T extends EventNames<EventTypes>>(
event: T,
fn?: EventListener<EventTypes, T>,
context?: Context,
once?: boolean
): this;

@@ -67,3 +128,3 @@ /**

export interface EventEmitterStatic {
new<EventTypes extends string | symbol | { [K in keyof EventTypes]: any[] } = string | symbol>(): EventEmitter<EventTypes>;
new <EventTypes extends ValidEventTypes>(): EventEmitter<EventTypes>;
}

@@ -70,0 +131,0 @@

10

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

@@ -48,10 +48,10 @@ "main": "index.js",

"assume": "~2.2.0",
"browserify": "~16.2.0",
"mocha": "~6.1.0",
"nyc": "~14.1.0",
"browserify": "~16.5.0",
"mocha": "~7.1.0",
"nyc": "~15.0.0",
"pre-commit": "~1.2.0",
"sauce-browsers": "~2.0.0",
"sauce-test": "~1.3.3",
"uglify-js": "~3.6.0"
"uglify-js": "~3.9.0"
}
}

@@ -89,2 +89,4 @@ # EventEmitter3

with them you have to clone the GitHub repository.
Note that you will have to run an additional `npm i` in the benchmarks folder
before `npm run benchmark`.

@@ -91,0 +93,0 @@ ## License

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