MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / optionalNumber

Function optionalNumber

src/app/service/agent/core/tools/param_utils.ts:32–39  ·  view source on GitHub ↗
(args: Record<string, unknown>, name: string)

Source from the content-addressed store, hash-verified

30
31/** 获取可选数字参数(支持字符串转数字) */
32export function optionalNumber(args: Record<string, unknown>, name: string): number | undefined {
33 const val = args[name];
34 if (val == null) return undefined;
35 if (typeof val === "number") return val;
36 const num = Number(val);
37 if (isNaN(num)) return undefined;
38 return num;
39}
40
41/** 获取可选布尔参数 */
42export function optionalBoolean(

Callers 3

executeMethod · 0.90
createTabToolsFunction · 0.90
executeMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected