aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2023-10-11 21:06:18 +0200
committerGitHub <[email protected]>2023-10-11 19:06:18 +0000
commit28d3bad0a30cfc7b82239b43a2b22a69ee355881 (patch)
tree339660596339cd350b0a79a855ab3ce2d3940d01 /src
parent5395074f66861c544e1d97690b2f4e0ab7def747 (diff)
downloadfaker-28d3bad0a30cfc7b82239b43a2b22a69ee355881.tar.xz
faker-28d3bad0a30cfc7b82239b43a2b22a69ee355881.zip
infra(unicorn): consistent-destructuring (#2462)
Diffstat (limited to 'src')
-rw-r--r--src/modules/helpers/unique.ts18
1 files changed, 8 insertions, 10 deletions
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,