s3rver: make error optional in callback signature (#40974)

* s3rver: make error potentially null in callback signature

* s3rver: returns itself when run is called with a callback

* Add signature for close method
This commit is contained in:
Retsam
2019-12-26 14:50:34 -05:00
committed by Andrew Branch
parent 1fda2b2e92
commit dfd4a7a859
2 changed files with 6 additions and 4 deletions

View File

@@ -7,9 +7,6 @@
/// <reference types="node" />
import * as http from "http";
declare class S3rver {
constructor(options: S3rverOptions)
setPort(port: number): S3rver;
@@ -18,8 +15,12 @@ declare class S3rver {
setSilent(silent: boolean): S3rver;
setIndexDocument(indexDocument: string): S3rver;
setErrorDocument(errorDocument: string): S3rver;
run(callback: (error: Error, hostname: string, port: number, directory: string) => void): http.Server;
run(callback: (error: Error | null, hostname: string, port: number, directory: string) => void): S3rver;
run(): Promise<string>;
close(): Promise<void>;
// Should return S3rver, but doesn't in all cases, currently
// See https://github.com/jamhall/s3rver/pull/571
close(callback: (error: Error | null) => void): void;
}
interface S3rverOptions {

View File

@@ -10,6 +10,7 @@ var s3rver = new S3rver({
}).run((err, hostname, port, directory) => {});
s3rver.close();
s3rver.close(e => console.log(e));
// using new options
import fs = require('fs');