From 3ee44a1fedd5bd80235385f24d1149f29425f203 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Mon, 19 Nov 2018 20:44:56 +0100 Subject: [PATCH 1/2] Add types for stream-to-string --- types/stream-to-string/index.d.ts | 20 ++++++++++++++++ .../stream-to-string-tests.ts | 15 ++++++++++++ types/stream-to-string/tsconfig.json | 23 +++++++++++++++++++ types/stream-to-string/tslint.json | 1 + 4 files changed, 59 insertions(+) create mode 100644 types/stream-to-string/index.d.ts create mode 100644 types/stream-to-string/stream-to-string-tests.ts create mode 100644 types/stream-to-string/tsconfig.json create mode 100644 types/stream-to-string/tslint.json diff --git a/types/stream-to-string/index.d.ts b/types/stream-to-string/index.d.ts new file mode 100644 index 0000000000..89df48b3ff --- /dev/null +++ b/types/stream-to-string/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for stream-to-string 1.1 +// Project: https://github.com/jasonpincin/stream-to-string +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = streamToString; + +// tslint:disable:unified-signatures + +declare function streamToString(stream: NodeJS.ReadableStream): Promise; +declare function streamToString(stream: NodeJS.ReadableStream, cb: Callback): Promise; +declare function streamToString( + stream: NodeJS.ReadableStream, + enc: string, + cb?: Callback +): Promise; + +type Callback = (error: Error | undefined, str: string) => void; diff --git a/types/stream-to-string/stream-to-string-tests.ts b/types/stream-to-string/stream-to-string-tests.ts new file mode 100644 index 0000000000..3d601a53db --- /dev/null +++ b/types/stream-to-string/stream-to-string-tests.ts @@ -0,0 +1,15 @@ +import streamToString = require("stream-to-string"); + +const stream = (null as any) as NodeJS.ReadableStream; +let convertedString: Promise; + +convertedString = streamToString(stream); +convertedString = streamToString(stream, "hex"); +streamToString(stream, (err, msg) => { + const e: Error | undefined = err; + const str: string = msg; +}); +streamToString(stream, "hex", (err, msg) => { + const e: Error | undefined = err; + const str: string = msg; +}); diff --git a/types/stream-to-string/tsconfig.json b/types/stream-to-string/tsconfig.json new file mode 100644 index 0000000000..81628c9480 --- /dev/null +++ b/types/stream-to-string/tsconfig.json @@ -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", + "stream-to-string-tests.ts" + ] +} diff --git a/types/stream-to-string/tslint.json b/types/stream-to-string/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/stream-to-string/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From f47bf09aa0ea90302508c7a33290091402d87d25 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Wed, 21 Nov 2018 18:54:35 +0100 Subject: [PATCH 2/2] fix review issues --- types/stream-to-string/index.d.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/types/stream-to-string/index.d.ts b/types/stream-to-string/index.d.ts index 89df48b3ff..7bb071b663 100644 --- a/types/stream-to-string/index.d.ts +++ b/types/stream-to-string/index.d.ts @@ -7,10 +7,7 @@ export = streamToString; -// tslint:disable:unified-signatures - -declare function streamToString(stream: NodeJS.ReadableStream): Promise; -declare function streamToString(stream: NodeJS.ReadableStream, cb: Callback): Promise; +declare function streamToString(stream: NodeJS.ReadableStream, cb?: Callback): Promise; declare function streamToString( stream: NodeJS.ReadableStream, enc: string,