source: frontend/node_modules/any-promise/index.d.ts

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 5.2 KB
Line 
1declare class Promise <R> implements Promise.Thenable <R> {
2 /**
3 * If you call resolve in the body of the callback passed to the constructor,
4 * your promise is fulfilled with result object passed to resolve.
5 * If you call reject your promise is rejected with the object passed to resolve.
6 * For consistency and debugging (eg stack traces), obj should be an instanceof Error.
7 * Any errors thrown in the constructor callback will be implicitly passed to reject().
8 */
9 constructor (callback: (resolve : (value?: R | Promise.Thenable<R>) => void, reject: (error?: any) => void) => void);
10
11 /**
12 * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects.
13 * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called.
14 * Both callbacks have a single parameter , the fulfillment value or rejection reason.
15 * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve.
16 * If an error is thrown in the callback, the returned promise rejects with that error.
17 *
18 * @param onFulfilled called when/if "promise" resolves
19 * @param onRejected called when/if "promise" rejects
20 */
21 then <U> (onFulfilled?: (value: R) => U | Promise.Thenable<U>, onRejected?: (error: any) => U | Promise.Thenable<U>): Promise<U>;
22 then <U> (onFulfilled?: (value: R) => U | Promise.Thenable<U>, onRejected?: (error: any) => void): Promise<U>;
23
24 /**
25 * Sugar for promise.then(undefined, onRejected)
26 *
27 * @param onRejected called when/if "promise" rejects
28 */
29 catch <U> (onRejected?: (error: any) => U | Promise.Thenable<U>): Promise<U>;
30
31 /**
32 * Make a new promise from the thenable.
33 * A thenable is promise-like in as far as it has a "then" method.
34 */
35 static resolve (): Promise<void>;
36 static resolve <R> (value: R | Promise.Thenable<R>): Promise<R>;
37
38 /**
39 * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error
40 */
41 static reject <R> (error: any): Promise<R>;
42
43 /**
44 * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects.
45 * the array passed to all can be a mixture of promise-like objects and other objects.
46 * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
47 */
48 static all <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> (values: [T1 | Promise.Thenable<T1>, T2 | Promise.Thenable<T2>, T3 | Promise.Thenable<T3>, T4 | Promise.Thenable <T4>, T5 | Promise.Thenable<T5>, T6 | Promise.Thenable<T6>, T7 | Promise.Thenable<T7>, T8 | Promise.Thenable<T8>, T9 | Promise.Thenable<T9>, T10 | Promise.Thenable<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
49 static all <T1, T2, T3, T4, T5, T6, T7, T8, T9> (values: [T1 | Promise.Thenable<T1>, T2 | Promise.Thenable<T2>, T3 | Promise.Thenable<T3>, T4 | Promise.Thenable <T4>, T5 | Promise.Thenable<T5>, T6 | Promise.Thenable<T6>, T7 | Promise.Thenable<T7>, T8 | Promise.Thenable<T8>, T9 | Promise.Thenable<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
50 static all <T1, T2, T3, T4, T5, T6, T7, T8> (values: [T1 | Promise.Thenable<T1>, T2 | Promise.Thenable<T2>, T3 | Promise.Thenable<T3>, T4 | Promise.Thenable <T4>, T5 | Promise.Thenable<T5>, T6 | Promise.Thenable<T6>, T7 | Promise.Thenable<T7>, T8 | Promise.Thenable<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
51 static all <T1, T2, T3, T4, T5, T6, T7> (values: [T1 | Promise.Thenable<T1>, T2 | Promise.Thenable<T2>, T3 | Promise.Thenable<T3>, T4 | Promise.Thenable <T4>, T5 | Promise.Thenable<T5>, T6 | Promise.Thenable<T6>, T7 | Promise.Thenable<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
52 static all <T1, T2, T3, T4, T5, T6> (values: [T1 | Promise.Thenable<T1>, T2 | Promise.Thenable<T2>, T3 | Promise.Thenable<T3>, T4 | Promise.Thenable <T4>, T5 | Promise.Thenable<T5>, T6 | Promise.Thenable<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
53 static all <T1, T2, T3, T4, T5> (values: [T1 | Promise.Thenable<T1>, T2 | Promise.Thenable<T2>, T3 | Promise.Thenable<T3>, T4 | Promise.Thenable <T4>, T5 | Promise.Thenable<T5>]): Promise<[T1, T2, T3, T4, T5]>;
54 static all <T1, T2, T3, T4> (values: [T1 | Promise.Thenable<T1>, T2 | Promise.Thenable<T2>, T3 | Promise.Thenable<T3>, T4 | Promise.Thenable <T4>]): Promise<[T1, T2, T3, T4]>;
55 static all <T1, T2, T3> (values: [T1 | Promise.Thenable<T1>, T2 | Promise.Thenable<T2>, T3 | Promise.Thenable<T3>]): Promise<[T1, T2, T3]>;
56 static all <T1, T2> (values: [T1 | Promise.Thenable<T1>, T2 | Promise.Thenable<T2>]): Promise<[T1, T2]>;
57 static all <T1> (values: [T1 | Promise.Thenable<T1>]): Promise<[T1]>;
58 static all <TAll> (values: Array<TAll | Promise.Thenable<TAll>>): Promise<TAll[]>;
59
60 /**
61 * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
62 */
63 static race <R> (promises: (R | Promise.Thenable<R>)[]): Promise<R>;
64}
65
66declare namespace Promise {
67 export interface Thenable <R> {
68 then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
69 then <U> (onFulfilled?: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
70 }
71}
72
73export = Promise;
Note: See TracBrowser for help on using the repository browser.