MCPcopy Create free account
hub / github.com/node-modules/utility / isSafeNumberString

Function isSafeNumberString

src/number.ts:13–22  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

11 * @param {String} s number format string, like `"123"`, `"-1000123123123123123123"`
12 */
13export function isSafeNumberString(s: string) {
14 if (s[0] === '-') {
15 s = s.substring(1);
16 }
17 if (s.length < MAX_SAFE_INTEGER_STR_LENGTH ||
18 (s.length === MAX_SAFE_INTEGER_STR_LENGTH && s <= MAX_SAFE_INTEGER_STR)) {
19 return true;
20 }
21 return false;
22}
23
24/**
25 * Convert string to Number if string in safe Number scope.

Callers 1

toSafeNumberFunction · 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…