MCPcopy
hub / github.com/coder/mux / parseInteger

Function parseInteger

src/node/services/analytics/etl.test.ts:107–120  ·  view source on GitHub ↗
(value: unknown, fieldName: string)

Source from the content-addressed store, hash-verified

105}
106
107function parseInteger(value: unknown, fieldName: string): number {
108 if (typeof value === "number") {
109 assert(Number.isInteger(value), `${fieldName} should be an integer number`);
110 return value;
111 }
112
113 if (typeof value === "bigint") {
114 const coerced = Number(value);
115 assert(Number.isSafeInteger(coerced), `${fieldName} should coerce to a safe integer`);
116 return coerced;
117 }
118
119 throw new TypeError(`${fieldName} should be an integer-compatible value`);
120}
121
122function parseBooleanFromInteger(value: unknown, fieldName: string): boolean {
123 const parsed = parseInteger(value, fieldName);

Callers 4

parseBooleanFromIntegerFunction · 0.85
queryEventCountFunction · 0.85
etl.test.tsFile · 0.85
normalizeSelectedRowFunction · 0.85

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected