nanoevents
Advanced tools
Comparing version 7.0.1 to 8.0.0
@@ -13,4 +13,20 @@ interface EventsMap { | ||
export declare class Emitter<Events extends EventsMap = DefaultEvents> { | ||
export interface Emitter<Events extends EventsMap = DefaultEvents> { | ||
/** | ||
* Calls each of the listeners registered for a given event. | ||
* | ||
* ```js | ||
* ee.emit('tick', tickType, tickDuration) | ||
* ``` | ||
* | ||
* @param event The event name. | ||
* @param args The arguments for listeners. | ||
*/ | ||
emit<K extends keyof Events>( | ||
this: this, | ||
event: K, | ||
...args: Parameters<Events[K]> | ||
): void | ||
/** | ||
* Event names in keys and arrays with listeners in values. | ||
@@ -43,18 +59,2 @@ * | ||
on<K extends keyof Events>(this: this, event: K, cb: Events[K]): Unsubscribe | ||
/** | ||
* Calls each of the listeners registered for a given event. | ||
* | ||
* ```js | ||
* ee.emit('tick', tickType, tickDuration) | ||
* ``` | ||
* | ||
* @param event The event name. | ||
* @param args The arguments for listeners. | ||
*/ | ||
emit<K extends keyof Events>( | ||
this: this, | ||
event: K, | ||
...args: Parameters<Events[K]> | ||
): void | ||
} | ||
@@ -61,0 +61,0 @@ |
export let createNanoEvents = () => ({ | ||
events: {}, | ||
emit(event, ...args) { | ||
@@ -9,2 +8,3 @@ let callbacks = this.events[event] || [] | ||
}, | ||
events: {}, | ||
on(event, cb) { | ||
@@ -11,0 +11,0 @@ this.events[event]?.push(cb) || (this.events[event] = [cb]) |
{ | ||
"name": "nanoevents", | ||
"version": "7.0.1", | ||
"description": "Simple and tiny (99 bytes) event emitter library", | ||
"version": "8.0.0", | ||
"description": "Simple and tiny (130 bytes) event emitter library", | ||
"keywords": [ | ||
@@ -20,3 +20,3 @@ "EventEmitter", | ||
"engines": { | ||
"node": "^14.0.0 || ^16.0.0 || >=18.0.0" | ||
"node": "^16.0.0 || ^18.0.0 || >=20.0.0" | ||
}, | ||
@@ -23,0 +23,0 @@ "sideEffects": false, |
@@ -5,5 +5,5 @@ # Nano Events | ||
* Only **99 bytes** (minified and gzipped). | ||
* Only **130 bytes** (minified and gzipped). | ||
It uses [Size Limit] to control size. | ||
* `on` method returns `unbind` function. You don’t need to save | ||
* The `on` method returns `unbind` function. You don’t need to save | ||
callback to variable for `removeListener`. | ||
@@ -41,2 +41,2 @@ * TypeScript and ES modules support. | ||
## Docs | ||
Read **[full docs](https://github.com/ai/nanoevents#readme)** on GitHub. | ||
Read full docs **[here](https://github.com/ai/nanoevents#readme)**. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4768