-
Notifications
You must be signed in to change notification settings - Fork 0
/
asyncblock.d.ts
73 lines (58 loc) · 1.8 KB
/
asyncblock.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
declare module _ab {
module ab {
interface Result<T> {
sync(options?: TaskOptions): T;
defer(options?: TaskOptions): T;
}
function enableTransform(module: any): boolean;
function getCurrentFlow(): Flow;
function ifError(callback: Function): Function;
function nostack<T>(run: (flow: ab.Flow) => T, done?: Function): ab.Result<T>;
function nostack<T>(run: () => T, done?: Function): ab.Result<T>;
interface TaskOptions {
ignoreError?: boolean;
key?: any;
responseFormat?: string[];
timeout?: number;
timeoutIsError?: boolean;
dontWait?: boolean;
firstArgIsError?: boolean;
}
interface Flow {
add(): any;
add(options: TaskOptions): any;
add(key: any): any;
callback(): any;
callback(options: TaskOptions): any;
callback(key: any): any;
set(): Function;
set(options: TaskOptions): Function;
set(key: any): Function;
set(key: any, responseFormat: string[]): Function;
wait(): any;
wait(key: any): any;
get(key: any): any;
del(key: any): any;
sync(func: any): any;
queue(options: TaskOptions, exec: Function): void;
queue(key: any, exec: Function): void;
queue(exec: Function): void;
maxParallel: number;
errorCallback: Function;
taskTimeout: number;
timeoutIsError: boolean;
//task timeout (event = taskTimeout)
on(event: string, handler: (info: {
key: any; runtime: number
}) => void): void ;
doneAdding(): void;
forceWait(): any;
}
}
function ab<T>(run: (flow: ab.Flow) => T, done?: Function): ab.Result<T>;
function ab<T>(run: () => T, done?: Function): ab.Result<T>;
}
declare module "asyncblock-generators" {
import ab = _ab.ab;
export = ab;
}