diff --git a/types/stream-concat/.npmignore b/types/stream-concat/.npmignore new file mode 100644 index 00000000000000..93e307400a5456 --- /dev/null +++ b/types/stream-concat/.npmignore @@ -0,0 +1,5 @@ +* +!**/*.d.ts +!**/*.d.cts +!**/*.d.mts +!**/*.d.*.ts diff --git a/types/stream-concat/index.d.ts b/types/stream-concat/index.d.ts new file mode 100644 index 00000000000000..9b5862386fb43f --- /dev/null +++ b/types/stream-concat/index.d.ts @@ -0,0 +1,20 @@ +/// + +import type { Readable, Transform, TransformOptions } from "stream"; + +interface Options extends TransformOptions { + advanceOnClose?: boolean; +} + +interface NextStream { + (): Readable | null | Promise; +} + +declare class StreamConcat extends Transform { + constructor(streams: Readable[] | NextStream, options?: Options); + + addStream(newStream: Readable): void; + nextStream(): Promise; +} + +export = StreamConcat; diff --git a/types/stream-concat/package.json b/types/stream-concat/package.json new file mode 100644 index 00000000000000..756debd51713af --- /dev/null +++ b/types/stream-concat/package.json @@ -0,0 +1,20 @@ +{ + "private": true, + "name": "@types/stream-concat", + "version": "2.0.9999", + "projects": [ + "https://github.com/sedenardi/node-stream-concat" + ], + "dependencies": { + "@types/node": "*" + }, + "devDependencies": { + "@types/stream-concat": "workspace:." + }, + "owners": [ + { + "name": "Tomasz Pluskiewicz", + "githubUsername": "tpluscode" + } + ] +} diff --git a/types/stream-concat/stream-concat-tests.ts b/types/stream-concat/stream-concat-tests.ts new file mode 100644 index 00000000000000..0405ca14e94bee --- /dev/null +++ b/types/stream-concat/stream-concat-tests.ts @@ -0,0 +1,50 @@ +import StreamConcat = require("stream-concat"); +import { Readable } from "stream"; + +const test: boolean = false; +const options = { + advanceOnClose: true, + highWaterMark: 10, + objectMode: true, +}; + +const readable = {}; +const fromStreams: Readable = new StreamConcat([ + readable, + readable, + readable, +]); +const fromStreamsWithOptions: Readable = new StreamConcat([ + readable, + readable, + readable, +], options); + +const fromFactory: Readable = new StreamConcat(() => { + if (test) { + return readable; + } + return null; +}); +const fromFactoryWithOptions: Readable = new StreamConcat(() => { + if (test) { + return readable; + } + return null; +}, options); + +const fromAsyncFactory: Readable = new StreamConcat(async () => { + if (test) { + return readable; + } + return null; +}); +const fromAsyncFactoryWithOptions: Readable = new StreamConcat(async () => { + if (test) { + return readable; + } + return null; +}, options); + +new StreamConcat([]).addStream(readable); +new StreamConcat([]).nextStream().then(() => {}); diff --git a/types/stream-concat/tsconfig.json b/types/stream-concat/tsconfig.json new file mode 100644 index 00000000000000..1b3b2c5ca533bc --- /dev/null +++ b/types/stream-concat/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "stream-concat-tests.ts" + ] +}