From bc5b7623cdd6ae2539dd562a8b0ce0ab1eccc7d1 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Tue, 16 Jun 2020 11:17:03 +0200 Subject: [PATCH] Add streamify-array typings (#45484) --- types/streamify-array/index.d.ts | 16 +++++++++++++ .../streamify-array/streamify-array-tests.ts | 9 +++++++ types/streamify-array/tsconfig.json | 24 +++++++++++++++++++ types/streamify-array/tslint.json | 1 + 4 files changed, 50 insertions(+) create mode 100644 types/streamify-array/index.d.ts create mode 100644 types/streamify-array/streamify-array-tests.ts create mode 100644 types/streamify-array/tsconfig.json create mode 100644 types/streamify-array/tslint.json diff --git a/types/streamify-array/index.d.ts b/types/streamify-array/index.d.ts new file mode 100644 index 0000000000..0b1565d81b --- /dev/null +++ b/types/streamify-array/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for streamify-array 1.0 +// Project: https://github.com/rubensworks/streamify-array.js#readme +// Definitions by: Joachim Van Herwegen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Readable } from 'stream'; + +/** + * Converts an array into a Node readable stream. + * Elements get removed from the array when they are read from the stream. + */ +declare function streamifyArray(input: any[]): Readable; + +export = streamifyArray; diff --git a/types/streamify-array/streamify-array-tests.ts b/types/streamify-array/streamify-array-tests.ts new file mode 100644 index 0000000000..095acdda76 --- /dev/null +++ b/types/streamify-array/streamify-array-tests.ts @@ -0,0 +1,9 @@ +import streamifyArray from 'streamify-array'; +import { Readable } from 'stream'; + +const stream: Readable = streamifyArray([1, 2, 3]); +stream.on('data', (d) => console.log('Data: ' + d)); +stream.on('end', () => console.log('Done!')); + +// $ExpectError +streamifyArray(); diff --git a/types/streamify-array/tsconfig.json b/types/streamify-array/tsconfig.json new file mode 100644 index 0000000000..c199db20dc --- /dev/null +++ b/types/streamify-array/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "esModuleInterop": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "streamify-array-tests.ts" + ] +} diff --git a/types/streamify-array/tslint.json b/types/streamify-array/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/streamify-array/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }