-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.cts
169 lines (126 loc) · 8.36 KB
/
index.d.cts
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
// TypeScript Version: 4.7
export interface Thenable <R> {
then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
}
type SettledStatus = 'fulfilled' | 'rejected';
export interface GenericAbortSignal {
readonly aborted: boolean;
onabort?: ((...args: any) => any) | null;
addEventListener?: (...args: any) => any;
removeEventListener?: (...args: any) => any;
}
interface AxiosPromiseOptions {
signal?: GenericAbortSignal;
timeout?: number;
}
type AtomicModeAwait = false;
type AtomicModeDetached = true;
type AtomicMode = AtomicModeAwait | AtomicModeDetached;
interface AxiosPromiseResolveOptions {
atomic?: AtomicMode
}
interface PromisifyOptions {
scopeArg?: boolean;
scopeContext?: boolean;
}
interface PromisifyAllOptions extends PromisifyOptions {
reducer?: (this: object, key: string | symbol, value: any) => string | boolean | undefined
}
declare namespace AxiosPromise {
type EventName = string|symbol;
type RawEvents = Record<EventName, Function|Function[]|null>
class EventEmitter {
constructor(events?: RawEvents);
constructor(events?: RawEvents);
on(event: EventName, listener: Function, prepend?: boolean): this;
addEventListener(event: EventName, listener: Function, prepend?: boolean): this;
off(event: EventName, listener: Function): boolean;
removeEventListener(event: EventName, listener: Function): boolean;
emit(event: EventName, ...args: any): boolean;
once(event: EventName, listener: Function, prepend?: boolean): this;
listenerCount(event: EventName): number;
}
class AbortSignal {
readonly aborted: boolean;
addEventListener(event: EventName, listener: Function): void;
removeEventListener(event: EventName, listener: Function): void;
}
class AbortController {
readonly signal: AbortSignal;
abort(): void;
}
export type ErrorCode = string | number | symbol;
export class CanceledError extends Error {
constructor(message?: string, code?: ErrorCode);
readonly name: string;
readonly code: ErrorCode;
readonly scope: AxiosPromise<any>;
static from(thing: any): CanceledError;
static isCanceledError(thing: any): boolean;
static addSignatureTo(target: object): void;
static rethrow(err: any, code?: ErrorCode): void;
static init(name: string, code?: ErrorCode): void;
}
class TimeoutError extends CanceledError {
constructor(message?: string, code?: ErrorCode);
constructor(timeout?: number, code?: ErrorCode);
}
type OnCancelListener = (reason: CanceledError) => void;
class AxiosPromise<R = any> implements Thenable <R> {
constructor(callback: (resolve: (value?: R | Thenable<R>) => void, reject: (error?: any) => void, scope: AxiosPromise<R>) => void | OnCancelListener, options?: AxiosPromiseOptions);
then<U>(onFulfilled?: (value: R, scope: AxiosPromise<U>) => U | Thenable<U>, onRejected?: (error: any, scope: AxiosPromise<U>) => U | Thenable<U>): AxiosPromise<U>;
then<U>(onFulfilled?: (value: R, scope: AxiosPromise<U>) => U | Thenable<U>, onRejected?: (error: any, scope: AxiosPromise<U>) => void): AxiosPromise<U>;
catch<U>(onRejected?: (error: any, scope: AxiosPromise<U>) => U | Thenable<U>): AxiosPromise<U>;
finally<U = any>(onFinally?: (result: {value: U, status: SettledStatus}, scope: AxiosPromise<U>) => any | Thenable<any>): AxiosPromise<R>;
atomic<U = any>(mode?: AtomicMode): AxiosPromise<U>;
timeout(ms: number, errorOrMessage?: Error|string|number): AxiosPromise<R>;
listen(signal?: GenericAbortSignal): AxiosPromise<R>;
cancel(reason?: any): boolean;
onCancel(onCancelListener: OnCancelListener): void;
tag(str: string): AxiosPromise<R>;
readonly signal: GenericAbortSignal;
static resolve(): AxiosPromise<void>;
static resolve<R>(value: R | Thenable<R>, options?: AxiosPromiseResolveOptions): AxiosPromise<R>;
static reject<R>(error: any): AxiosPromise<R>;
static atomic<R>(value: any | Thenable<R>, mode?: AtomicMode): AxiosPromise<R>;
static all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable<T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>, T10 | Thenable<T10>]): AxiosPromise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
static all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable<T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>]): AxiosPromise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
static all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable<T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>]): AxiosPromise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
static all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable<T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>]): AxiosPromise<[T1, T2, T3, T4, T5, T6, T7]>;
static all<T1, T2, T3, T4, T5, T6>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable<T4>, T5 | Thenable<T5>, T6 | Thenable<T6>]): AxiosPromise<[T1, T2, T3, T4, T5, T6]>;
static all<T1, T2, T3, T4, T5>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable<T4>, T5 | Thenable<T5>]): AxiosPromise<[T1, T2, T3, T4, T5]>;
static all<T1, T2, T3, T4>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable<T4>]): AxiosPromise<[T1, T2, T3, T4]>;
static all<T1, T2, T3>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>]): AxiosPromise<[T1, T2, T3]>;
static all<T1, T2>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>]): AxiosPromise<[T1, T2]>;
static all<T1>(values: [T1 | Thenable<T1>]): AxiosPromise<[T1]>;
static all<TAll>(values: Array<TAll | Thenable<TAll>>): AxiosPromise<TAll[]>;
static race<R>(promises: (R | Thenable<R>)[]): AxiosPromise<R>;
static allSettled<R>(promises: (R | Thenable<R>)[]): AxiosPromise<R>;
static delay<R = any>(ms: number): AxiosPromise<R>;
static isAxiosPromise(thing: any): boolean;
static isCanceledError(thing: any): boolean;
static readonly CanceledError: typeof CanceledError;
static readonly TimeoutError: typeof TimeoutError;
static _unhandledRejection(reason: any, promise: AxiosPromise): void;
static promisify<TResult = any>(fn: (...args: any) => IterableIterator<TResult | Thenable<TResult>>, options?: PromisifyOptions): () => AxiosPromise<TResult>;
static promisify<TResult = any>(fn: (scope: AxiosPromise<TResult>, ...args: any) => IterableIterator<TResult | Thenable<TResult>>, options?: PromisifyOptions): () => AxiosPromise<TResult>;
static promisifyAll(obj: object, options?: PromisifyAllOptions): void;
}
class AxiosPromiseSync<R = any> extends AxiosPromise <R> {
}
function isGenerator(thing:any): boolean;
function isGeneratorFunction(thing:any): boolean;
function isAsyncFunction(thing:any): boolean;
function isPlainFunction(thing:any): boolean;
function isAbortSignal(thing:any): boolean;
function isAbortController(thing:any): boolean;
function isContextDefined(context:any): boolean;
function lazyBind(obj: object, props: Record<symbol|string, any>, options?: {bindMethods?: boolean}): boolean;
function defineConstants(obj: object, props: Record<symbol|string, any>, options?: {configurable?: boolean, enumerable?: boolean}): void;
function setImmediate(handler: ()=> void): void;
function asap(handler: ()=> void): void;
function symbols(...names: string[]): IterableIterator<symbol>;
function bottleneck<TResult = any, TArgs extends any[] = []>(fn: (...args: TArgs) => any, options?: {concurrency: number, cancelRunning: boolean, sync: boolean, timeout: number, taskTimeout: number, queueTimeout: number}) : (...args: TArgs) => AxiosPromise<TResult>
const global: object;
}