-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
128 lines (116 loc) · 3.86 KB
/
index.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import * as stream from 'stream';
export function ended(stream: NodeJS.ReadableStream): Promise<void>;
export function finished(stream: NodeJS.WritableStream): Promise<void>;
export function toBuffer(stream: NodeJS.ReadableStream): Promise<Buffer>;
type Resolveable<T> = Promise<T> | T;
type EncodingType = string | null;
type ChunkType = Buffer | string;
type ChunkObjectType = ChunkType | null;
type PushType = ChunkType | null;
type PushObjectType = ChunkObjectType | null;
type ChunkList = { chunk: ChunkType; encoding: EncodingType }[];
type ChunkObjectList = { chunk: ChunkObjectType; encoding: EncodingType }[];
interface ReadableOptionsBase {
highWaterMark?: number;
encoding?: string | null;
objectMode?: boolean;
}
interface WritableOptionsBase {
highWaterMark?: number;
decodeStrings?: boolean;
objectMode?: boolean;
}
interface ReadableOptions extends ReadableOptionsBase {
objectMode?: false;
read?: (size: number) => Resolveable<PushType | void>;
}
interface ReadableObjectOptions extends ReadableOptionsBase {
objectMode: true;
read?: (size: number) => Resolveable<PushObjectType | void>;
}
export class PromiseReadable extends stream.Readable {
constructor(options: ReadableObjectOptions);
constructor(options: ReadableOptions);
}
interface WritableOptions extends WritableOptionsBase {
objectMode?: false;
write?: (chunk: ChunkType, encoding: EncodingType) => Resolveable<void>;
writev?: (chunks: ChunkList) => Resolveable<void>;
}
interface WritableObjectOptions extends WritableOptionsBase {
objectMode: true;
write?: (
chunk: ChunkObjectType,
encoding: EncodingType,
) => Resolveable<void>;
writev?: (chunks: ChunkObjectList) => Resolveable<void>;
}
export class PromiseWritable extends stream.Writable {
constructor(options: WritableObjectOptions);
constructor(options: WritableOptions);
}
interface DuplexOptionsBase extends ReadableOptionsBase, WritableOptionsBase {
allowHalfOpen?: boolean;
readableObjectMode?: boolean;
writableObjectMode?: boolean;
}
interface DuplexOptions
extends ReadableOptions,
WritableOptions,
DuplexOptionsBase {
readableObjectMode?: false;
writableObjectMode?: false;
objectMode?: false;
}
type DuplexRObjectOptions = ReadableObjectOptions &
WritableOptions &
DuplexOptionsBase & {
readableObjectMode: true;
writableObjectMode?: false;
objectMode?: false;
};
type DuplexWObjectOptions = ReadableOptions &
WritableObjectOptions &
DuplexOptionsBase & {
readableObjectMode?: false;
writableObjectMode: true;
objectMode?: false;
};
type DuplexObjectOptions = ReadableObjectOptions &
WritableObjectOptions &
DuplexOptionsBase & {
readableObjectMode?: false;
writableObjectMode?: true;
objectMode?: true;
};
export class PromiseDuplex extends stream.Duplex {
constructor(options: DuplexObjectOptions);
constructor(options: DuplexRObjectOptions);
constructor(options: DuplexWObjectOptions);
constructor(options: DuplexOptions);
}
interface TransformOptionsBase
extends ReadableOptionsBase,
WritableOptionsBase {}
interface TransformOptions extends ReadableOptions, WritableOptions {
objectMode?: false;
transform: (
chunk: ChunkType,
encoding: EncodingType,
) => Resolveable<PushType>;
flush?: () => Resolveable<PushType | void>;
}
interface TransformObjectOptions
extends ReadableObjectOptions,
WritableObjectOptions {
objectMode: true;
transform: (
chunk: ChunkObjectType,
encoding: EncodingType,
) => Resolveable<PushObjectType>;
flush?: () => Resolveable<PushObjectType | void>;
}
export class PromiseTransform extends stream.Transform {
constructor(options: TransformObjectOptions);
constructor(options: TransformOptions);
}