diff --git a/types/is-stream/index.d.ts b/types/is-stream/index.d.ts new file mode 100644 index 0000000000..0c24d084d9 --- /dev/null +++ b/types/is-stream/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for is-stream 1.1 +// Project: https://github.com/sindresorhus/is-stream#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +import * as stream from "stream"; + +export = isStream; + +declare function isStream(maybeStream: any): maybeStream is stream.Stream; + +declare namespace isStream { + function writable(maybeWritable: any): maybeWritable is stream.Writable; + function readable(maybeReadable: any): maybeReadable is stream.Readable; + function duplex(maybeDuplex: any): maybeDuplex is stream.Duplex; + function transform(maybeTransform: any): maybeTransform is stream.Transform; +} diff --git a/types/is-stream/is-stream-tests.ts b/types/is-stream/is-stream-tests.ts new file mode 100644 index 0000000000..9d9eb315b4 --- /dev/null +++ b/types/is-stream/is-stream-tests.ts @@ -0,0 +1,24 @@ +import isStream = require('is-stream'); +import * as stream from 'stream'; + +const anyStream: any = new stream.Stream(); + +if (isStream(anyStream)) { + const justStream: stream.Stream = anyStream; +} + +if (isStream.writable(anyStream)) { + const writableStream: stream.Writable = anyStream; +} + +if (isStream.readable(anyStream)) { + const readableStream: stream.Readable = anyStream; +} + +if (isStream.duplex(anyStream)) { + const duplexStream: stream.Duplex = anyStream; +} + +if (isStream.transform(anyStream)) { + const transformStream: stream.Transform = anyStream; +} diff --git a/types/is-stream/tsconfig.json b/types/is-stream/tsconfig.json new file mode 100644 index 0000000000..926737569f --- /dev/null +++ b/types/is-stream/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-stream-tests.ts" + ] +} diff --git a/types/is-stream/tslint.json b/types/is-stream/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-stream/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }