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

Function toSafeNumber

src/number.ts:30–36  ·  view source on GitHub ↗
(s: string | number)

Source from the content-addressed store, hash-verified

28 * @return {Number|String} success will return Number, otherwise return the original string.
29 */
30export function toSafeNumber(s: string | number): number | string {
31 if (typeof s === 'number') {
32 return s;
33 }
34
35 return isSafeNumberString(s) ? Number(s) : s;
36}
37
38/**
39 * Produces a random integer between the inclusive `lower` and `upper` bounds.

Callers 1

number.test.tsFile · 0.85

Calls 1

isSafeNumberStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…