MCPcopy Index your code
hub / github.com/streamlit/streamlit / requireNumberInt

Function requireNumberInt

frontend/lib/src/WidgetStateManager.ts:1527–1541  ·  view source on GitHub ↗

* Coerce a `number | Long` to a `number`. * * Our "intValue" and "intArrayValue" widget protobuf fields represent their * values with sint64, because sint32 is too small to represent the full range * of JavaScript int values. Protobufjs uses `number | Long` to represent * sint64. However, we're

(value: number | Long)

Source from the content-addressed store, hash-verified

1525 * precision (which should not be possible!), throw an error instead.
1526 */
1527function requireNumberInt(value: number | Long): number {
1528 if (typeof value === "number") {
1529 return value
1530 }
1531
1532 const longNumber = util.LongBits.from(value).toNumber()
1533 if (Number.isSafeInteger(longNumber)) {
1534 return longNumber
1535 }
1536
1537 throw new Error(
1538 // eslint-disable-next-line @typescript-eslint/no-base-to-string -- Long has a toString() method
1539 `value ${value.toString()} cannot be converted to number without a loss of precision!`
1540 )
1541}

Callers 1

getIntValueMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…