mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-17 12:16:38 +08:00
25 lines
571 B
TypeScript
25 lines
571 B
TypeScript
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;
|
|
}
|