Ensure INetscriptHelper number function handles NaN

This commit is contained in:
Jeffrey A. Robinson
2022-01-11 22:24:03 -08:00
parent e9db656e13
commit 3b765b2865
2 changed files with 5 additions and 3 deletions
+5 -2
View File
@@ -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 => {