Skip to content

Commit

Permalink
tsconfig?
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Apr 15, 2024
1 parent f3ce5e0 commit 22b1658
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@ export const defaultRetryConditions: RetryConditions = {
],
}

/** Merges two `RetryCondition`s together, including all properties from each */
export const unionRetryConditions = (left: RetryConditions, right: RetryConditions): RetryConditions => ({
methods: [...new Set([...left.methods, ...right.methods])],
statuses: [...new Set([...left.statuses, ...right.statuses])],
errorCodes: [...new Set([...left.errorCodes, ...right.errorCodes])],
})

/** Merges two `RetryCondition`s together, including only properties that appear in both */
export const intersectRetryConditions = (left: RetryConditions, right: RetryConditions): RetryConditions => {
const rightMethods = new Set(right.methods)
const rightStatuses = new Set(right.statuses)
const rightErrorCodes = new Set(right.errorCodes)
return {
methods: left.methods.filter(m => rightMethods.has(m)),
statuses: left.statuses.filter(s => rightStatuses.has(s)),
errorCodes: left.errorCodes.filter(c => rightErrorCodes.has(c)),
}
}

export const retryOnFailure = ({conditions = defaultRetryConditions} = {}): ShouldRetry => {
const methods = new Set(conditions.methods)
const statuses = new Set(conditions.statuses)
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"DOM"
],
"target": "ES2022",
"module": "ES2022",
"module": "NodeNext",
"strict": true,
"noEmit": true,
"noErrorTruncation": true,
Expand Down

0 comments on commit 22b1658

Please sign in to comment.