IPVGO: Improve type checking and documentation (#2028)

This commit is contained in:
Michael Ficocelli
2025-03-23 02:59:46 -04:00
committed by GitHub
parent 41c497161f
commit 70a083b34b
21 changed files with 164 additions and 119 deletions
+9
View File
@@ -73,6 +73,7 @@ export const helpers = {
positiveSafeInteger,
positiveNumber,
scriptArgs,
boolean,
runOptions,
spawnOptions,
argsToString,
@@ -181,6 +182,14 @@ function scriptArgs(ctx: NetscriptContext, args: unknown) {
return args;
}
/** Converts the provided value for v to a boolean, throwing if it is not */
function boolean(ctx: NetscriptContext, argName: string, v: unknown): boolean {
if (typeof v !== "boolean") {
throw errorMessage(ctx, `${argName} must be a boolean, was ${v}`, "TYPE");
}
return v;
}
function runOptions(ctx: NetscriptContext, threadOrOption: unknown): CompleteRunOptions {
const result: CompleteRunOptions = {
threads: 1 as PositiveInteger,