From 408e824882bd6a2d5cfd2095be31b5f3619d050d Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Sun, 2 Aug 2026 17:33:13 +0530 Subject: [PATCH] fix: code quality and safety improvements --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index c769e99..0217095 100644 --- a/src/index.ts +++ b/src/index.ts @@ -66,10 +66,10 @@ export function registerPricing(provider: string, model: string, pricing: ModelP if (!pricing || typeof pricing !== 'object') { throw new Error('TokenFirewall: Pricing must be an object'); } - if (typeof pricing.input !== 'number' || pricing.input < 0 || !isFinite(pricing.input) || isNaN(pricing.input)) { + if (typeof pricing.input !== 'number' || pricing.input < 0 || !isFinite(pricing.input) || Number.isNaN(pricing.input)) { throw new Error('TokenFirewall: Pricing input must be a non-negative finite number'); } - if (typeof pricing.output !== 'number' || pricing.output < 0 || !isFinite(pricing.output) || isNaN(pricing.output)) { + if (typeof pricing.output !== 'number' || pricing.output < 0 || !isFinite(pricing.output) || Number.isNaN(pricing.output)) { throw new Error('TokenFirewall: Pricing output must be a non-negative finite number'); } @@ -90,7 +90,7 @@ export function registerContextLimit(provider: string, model: string, contextLim if (!model || typeof model !== 'string' || model.trim() === '') { throw new Error('TokenFirewall: Model must be a non-empty string'); } - if (typeof contextLimit !== 'number' || contextLimit <= 0 || !isFinite(contextLimit) || isNaN(contextLimit)) { + if (typeof contextLimit !== 'number' || contextLimit <= 0 || !isFinite(contextLimit) || Number.isNaN(contextLimit)) { throw new Error('TokenFirewall: Context limit must be a positive finite number'); }