typed-emitter
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -1,2 +0,2 @@ | ||
type Arguments<T> = [T] extends [(...args: infer U) => any] | ||
export type Arguments<T> = [T] extends [(...args: infer U) => any] | ||
? U | ||
@@ -3,0 +3,0 @@ : [T] extends [void] ? [] : [T] |
{ | ||
"name": "typed-emitter", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Strictly typed event emitter interface for TypeScript 3.", |
@@ -13,6 +13,6 @@ # Typed-Emitter | ||
```sh | ||
$ npm install typed-emitter | ||
$ npm install --save-dev typed-emitter | ||
# Using yarn: | ||
$ yarn add typed-emitter | ||
$ yarn add --dev typed-emitter | ||
``` | ||
@@ -51,2 +51,20 @@ | ||
## Extending an emitter | ||
You might find yourself in a situation where you need to extend an event emitter, but also want to strictly type its events. Here is how to. | ||
```ts | ||
class MyEventEmitter extends (EventEmitter as new () => TypedEmitter<MyEvents>) { | ||
// ... | ||
} | ||
``` | ||
As a generic class: | ||
```ts | ||
class MyEventEmitter<T> extends (EventEmitter as { new<T>(): TypedEmitter<T> })<T> { | ||
// ... | ||
} | ||
``` | ||
## Why another package? | ||
@@ -60,5 +78,4 @@ | ||
## License | ||
MIT |
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
5312
79