Skip to content

Commit ebc5cca

Browse files
committed
fix: return 0 instead of NaN if client has no hits
1 parent 74565f4 commit ebc5cca

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/lib.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const parseScriptResponse = (results: RedisReply): ClientRateLimitInfo => {
3535
if (results.length !== 2)
3636
throw new Error(`Expected 2 replies, got ${results.length}`)
3737

38-
const totalHits = toInt(results[0])
38+
const totalHits = results[0] === false ? 0 : toInt(results[0])
3939
const timeToExpire = toInt(results[1])
4040

4141
const resetTime = new Date(Date.now() + timeToExpire)

0 commit comments

Comments
 (0)