source: trip-planner-front/node_modules/p-try/index.d.ts@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1declare const pTry: {
2 /**
3 Start a promise chain.
4
5 @param fn - The function to run to start the promise chain.
6 @param arguments - Arguments to pass to `fn`.
7 @returns The value of calling `fn(...arguments)`. If the function throws an error, the returned `Promise` will be rejected with that error.
8
9 @example
10 ```
11 import pTry = require('p-try');
12
13 (async () => {
14 try {
15 const value = await pTry(() => {
16 return synchronousFunctionThatMightThrow();
17 });
18 console.log(value);
19 } catch (error) {
20 console.error(error);
21 }
22 })();
23 ```
24 */
25 <ValueType, ArgumentsType extends unknown[]>(
26 fn: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType,
27 ...arguments: ArgumentsType
28 ): Promise<ValueType>;
29
30 // TODO: remove this in the next major version, refactor the whole definition to:
31 // declare function pTry<ValueType, ArgumentsType extends unknown[]>(
32 // fn: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType,
33 // ...arguments: ArgumentsType
34 // ): Promise<ValueType>;
35 // export = pTry;
36 default: typeof pTry;
37};
38
39export = pTry;
Note: See TracBrowser for help on using the repository browser.