Skip to content

Commit c8b8c10

Browse files
Merge pull request DefinitelyTyped#30670 from BendingBender/stream-to-string
Add types for stream-to-string
2 parents f7dd44a + f47bf09 commit c8b8c10

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

types/stream-to-string/index.d.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Type definitions for stream-to-string 1.1
2+
// Project: https://github.com/jasonpincin/stream-to-string
3+
// Definitions by: BendingBender <https://github.com/BendingBender>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
6+
/// <reference types="node" />
7+
8+
export = streamToString;
9+
10+
declare function streamToString(stream: NodeJS.ReadableStream, cb?: Callback): Promise<string>;
11+
declare function streamToString(
12+
stream: NodeJS.ReadableStream,
13+
enc: string,
14+
cb?: Callback
15+
): Promise<string>;
16+
17+
type Callback = (error: Error | undefined, str: string) => void;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import streamToString = require("stream-to-string");
2+
3+
const stream = (null as any) as NodeJS.ReadableStream;
4+
let convertedString: Promise<string>;
5+
6+
convertedString = streamToString(stream);
7+
convertedString = streamToString(stream, "hex");
8+
streamToString(stream, (err, msg) => {
9+
const e: Error | undefined = err;
10+
const str: string = msg;
11+
});
12+
streamToString(stream, "hex", (err, msg) => {
13+
const e: Error | undefined = err;
14+
const str: string = msg;
15+
});

types/stream-to-string/tsconfig.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"lib": [
5+
"es6"
6+
],
7+
"noImplicitAny": true,
8+
"noImplicitThis": true,
9+
"strictNullChecks": true,
10+
"strictFunctionTypes": true,
11+
"baseUrl": "../",
12+
"typeRoots": [
13+
"../"
14+
],
15+
"types": [],
16+
"noEmit": true,
17+
"forceConsistentCasingInFileNames": true
18+
},
19+
"files": [
20+
"index.d.ts",
21+
"stream-to-string-tests.ts"
22+
]
23+
}

types/stream-to-string/tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "extends": "dtslint/dt.json" }

0 commit comments

Comments
 (0)