Skip to content

Commit

Permalink
fix: return 0 instead of NaN if client has no hits
Browse files Browse the repository at this point in the history
  • Loading branch information
gamemaker1 committed Oct 5, 2023
1 parent 74565f4 commit ebc5cca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const parseScriptResponse = (results: RedisReply): ClientRateLimitInfo => {
if (results.length !== 2)
throw new Error(`Expected 2 replies, got ${results.length}`)

const totalHits = toInt(results[0])
const totalHits = results[0] === false ? 0 : toInt(results[0])
const timeToExpire = toInt(results[1])

const resetTime = new Date(Date.now() + timeToExpire)
Expand Down

0 comments on commit ebc5cca

Please sign in to comment.