MCPcopy
hub / github.com/prisma/prisma / parseInteger

Function parseInteger

packages/query-plan-executor/src/formats/numeric.ts:8–21  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

6 * @throws {Error} If the integer string is invalid.
7 */
8export function parseInteger(value: string): number {
9 const number = Number.parseInt(value, 10)
10
11 if (isNaN(number)) {
12 throw new Error(`Invalid integer: ${value}`)
13 }
14
15 // Ensure we don't have trailing characters that were ignored by `parseInt`.
16 if (number.toString() !== value) {
17 throw new Error(`Invalid integer: ${value}`)
18 }
19
20 return number
21}

Callers 3

parseDurationFunction · 0.90
parseSizeFunction · 0.90
numeric.test.tsFile · 0.90

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected