-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.test-d.ts
51 lines (43 loc) · 1.1 KB
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import {
type Stream,
type Writable as WritableStream,
type Readable as ReadableStream,
Duplex as DuplexStream,
type Transform as TransformStream,
} from 'node:stream';
import {expectType, expectAssignable} from 'tsd';
import {
isStream,
isWritableStream,
isReadableStream,
isDuplexStream,
isTransformStream,
type Options,
} from './index.js';
const foo = '';
if (isStream(foo)) {
expectAssignable<Stream>(foo);
}
if (isWritableStream(foo)) {
expectAssignable<WritableStream>(foo);
}
if (isReadableStream(foo)) {
expectAssignable<ReadableStream>(foo);
}
if (isDuplexStream(foo)) {
expectAssignable<DuplexStream>(new DuplexStream());
}
if (isTransformStream(foo)) {
expectAssignable<TransformStream>(foo);
}
isStream(foo, {});
isStream(foo, {checkOpen: false});
isWritableStream(foo, {});
isWritableStream(foo, {checkOpen: false});
isReadableStream(foo, {});
isReadableStream(foo, {checkOpen: false});
isDuplexStream(foo, {});
isDuplexStream(foo, {checkOpen: false});
isTransformStream(foo, {});
isTransformStream(foo, {checkOpen: false});
expectType<boolean | undefined>({} as Options['checkOpen']);