diff options
| author | ST-DDT <[email protected]> | 2023-10-11 21:06:18 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-11 19:06:18 +0000 |
| commit | 28d3bad0a30cfc7b82239b43a2b22a69ee355881 (patch) | |
| tree | 339660596339cd350b0a79a855ab3ce2d3940d01 | |
| parent | 5395074f66861c544e1d97690b2f4e0ab7def747 (diff) | |
| download | faker-28d3bad0a30cfc7b82239b43a2b22a69ee355881.tar.xz faker-28d3bad0a30cfc7b82239b43a2b22a69ee355881.zip | |
infra(unicorn): consistent-destructuring (#2462)
| -rw-r--r-- | .eslintrc.js | 1 | ||||
| -rw-r--r-- | 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, |
