Add declarations for stoppable 1.1

This commit is contained in:
John Plusje
2018-11-26 15:24:11 +01:00
parent 36a32d8a72
commit 9d01bdd867
2 changed files with 14 additions and 6 deletions
+7 -2
View File
@@ -1,11 +1,16 @@
// Type definitions for stoppable 1.0
// Type definitions for stoppable 1.1
// Project: https://github.com/hunterloftis/stoppable
// Definitions by: Eric Byers <https://github.com/EricByers>
// John Plusjé <https://github.com/jplusje>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { Server } from 'http';
declare function stoppable(server: Server, grace?: number): Server;
interface StoppableServer extends Server {
stop(callback?: (e: Error, gracefully: boolean) => void): void;
}
declare function stoppable(server: Server, grace?: number): StoppableServer;
export = stoppable;
+7 -4
View File
@@ -1,8 +1,11 @@
import * as http from 'http';
import stoppable = require('stoppable');
const server: http.Server = stoppable(http.createServer());
server.close();
const server = stoppable(http.createServer());
server.stop();
const server2: http.Server = stoppable(http.createServer(), 10000);
server2.close();
const server2 = stoppable(http.createServer(), 10000);
server2.stop();
const server3 = stoppable(http.createServer());
server.stop((err, gracefully) => {});