Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanmino committed Feb 2, 2021
1 parent bc8d30a commit 93b8360
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,7 @@ export async function safelyExecute(operation: () => Promise<any>, logError = fa
* @param timeout - Timeout to fail the operation
* @returns - Promise resolving to the result of the async operation
*/
export async function safelyExecuteWithTimeout(
operation: () => Promise<any>,
logError = false,
timeout = 500,
) {
export async function safelyExecuteWithTimeout(operation: () => Promise<any>, logError = false, timeout = 500) {
try {
return await Promise.race([
operation(),
Expand Down
8 changes: 4 additions & 4 deletions tests/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ describe('util', () => {
});

it('should resolve', async () => {
const response = await util.safelyExecuteWithTimeout(() => {
return new Promise((res) => setTimeout(() => res('response'), 200));
});
expect(response).toEqual('response');
const response = await util.safelyExecuteWithTimeout(() => {
return new Promise((res) => setTimeout(() => res('response'), 200));
});
expect(response).toEqual('response');
});

it('should timeout', () => {
Expand Down

0 comments on commit 93b8360

Please sign in to comment.