Skip to content

Commit 1ba22cc

Browse files
authored
🤖 Merge PR DefinitelyTyped#72587 feat: stream-concat by @tpluscode
1 parent db30eaf commit 1ba22cc

File tree

5 files changed

+114
-0
lines changed

5 files changed

+114
-0
lines changed

types/stream-concat/.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*
2+
!**/*.d.ts
3+
!**/*.d.cts
4+
!**/*.d.mts
5+
!**/*.d.*.ts

types/stream-concat/index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference types="node" />
2+
3+
import type { Readable, Transform, TransformOptions } from "stream";
4+
5+
interface Options extends TransformOptions {
6+
advanceOnClose?: boolean;
7+
}
8+
9+
interface NextStream {
10+
(): Readable | null | Promise<Readable | null>;
11+
}
12+
13+
declare class StreamConcat extends Transform {
14+
constructor(streams: Readable[] | NextStream, options?: Options);
15+
16+
addStream(newStream: Readable): void;
17+
nextStream(): Promise<void>;
18+
}
19+
20+
export = StreamConcat;

types/stream-concat/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"private": true,
3+
"name": "@types/stream-concat",
4+
"version": "2.0.9999",
5+
"projects": [
6+
"https://github.com/sedenardi/node-stream-concat"
7+
],
8+
"dependencies": {
9+
"@types/node": "*"
10+
},
11+
"devDependencies": {
12+
"@types/stream-concat": "workspace:."
13+
},
14+
"owners": [
15+
{
16+
"name": "Tomasz Pluskiewicz",
17+
"githubUsername": "tpluscode"
18+
}
19+
]
20+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import StreamConcat = require("stream-concat");
2+
import { Readable } from "stream";
3+
4+
const test: boolean = false;
5+
const options = {
6+
advanceOnClose: true,
7+
highWaterMark: 10,
8+
objectMode: true,
9+
};
10+
11+
const readable = <Readable> {};
12+
const fromStreams: Readable = new StreamConcat([
13+
readable,
14+
readable,
15+
readable,
16+
]);
17+
const fromStreamsWithOptions: Readable = new StreamConcat([
18+
readable,
19+
readable,
20+
readable,
21+
], options);
22+
23+
const fromFactory: Readable = new StreamConcat(() => {
24+
if (test) {
25+
return readable;
26+
}
27+
return null;
28+
});
29+
const fromFactoryWithOptions: Readable = new StreamConcat(() => {
30+
if (test) {
31+
return readable;
32+
}
33+
return null;
34+
}, options);
35+
36+
const fromAsyncFactory: Readable = new StreamConcat(async () => {
37+
if (test) {
38+
return readable;
39+
}
40+
return null;
41+
});
42+
const fromAsyncFactoryWithOptions: Readable = new StreamConcat(async () => {
43+
if (test) {
44+
return readable;
45+
}
46+
return null;
47+
}, options);
48+
49+
new StreamConcat([]).addStream(readable);
50+
new StreamConcat([]).nextStream().then(() => {});

types/stream-concat/tsconfig.json

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

0 commit comments

Comments
 (0)