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.
11 import pTry = require('p-try');
15 const value = await pTry(() => {
16 return synchronousFunctionThatMightThrow();
25 <ValueType, ArgumentsType extends unknown[]>(
26 fn: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType,
27 ...arguments: ArgumentsType
28 ): Promise<ValueType>;
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>;