MCPcopy
hub / github.com/thesysdev/openui / toNumber

Function toNumber

packages/lang-core/src/parser/builtins.ts:31–39  ·  view source on GitHub ↗
(val: unknown)

Source from the content-addressed store, hash-verified

29}
30
31function toNumber(val: unknown): number {
32 if (typeof val === "number") return val;
33 if (typeof val === "string") {
34 const n = Number(val);
35 return isNaN(n) ? 0 : n;
36 }
37 if (typeof val === "boolean") return val ? 1 : 0;
38 return 0;
39}
40
41export const BUILTINS: Record<string, BuiltinDef> = {
42 Count: {

Callers 2

evaluateFunction · 0.90
builtins.tsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected