1 | /**
|
2 | Start a promise chain.
|
3 |
|
4 | @param function_ - The function to run to start the promise chain.
|
5 | @param arguments - Arguments to pass to `function_`.
|
6 | @returns The value of calling `function_(...arguments)`. If the function throws an error, the returned `Promise` will be rejected with that error.
|
7 |
|
8 | @example
|
9 | ```
|
10 | import pTry from 'p-try';
|
11 |
|
12 | try {
|
13 | const value = await pTry(() => {
|
14 | return synchronousFunctionThatMightThrow();
|
15 | });
|
16 | console.log(value);
|
17 | } catch (error) {
|
18 | console.error(error);
|
19 | }
|
20 | ```
|
21 | */
|
22 | export default function<ValueType, ArgumentsType extends unknown[]>(
|
23 | function_: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType,
|
24 | ...arguments: ArgumentsType
|
25 | ): Promise<ValueType>;
|