nanoevents
Advanced tools
Comparing version 5.1.8 to 5.1.9
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 5.1.9 | ||
* Add `package.types`. | ||
## 5.1.8 | ||
@@ -5,0 +8,0 @@ * Fix ES module support. |
{ | ||
"name": "nanoevents", | ||
"version": "5.1.8", | ||
"version": "5.1.9", | ||
"description": "Simple and tiny (72 bytes) event emitter library", | ||
@@ -23,2 +23,3 @@ "keywords": [ | ||
"sideEffects": false, | ||
"types": "index.d.ts", | ||
"type": "module", | ||
@@ -29,8 +30,10 @@ "main": "index.cjs", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"require": "./index.cjs", | ||
"import": "./index.js" | ||
} | ||
"import": "./index.js", | ||
"types": "index.d.ts" | ||
}, | ||
"./package.json": "./package.json", | ||
"index.d.ts": "index.d.ts" | ||
} | ||
} |
@@ -41,2 +41,3 @@ # Nano Events | ||
* [Install](#install) | ||
* [TypeScript](#typescript) | ||
@@ -52,2 +53,9 @@ * [Mixing to Object](#mixing-to-object) | ||
## Install | ||
```sh | ||
npm install nanoevents | ||
``` | ||
## TypeScript | ||
@@ -102,3 +110,25 @@ | ||
With Typescript: | ||
```ts | ||
import { createNanoEvents, Emitter } from "nanoevents" | ||
interface Events { | ||
start: (startedAt: number) => void | ||
} | ||
class Ticker { | ||
emitter: Emitter | ||
constructor () { | ||
this.emitter = createNanoEvents<Events>() | ||
} | ||
on<E extends keyof Events>(event: E, callback: Events[E]) { | ||
return this.emitter.on(event, callback) | ||
} | ||
} | ||
``` | ||
## Add Listener | ||
@@ -105,0 +135,0 @@ |
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
10617
239