mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #28056 from nju33/nanoevents
Add type definitions for nanoevents
This commit is contained in:
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Type definitions for nanoevents 1.0
|
||||
// Project: https://github.com/ai/nanoevents#readme
|
||||
// Definitions by: nju33 <https://github.com/nju33>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
declare function unbind(): void;
|
||||
|
||||
declare class NanoEvents<T extends object> {
|
||||
on<U extends keyof T>(name: U, callBack: (arg: T[U]) => any): typeof unbind;
|
||||
emit<U extends keyof T>(name: U, value: T[U]): void;
|
||||
}
|
||||
|
||||
export = NanoEvents;
|
||||
@@ -0,0 +1,8 @@
|
||||
import NanoEvents = require('nanoevents');
|
||||
import unbindAll = require('nanoevents/unbind-all');
|
||||
|
||||
const emitter = new NanoEvents<{foo: {foo: string}, bar: {bar: string}}>();
|
||||
const unbind = emitter.on('foo', action => action.foo);
|
||||
emitter.emit('bar', {bar: 'test'});
|
||||
unbind();
|
||||
unbindAll(emitter);
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"nanoevents-tests.ts",
|
||||
"unbind-all.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import NanoEmitter = require('.');
|
||||
|
||||
declare function unbindAll(emitter: NanoEmitter<any>): void;
|
||||
|
||||
export = unbindAll;
|
||||
Reference in New Issue
Block a user