-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
98 lines (81 loc) · 2.39 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
/**
* TypeScript definitions for invoke-parallel
*/
// This is very poorly typed, because TypeScript provides not nearly the
// dynamism I need in the types.
export interface CancelToken extends Promise<void> {
resolve(): void;
}
export interface CallOptions {
cancelToken?: PromiseLike<any>;
keepOpen?: boolean;
}
export interface PoolOptions {
cwd?: string;
env?: {[key: string]: string};
limit?: number;
minimum?: number;
maxPerChild?: number;
timeout?: number;
retries?: number;
onError?(error: Error): any;
}
export interface ActivePoolOptions {
cwd: string;
env: {[key: string]: string};
limit: number;
minimum: number;
maxPerChild: number;
timeout: number;
retries: number;
onError(error: Error): any;
}
export interface RequireOptions {
pool?: Pool;
cancelToken?: PromiseLike<any>;
isolated?: boolean;
options?: PoolOptions; // Only meaningful with `isolated: true`
}
export interface ModuleKeys {
[key: string]: (...args: any[]) => Promise<any>;
}
export interface ModuleCall<T extends ModuleKeys> extends T {
(options: CallOptions): this;
}
export interface ChildStats {
running: number;
loaded: string[];
dying: boolean;
loads: number;
calls: number;
}
export interface Pool {
options(): ActivePoolOptions;
childStats(): ChildStats[];
total(): number;
spawned(): number;
queued(): number;
running(): number;
waiting(): number;
loaded(): string[];
cached(module: string): string[] | void;
loading(): string[];
}
export declare function globalPool(): Pool;
export declare function pool(options?: PoolOptions): Pool;
// It's recommended to pass the `T` generic parameter to remain well-typed. This
// module can't infer it otherwise, since TypeScript provides no facilities for
// getting static modules' namespace export types at the type level.
export declare function require<T extends ModuleKeys>(module: string, options?: RequireOptions): Promise<ModuleCall<T>>;
export declare function cancelToken(init: (cancel: () => void) => any): CancelToken;
export declare class Retry extends Error {}
export declare class Cancel extends Error {}
// For the worker.
export interface SendOptions {
keepOpen?: boolean;
}
export interface ReturnWrap {
value: any;
options: SendOptions;
}
export function set(value: any, options: SendOptions): ReturnWrap;