Skip to content

Commit

Permalink
(#5) Removed code smell while working on sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
s1hofmann committed Aug 12, 2020
1 parent a738e19 commit d8cc180
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/util/poll-action.function.ts
@@ -1,9 +1,9 @@
export function timeout<R>(updateIntervalMs: number, maxDurationMs: number, action: (...params: any) => Promise<R>): Promise<R> {
return new Promise<R>((resolve, reject) => {
let interval: NodeJS.Timeout;
const timeout = setTimeout(
const maxTimeout = setTimeout(
() => {
clearTimeout(timeout);
clearTimeout(maxTimeout);
if (interval) {
clearTimeout(interval);
}
Expand All @@ -17,7 +17,7 @@ export function timeout<R>(updateIntervalMs: number, maxDurationMs: number, acti
if (!result) {
interval = setTimeout(intervalFunc, updateIntervalMs);
} else {
clearTimeout(timeout);
clearTimeout(maxTimeout);
clearTimeout(interval);
resolve(result);
}
Expand All @@ -31,7 +31,7 @@ export function timeout<R>(updateIntervalMs: number, maxDurationMs: number, acti
if (!result) {
startInterval();
} else {
clearTimeout(timeout);
clearTimeout(maxTimeout);
resolve(result);
}
}).catch(() => {
Expand Down

0 comments on commit d8cc180

Please sign in to comment.