Skip to content

Commit

Permalink
simplify getHttp2IdleTime
Browse files Browse the repository at this point in the history
  • Loading branch information
henryfauna committed Jun 14, 2022
1 parent 3dee1bd commit 4742d8f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,13 @@ function getHttp2SessionIdleTime(configuredIdleTime) {
// attemp to set the idle time to the env value and then the configured value
const values = [envIdleTime, configuredIdleTime]
for (const rawValue of values) {
const parsedValue = parseInt(rawValue, 10)
const parsedValue = rawValue === 'Infinity'
? Number.MAX_SAFE_INTEGER
: parseInt(rawValue, 10)
const isNegative = parsedValue < 0
const isInfinity = rawValue === 'Infinity'
const isGreaterThanMax = parsedValue > maxIdleTime || isInfinity
const isGreaterThanMax = parsedValue > maxIdleTime
// if we didn't get infinity or a positive integer move to the next value
if (isNegative) continue
if (!isInfinity && !parsedValue) continue
if (isNegative || !parsedValue) continue
// if we did get something valid constrain it to the ceiling
value = parsedValue
if (isGreaterThanMax) value = maxIdleTime
Expand Down

0 comments on commit 4742d8f

Please sign in to comment.