Skip to content

Commit

Permalink
integer checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperwfloyd committed Apr 6, 2023
1 parent a36f5b7 commit 44da713
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@typescript-eslint/no-unnecessary-condition": "off",
"@typescript-eslint/no-unsafe-call": "error",
"@typescript-eslint/prefer-readonly-parameter-types": "off",
"@typescript-eslint/strict-boolean-expressions": "off",
"block-scoped-var": "error",
"camelcase": "error",
"eqeqeq": "error",
Expand Down
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,19 @@ const fancyfetch: typeof Fancyfetch = async (resource, options, extras) => {
)}`
);
if (
typeof extrasToUse?.maxAttempts === `number` &&
(!Number.isInteger(extrasToUse.maxAttempts) || extrasToUse.maxAttempts < 1)
extrasToUse?.maxAttempts &&
(typeof extrasToUse?.maxAttempts !== `number` ||
!Number.isInteger(extrasToUse.maxAttempts) ||
extrasToUse.maxAttempts < 1)
)
throw new Error(
`Error in fancyfetch: extras.maxAttempts must be a positive integer.\n\nextras.maxAttempts: ${extrasToUse.maxAttempts}`
);
if (
typeof extrasToUse?.retryDelay === `number` &&
(!Number.isInteger(extrasToUse.maxAttempts) || extrasToUse.maxAttempts < 1)
extrasToUse?.retryDelay &&
(typeof extrasToUse?.retryDelay !== `number` ||
!Number.isInteger(extrasToUse.retryDelay) ||
extrasToUse.retryDelay < 1)
)
throw new Error(
`Error in fancyfetch: extras.retryDelay must be a positive integer.\n\nextras.retryDelay: ${String(
Expand Down

0 comments on commit 44da713

Please sign in to comment.