-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
modern-async.d.ts
203 lines (203 loc) · 9.95 KB
/
modern-async.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
198
199
200
201
202
203
declare module "asyncIterableWrap" {
export default asyncIterableWrap;
function asyncIterableWrap<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>): AsyncIterable<V>;
}
declare module "asyncWrap" {
export default asyncWrap;
function asyncWrap(fct: Function): Function;
}
declare module "asyncRoot" {
export default asyncRoot;
function asyncRoot(fct: () => Promise<void> | void, errorHandler?: (reason: any) => void): Promise<void>;
}
declare module "CancelledError" {
export default CancelledError;
class CancelledError extends Error {
constructor(message: string);
}
}
declare module "Deferred" {
export default Deferred;
class Deferred<T> {
get promise(): Promise<T>;
get resolve(): (v: T) => void;
get reject(): (v: any) => void;
}
}
declare module "asyncDelayCancellable" {
export default asyncDelayCancellable;
function asyncDelayCancellable(): [Promise<void>, () => boolean];
}
declare module "asyncDelay" {
export default asyncDelay;
function asyncDelay(): Promise<void>;
}
declare module "Delayer" {
export default Delayer;
class Delayer {
constructor(triggerTime: number);
set triggerTime(arg: number);
get triggerTime(): number;
reset(): void;
checkDelay(): Promise<boolean>;
}
}
declare module "queueMicrotask" {
export default queueMicrotask;
function queueMicrotask(fct: () => void): void;
}
declare module "Queue" {
export default Queue;
class Queue {
constructor(concurrency: number);
get concurrency(): number;
get running(): number;
get pending(): number;
exec<M>(fct: () => Promise<M> | M, priority?: number): Promise<M>;
execCancellable<M>(fct: () => Promise<M> | M, priority?: number): [Promise<M>, () => boolean];
cancelAllPending(): number;
}
}
declare module "asyncEvery" {
export default asyncEvery;
function asyncEvery<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, iteratee: (value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<boolean> | boolean, queueOrConcurrency?: Queue | number): Promise<boolean>;
import Queue from "Queue";
}
declare module "asyncIterableToArray" {
export default asyncIterableToArray;
function asyncIterableToArray<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>): Promise<V[]>;
}
declare module "asyncGeneratorMap" {
export default asyncGeneratorMap;
function asyncGeneratorMap<V, M>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, iteratee: (value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<M> | M, queueOrConcurrency?: Queue | number, ordered?: boolean): AsyncIterable<M>;
import Queue from "Queue";
}
declare module "asyncGeneratorFilter" {
export default asyncGeneratorFilter;
function asyncGeneratorFilter<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, iteratee: (value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<boolean> | boolean, queueOrConcurrency?: Queue | number, ordered?: boolean): AsyncIterable<V>;
import Queue from "Queue";
}
declare module "asyncFilter" {
export default asyncFilter;
function asyncFilter<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, iteratee: (value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<boolean> | boolean, queueOrConcurrency?: Queue | number): Promise<V[]>;
import Queue from "Queue";
}
declare module "asyncFind" {
export default asyncFind;
function asyncFind<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, iteratee: (value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<boolean> | boolean, queueOrConcurrency?: Queue | number, ordered?: boolean): Promise<V>;
import Queue from "Queue";
}
declare module "asyncFindIndex" {
export default asyncFindIndex;
function asyncFindIndex<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, iteratee: (value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<boolean> | boolean, queueOrConcurrency?: Queue | number, ordered?: boolean): Promise<number>;
import Queue from "Queue";
}
declare module "asyncForEach" {
export default asyncForEach;
function asyncForEach<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, iteratee: (value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<void> | void, queueOrConcurrency?: Queue | number): Promise<void>;
import Queue from "Queue";
}
declare module "asyncMap" {
export default asyncMap;
function asyncMap<V, M>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, iteratee: (value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<M> | M, queueOrConcurrency?: Queue | number): Promise<M[]>;
import Queue from "Queue";
}
declare module "asyncReduce" {
export default asyncReduce;
function asyncReduce<V, A>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, reducer: (accumulator: A, value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<A> | A, initial: A): Promise<A>;
function asyncReduce<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, reducer: (accumulator: V, value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<V> | V): Promise<V>;
}
declare module "asyncReduceRight" {
export default asyncReduceRight;
function asyncReduceRight<V, A>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>,reducer: (accumulator: A, value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<A> | A, initial: A): Promise<A>;
function asyncReduceRight<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, reducer: (accumulator: V, value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<V> | V): Promise<V>;
}
declare module "asyncSleepCancellable" {
export default asyncSleepCancellable;
function asyncSleepCancellable(amount: number): [Promise<void>, () => boolean];
}
declare module "Scheduler" {
export default Scheduler;
class Scheduler {
constructor(fct: () => Promise<void> | void, delay: number, options?: {
startImmediate?: boolean;
concurrency?: number;
maxPending?: number;
});
get delay(): number;
get startImmediate(): boolean;
get concurrency(): number;
get maxPending(): number;
get started(): boolean;
start(): void;
stop(): void;
}
}
declare module "asyncSleep" {
export default asyncSleep;
function asyncSleep(amount: number): Promise<void>;
}
declare module "asyncSleepPreciseCancellable" {
export default asyncSleepPreciseCancellable;
function asyncSleepPreciseCancellable(amount: number): [Promise<void>, () => boolean];
}
declare module "asyncSleepPrecise" {
export default asyncSleepPrecise;
function asyncSleepPrecise(amount: number): Promise<void>;
}
declare module "asyncSome" {
export default asyncSome;
function asyncSome<V>(iterable: Iterable<Promise<V> | V> | AsyncIterable<V>, iteratee: (value: V, index: number, iterable: Iterable<Promise<V> | V> | AsyncIterable<V>) => Promise<boolean> | boolean, queueOrConcurrency?: Queue | number): Promise<boolean>;
import Queue from "Queue";
}
declare module "TimeoutError" {
export default TimeoutError;
class TimeoutError extends Error {
constructor(message: string);
}
}
declare module "asyncTimeout" {
export default asyncTimeout;
function asyncTimeout<T>(fct: () => Promise<T> | T, amount: number): Promise<T>;
}
declare module "asyncTimeoutPrecise" {
export default asyncTimeoutPrecise;
function asyncTimeoutPrecise<T>(fct: () => Promise<T> | T, amount: number): Promise<T>;
}
declare module "reflectAsyncStatus" {
export default reflectAsyncStatus;
function reflectAsyncStatus<T>(fct: () => Promise<T> | T): Promise<PromiseSettledResult<T>>;
}
declare module "modern-async" {
export { default as asyncIterableWrap } from "asyncIterableWrap";
export { default as asyncRoot } from "asyncRoot";
export { default as asyncWrap } from "asyncWrap";
export { default as CancelledError } from "CancelledError";
export { default as Deferred } from "Deferred";
export { default as asyncDelay } from "asyncDelay";
export { default as asyncDelayCancellable } from "asyncDelayCancellable";
export { default as Delayer } from "Delayer";
export { default as asyncEvery } from "asyncEvery";
export { default as asyncFilter } from "asyncFilter";
export { default as asyncGeneratorFilter } from "asyncGeneratorFilter";
export { default as asyncFind } from "asyncFind";
export { default as asyncFindIndex } from "asyncFindIndex";
export { default as asyncForEach } from "asyncForEach";
export { default as asyncMap } from "asyncMap";
export { default as asyncGeneratorMap } from "asyncGeneratorMap";
export { default as Queue } from "Queue";
export { default as queueMicrotask } from "queueMicrotask";
export { default as asyncReduce } from "asyncReduce";
export { default as asyncReduceRight } from "asyncReduceRight";
export { default as Scheduler } from "Scheduler";
export { default as asyncSleep } from "asyncSleep";
export { default as asyncSleepCancellable } from "asyncSleepCancellable";
export { default as asyncSleepPrecise } from "asyncSleepPrecise";
export { default as asyncSleepPreciseCancellable } from "asyncSleepPreciseCancellable";
export { default as asyncSome } from "asyncSome";
export { default as asyncTimeout } from "asyncTimeout";
export { default as TimeoutError } from "TimeoutError";
export { default as asyncTimeoutPrecise } from "asyncTimeoutPrecise";
export { default as asyncIterableToArray } from "asyncIterableToArray";
export { default as reflectAsyncStatus } from "reflectAsyncStatus";
}