1 | export function isStream(stream) {
|
2 | return stream !== null
|
3 | && typeof stream === 'object'
|
4 | && typeof stream.pipe === 'function';
|
5 | }
|
6 |
|
7 | export function isWritableStream(stream) {
|
8 | return isStream(stream)
|
9 | && stream.writable !== false
|
10 | && typeof stream._write === 'function'
|
11 | && typeof stream._writableState === 'object';
|
12 | }
|
13 |
|
14 | export function isReadableStream(stream) {
|
15 | return isStream(stream)
|
16 | && stream.readable !== false
|
17 | && typeof stream._read === 'function'
|
18 | && typeof stream._readableState === 'object';
|
19 | }
|
20 |
|
21 | export function isDuplexStream(stream) {
|
22 | return isWritableStream(stream)
|
23 | && isReadableStream(stream);
|
24 | }
|
25 |
|
26 | export function isTransformStream(stream) {
|
27 | return isDuplexStream(stream)
|
28 | && typeof stream._transform === 'function';
|
29 | }
|