@for-fun/event-emitter
Advanced tools
Comparing version 0.1.4 to 1.0.0
/*! | ||
* @for-fun/event-emitter v0.1.4 (https://github.com/wmzy/event-emitter) | ||
* @for-fun/event-emitter v1.0.0 (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) |
@@ -13,10 +13,8 @@ export const errorEvent: symbol; | ||
type Param<T extends ET, K extends Key<T>> = K extends 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 EventEmitter<T extends ET = [EventType, any[]]> = { | ||
[s]: T | ||
}; | ||
@@ -28,8 +26,8 @@ | ||
export function create<T extends ET>(): EventEmitter<T>; | ||
export function emit<E extends EventEmitter<any>, K extends keyof E[S]>(ee: E, key: K, ...args: E[S][K]): void; | ||
export function create<T extends ET = [any, any[]]>(): EventEmitter<T>; | ||
export function emit<E extends EventEmitter<any>, const K extends Key<E[S]>>(ee: E, key: K, ...args: Param<E[S], K>): void; | ||
export function emitError(ee: EventEmitter<any>, err: Error): void; | ||
export function on<E extends EventEmitter<any>, K extends keyof E[S]>(ee: E, key: K, handler: Handler<E[S][K]>): OffFunction; | ||
export function on<E extends EventEmitter<any>, const K extends Key<E[S]>>(ee: E, key: K, handler: Handler<Param<E[S], K>>): OffFunction; | ||
export function onError(ee: EventEmitter<any>, handler: ErrorHandler): OffFunction; | ||
export function once<E extends EventEmitter<any>, K extends keyof E[S]>(ee: E, key: K, handler: Handler<E[S][K]>): OffFunction; | ||
export function once<E extends EventEmitter<any>, const K extends Key<E[S]>>(ee: E, key: K, handler: Handler<Param<E[S], K>>): OffFunction; | ||
export function onceError(ee: EventEmitter<any>, handler: ErrorHandler): OffFunction; | ||
@@ -39,9 +37,9 @@ | ||
export function createAndBind<T extends ET>(): { | ||
emit<K extends keyof EventEmitter<T>[S]>(key: K, ...args: EventEmitter<T>[S][K]): void; | ||
export function createAndBind<T extends ET = [any, any[]]>(): { | ||
emit<const K extends Key<T>>(key: K, ...args: Param<T>, K): void; | ||
emitError(err: Error): void; | ||
on<K extends keyof EventEmitter<T>[S]>(key: K, handler: Handler<EventEmitter<T>[S][K]>): OffFunction; | ||
on<const K extends Key<T>>(key: K, handler: Handler<Param<T, K>>): OffFunction; | ||
onError(handler: ErrorHandler): OffFunction; | ||
once<K extends keyof EventEmitter<T>[S]>(key: K, handler: Handler<EventEmitter<T>[S][K]>): OffFunction; | ||
once<const K extends Key<T>>(key: K, handler: Handler<Param<T, K>>): OffFunction; | ||
onceError(handler: ErrorHandler): OffFunction; | ||
}; |
{ | ||
"name": "@for-fun/event-emitter", | ||
"version": "0.1.4", | ||
"version": "1.0.0", | ||
"description": "event-emitter", | ||
@@ -39,30 +39,30 @@ "main": "dist/event-emitter.cjs.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.20.5", | ||
"@babel/eslint-parser": "^7.19.1", | ||
"@babel/preset-env": "^7.20.2", | ||
"@babel/register": "^7.18.9", | ||
"@babel/core": "^7.22.8", | ||
"@babel/eslint-parser": "^7.22.7", | ||
"@babel/preset-env": "^7.22.7", | ||
"@babel/register": "^7.22.5", | ||
"@rollup/plugin-babel": "^6.0.3", | ||
"@rollup/plugin-terser": "^0.2.0", | ||
"commitizen": "^4.2.6", | ||
"@rollup/plugin-terser": "^0.4.3", | ||
"commitizen": "^4.3.0", | ||
"coveralls": "^3.1.1", | ||
"cross-env": "^7.0.3", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"eslint": "^8.29.0", | ||
"eslint": "^8.44.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-compat": "^4.0.2", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-compat": "^4.1.4", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-mocha": "^10.1.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"husky": "^8.0.2", | ||
"lint-staged": "^13.1.0", | ||
"mocha": "^10.1.0", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^13.2.3", | ||
"mocha": "^10.2.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.8.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^3.6.0", | ||
"prettier": "^3.0.0", | ||
"rimraf": "^5.0.1", | ||
"rollup": "^3.26.2", | ||
"should": "^13.2.3", | ||
"should-sinon": "0.0.6", | ||
"sinon": "^15.0.0", | ||
"typescript": "^4.9.4" | ||
"sinon": "^15.2.0", | ||
"typescript": "^5.1.6" | ||
}, | ||
@@ -69,0 +69,0 @@ "lint-staged": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
28391
0
264