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