From 3b765b2865639b0226ba6a55c527322d5686f6ef Mon Sep 17 00:00:00 2001 From: "Jeffrey A. Robinson" Date: Tue, 11 Jan 2022 22:24:03 -0800 Subject: [PATCH] Ensure INetscriptHelper number function handles NaN --- src/Augmentation/AugmentationHelpers.tsx | 1 - src/NetscriptFunctions.ts | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Augmentation/AugmentationHelpers.tsx b/src/Augmentation/AugmentationHelpers.tsx index 8ed797b79..9d3d5fa3a 100644 --- a/src/Augmentation/AugmentationHelpers.tsx +++ b/src/Augmentation/AugmentationHelpers.tsx @@ -13,7 +13,6 @@ import { SourceFileFlags } from "../SourceFile/SourceFileFlags"; import { dialogBoxCreate } from "../ui/React/DialogBox"; import { clearObject } from "../utils/helpers/clearObject"; -import { Router } from "../ui/GameRoot"; import { WHRNG } from "../Casino/RNG"; diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index ea97083a9..6c5e219fb 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -432,8 +432,11 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { throw makeRuntimeErrorMsg(funcName, `${argName} should be a string`); }, number: (funcName: string, argName: string, v: any): number => { - if (typeof v === "number") return v; - if (!isNaN(v) && !isNaN(parseFloat(v))) return parseFloat(v); + if (!isNaN(v)) + { + if (typeof v === "number") return v; + if (!isNaN(parseFloat(v))) return parseFloat(v); + } throw makeRuntimeErrorMsg(funcName, `${argName} should be a number`); }, boolean: (v: any): boolean => {