1 | /// <reference types="node"/>
|
2 | import * as stream from 'stream';
|
3 |
|
4 | declare const isStream: {
|
5 | /**
|
6 | @returns Whether `stream` is a [`Stream`](https://nodejs.org/api/stream.html#stream_stream).
|
7 |
|
8 | @example
|
9 | ```
|
10 | import * as fs from 'fs';
|
11 | import isStream = require('is-stream');
|
12 |
|
13 | isStream(fs.createReadStream('unicorn.png'));
|
14 | //=> true
|
15 |
|
16 | isStream({});
|
17 | //=> false
|
18 | ```
|
19 | */
|
20 | (stream: unknown): stream is stream.Stream;
|
21 |
|
22 | /**
|
23 | @returns Whether `stream` is a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable).
|
24 |
|
25 | @example
|
26 | ```
|
27 | import * as fs from 'fs';
|
28 | import isStream = require('is-stream');
|
29 |
|
30 | isStream.writable(fs.createWriteStrem('unicorn.txt'));
|
31 | //=> true
|
32 | ```
|
33 | */
|
34 | writable(stream: unknown): stream is stream.Writable;
|
35 |
|
36 | /**
|
37 | @returns Whether `stream` is a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable).
|
38 |
|
39 | @example
|
40 | ```
|
41 | import * as fs from 'fs';
|
42 | import isStream = require('is-stream');
|
43 |
|
44 | isStream.readable(fs.createReadStream('unicorn.png'));
|
45 | //=> true
|
46 | ```
|
47 | */
|
48 | readable(stream: unknown): stream is stream.Readable;
|
49 |
|
50 | /**
|
51 | @returns Whether `stream` is a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
|
52 |
|
53 | @example
|
54 | ```
|
55 | import {Duplex} from 'stream';
|
56 | import isStream = require('is-stream');
|
57 |
|
58 | isStream.duplex(new Duplex());
|
59 | //=> true
|
60 | ```
|
61 | */
|
62 | duplex(stream: unknown): stream is stream.Duplex;
|
63 |
|
64 | /**
|
65 | @returns Whether `stream` is a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform).
|
66 |
|
67 | @example
|
68 | ```
|
69 | import * as fs from 'fs';
|
70 | import Stringify = require('streaming-json-stringify');
|
71 | import isStream = require('is-stream');
|
72 |
|
73 | isStream.transform(Stringify());
|
74 | //=> true
|
75 | ```
|
76 | */
|
77 | transform(input: unknown): input is stream.Transform;
|
78 | };
|
79 |
|
80 | export = isStream;
|