diff --git a/types/stream-to-string/index.d.ts b/types/stream-to-string/index.d.ts new file mode 100644 index 0000000000..7bb071b663 --- /dev/null +++ b/types/stream-to-string/index.d.ts @@ -0,0 +1,17 @@ +// 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; + +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" }