MCPcopy Index your code
hub / github.com/reactstrap/reactstrap / toNumber

Function toNumber

src/utils.js:243–269  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

241}
242
243export function toNumber(value) {
244 const type = typeof value;
245 const NAN = 0 / 0;
246 if (type === 'number') {
247 return value;
248 }
249 if (
250 type === 'symbol' ||
251 (type === 'object' && getTag(value) === '[object Symbol]')
252 ) {
253 return NAN;
254 }
255 if (isObject(value)) {
256 const other = typeof value.valueOf === 'function' ? value.valueOf() : value;
257 value = isObject(other) ? `${other}` : other;
258 }
259 if (type !== 'string') {
260 return value === 0 ? value : +value;
261 }
262 value = value.replace(/^\s+|\s+$/g, '');
263 const isBinary = /^0b[01]+$/i.test(value);
264 return isBinary || /^0o[0-7]+$/i.test(value)
265 ? parseInt(value.slice(2), isBinary ? 2 : 8)
266 : /^[-+]0x[0-9a-f]+$/i.test(value)
267 ? NAN
268 : +value;
269}
270
271export function isFunction(value) {
272 if (!isObject(value)) {

Callers 1

ProgressFunction · 0.90

Calls 2

getTagFunction · 0.85
isObjectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…