-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
202 lines (144 loc) · 4.58 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import { EventEmitter } from "eventemitter3";
/**
*
* IterableEmitter is an async iterable buffer
*
* It can convert an emitter type stream of data to an iterable
*
* ```
*
* const options = { highWaterMark:
* }
*
* const e2i = new IterableEmitter(emitter, options)
* ```
*
*/
export declare class IterableEmitter extends EventEmitter {
constructor (Emitter:typeof EventEmitter, options:iterableEmitterOptions);
options:iterableEmitterOptions;
/**
* Is the buffer in the paused state (not expecting any more items to be added)
*/
paused:boolean;
/**
* Is the buffer in the done state (not expecting any more items to be added)
*/
done:boolean;
/**
* Current length of the buffer
*/
length:number;
/**
* Total number of items added to the buffer
*/
totalLength:number;
/**
* Total number of items returned from the buffer
*/
totalReturned:number;
/**
* Total data elements filtered
*/
totalFiltered:number;
/**
* Error object
*/
error:{error:boolean, errorObject:Error}
[Symbol.asyncIterator]() : Promise<any>;
}
type iterableEmitterEvent = string;
type iterableEmitterOptionBase = {
/**
*
* Once the buffer reaches the highWaterMark in size, the 'pause' method on the emitter will be called for every subsequent 'dataEvent'.
*
* Default value of 1000
*
*/
highWaterMark?:number;
/**
* When a paused buffer has been drained to the lowWaterMark, the 'resume' method on the emitter will be called.
*
* Default value of 500
*
*/
lowWaterMark?:number;
/**
* If set to true, the buffer will be initialized in size to the highWaterMark
*
* Default value of true
*
*/
initializeBuffer?:boolean;
/**
* The buffer will listen for 'dataEvents' and push the arguments onto the stack,
* if multiple arguments are supplied, they will be converted to an array
*/
dataEvent:iterableEmitterEvent;
/**
* A single event, or an array of events that result in the buffer considered 'resolved'.
* Any further data events, or attempts to add to the buffer will result in an error.
*/
resolutionEvent:iterableEmitterEvent | iterableEmitterEvent[];
/**
* Rejection event(s) to listen for, defaults to 'error'
*/
rejectionEvent:iterableEmitterEvent | iterableEmitterEvent[];
/**
* You can pass a method to transform the data returned from the 'dataEvent' prior to having
* it pushed on the buffer. all arguments passed to the 'data' event will be passed to the transform method.
*/
transform?:{(...args:any[]):any};
/**
*
*
*
*/
preFilter?:{(...args:any[]):boolean}
/**
*
* The pause function will be called when a data event results in the number of items in the buffer to meet
* or exceed the high water mark. It will be bound to the emitter
*
*/
pauseFunction:{():void};
/**
*
* The resume function will be called when the buffer has been drained to the low water mark. It will be bound to the emitter
*
*/
resumeFunction:{():void}
/**
*
* The pause method, is a string representing the name of a method on the emitter that will be called when a data event results in the number of items in the buffer to meet
* or exceed the high water mark.
*
*/
pauseMethod:string;
/**
*
* The resume method, is a string representing the name of a method on the emitter that will be called when the buffer has been drained to the low water mark
*
*/
resumeMethod:string
}
export interface iterableEmitterOptions extends iterableEmitterOptionBase {}
export interface iterableEmitterValidatedOptions extends iterableEmitterOptionBase {
/**
* A single event, or an array of events that result in the buffer considered 'resolved'.
* Any further data events, or attempts to add to the buffer will result in an error.
*/
resolutionEvent: iterableEmitterEvent[];
/**
* Rejection event(s) to listen for, defaults to 'error'
*/
rejectionEvent: iterableEmitterEvent[];
/**
* If set to true, the buffer will be initialized in size to the highWaterMark
*
* Default value of true
*
*/
initializeBuffer:boolean;
}