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

@for-fun/event-emitter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@for-fun/event-emitter - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

2

dist/event-emitter.umd.min.js
/*!
* @for-fun/event-emitter v0.1.2 (https://github.com/wmzy/event-emitter)
* @for-fun/event-emitter v0.1.3 (https://github.com/wmzy/event-emitter)
* Copyright (c) 2019-present wmzy

@@ -4,0 +4,0 @@ * Licensed under MIT (https://github.com/wmzy/event-emitter/blob/master/LICENSE)

@@ -1,24 +0,44 @@

export type Handler = (...args: unknown[]) => void;
export const errorEvent: symbol;
export type EventType = string | symbol;
declare const s: unique symbol;
type S = typeof s;
type ET = [EventType, any[]] | EventType;
type Key<T extends ET> =
| Extract<T, [EventType, any[]]>[0]
| Extract<T, EventType>;
type Param<T extends ET, K extends Key<T>> = K extends Extract<T, EventType>
? []
: Extract<T, [K, any[]]>[1];
export type EventEmitter<T extends ET> = {
[s]: {
[key in Key<T>]: Param<T, key>;
}
};
export type Handler<P extends any[]> = (...args: P) => void;
export type ErrorHandler = (err: Error) => void;
export type OffFunction = () => void;
export type EventEmitter<K> = Map<K, Set<Handler>>;
export const errorEvent: Symbol;
export function create<K>(): EventEmitter<K>;
export function emit<K>(ee: EventEmitter<K>, key: K, ...args: unknown[]): void;
export function emitError<K>(ee: EventEmitter<K>, err: Error): void;
export function on<K>(ee: EventEmitter<K>, key: K, handler: Handler): OffFunction;
export function onError<K>(ee: EventEmitter<K>, handler: ErrorHandler): OffFunction;
export function once<K>(ee: EventEmitter<K>, key: K, handler: Handler): OffFunction;
export function onceError<K>(ee: EventEmitter<K>, handler: ErrorHandler): OffFunction;
export function create<T extends ET>(): EventEmitter<T>;
export function emit<E extends EventEmitter<ET>, K extends keyof E[S]>(ee: E, key: K, ...args: E[S][K]): void;
export function emitError(ee: EventEmitter<ET>, err: Error): void;
export function on<E extends EventEmitter<ET>, K extends keyof E[S]>(ee: E, key: K, handler: Handler<E[S][K]>): OffFunction;
export function onError(ee: EventEmitter<ET>, handler: ErrorHandler): OffFunction;
export function once<E extends EventEmitter<ET>, K extends keyof E[S]>(ee: E, key: K, handler: Handler<E[S][K]>): OffFunction;
export function onceError(ee: EventEmitter<ET>, handler: ErrorHandler): OffFunction;
export function bindContext(context: any): (func: Function) => Function;
export function createAndBind<K>(): {
emit(key: K, ...args: unknown[]): void;
export function createAndBind<T extends ET>(): {
emit<K extends keyof EventEmitter<T>[S]>(key: K, ...args: EventEmitter<T>[S][K]): void;
emitError(err: Error): void;
on(key: K, handler: Handler): OffFunction;
on<K extends keyof EventEmitter<T>[S]>(key: K, handler: Handler<EventEmitter<T>[S][K]>): OffFunction;
onError(handler: ErrorHandler): OffFunction;
once(key: K, handler: Handler): OffFunction;
once<K extends keyof EventEmitter<T>[S]>(key: K, handler: Handler<EventEmitter<T>[S][K]>): OffFunction;
onceError(handler: ErrorHandler): OffFunction;
};
{
"name": "@for-fun/event-emitter",
"version": "0.1.2",
"version": "0.1.3",
"description": "event-emitter",

@@ -5,0 +5,0 @@ "main": "dist/event-emitter.cjs.js",

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