From ebc5ccabfb0316e9e2f54dc4e9cf2367a7eb5f31 Mon Sep 17 00:00:00 2001 From: Vedant K Date: Thu, 5 Oct 2023 15:58:03 +0530 Subject: [PATCH] fix: return 0 instead of `NaN` if client has no hits --- source/lib.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/lib.ts b/source/lib.ts index 2021164..536212d 100644 --- a/source/lib.ts +++ b/source/lib.ts @@ -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)