From 28d3bad0a30cfc7b82239b43a2b22a69ee355881 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Wed, 11 Oct 2023 21:06:18 +0200 Subject: infra(unicorn): consistent-destructuring (#2462) --- .eslintrc.js | 1 - src/modules/helpers/unique.ts | 18 ++++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 303731dc..ecbe2320 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -49,7 +49,6 @@ module.exports = defineConfig({ // Each rule should be checked whether it should be enabled/configured and the problems fixed, or stay disabled permanently. 'unicorn/better-regex': 'off', 'unicorn/catch-error-name': 'off', - 'unicorn/consistent-destructuring': 'off', 'unicorn/consistent-function-scoping': 'off', 'unicorn/escape-case': 'off', 'unicorn/filename-case': 'off', diff --git a/src/modules/helpers/unique.ts b/src/modules/helpers/unique.ts index fd1aec33..44b3a71d 100644 --- a/src/modules/helpers/unique.ts +++ b/src/modules/helpers/unique.ts @@ -95,39 +95,37 @@ export function exec< startTime = Date.now(), maxTime = 50, maxRetries = 50, + currentIterations = 0, compare = defaultCompare, store, } = options; let { exclude } = options; - options.currentIterations = options.currentIterations ?? 0; + options.currentIterations = currentIterations; // Support single exclude argument as string if (!Array.isArray(exclude)) { exclude = [exclude]; } - // if (options.currentIterations > 0) { - // console.log('iterating', options.currentIterations) - // } - - // console.log(now - startTime) + // If out of time -> throw error. if (now - startTime >= maxTime) { return errorMessage( startTime, now, `Exceeded maxTime: ${maxTime}`, store, - options.currentIterations + currentIterations ); } - if (options.currentIterations >= maxRetries) { + // If out of retries -> throw error. + if (currentIterations >= maxRetries) { return errorMessage( startTime, now, `Exceeded maxRetries: ${maxRetries}`, store, - options.currentIterations + currentIterations ); } @@ -141,7 +139,7 @@ export function exec< return result; } - // console.log('conflict', result); + // Conflict, try again. options.currentIterations++; return exec(method, args, { ...options, -- cgit v1.2.3