Merge pull request #24101 from ahstro/feature/event-emitter-es6

Add types for event-emitter-es6
This commit is contained in:
Armando Aguirre
2018-03-06 15:01:23 -08:00
committed by GitHub
4 changed files with 64 additions and 0 deletions
@@ -0,0 +1,17 @@
import EventEmitter = require("event-emitter-es6");
const ee = new EventEmitter();
const ee1 = new EventEmitter({ emitDelay: 50 });
const ee2 = new EventEmitter({ strictMode: true });
const ee3 = new EventEmitter({ strictMode: false, emitDelay: 5 });
const ee4 = new EventEmitter({});
ee.on("test", () => {});
ee.once("test", () => {});
ee.off("test", () => {});
ee.off("test");
ee.emit("test");
ee.emit("test", 1, 2, 3, "a", "b", "c");
ee.emitSync("test");
ee.emitSync("test", 1, 2, 3, "a", "b", "c");
ee.destroy();
+23
View File
@@ -0,0 +1,23 @@
// Type definitions for event-emitter-es6 1.1
// Project: https://github.com/insane-jo/event-emitter#readme
// Definitions by: Anton Strömkvist <https://github.com/ahstro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Options {
emitDelay?: number;
strictMode?: boolean;
}
type Listener = (...args: any[]) => void;
declare class EventEmitter {
constructor(options?: Options);
on(type: string, listener: Listener): void;
once(type: string, listener: Listener): void;
off(type: string, listener?: Listener): void;
emit(type: string, ...eventArgs: any[]): void;
emitSync(type: string, ...eventArgs: any[]): void;
destroy(): void;
}
export = EventEmitter;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"event-emitter-es6-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }