MCPcopy
hub / github.com/codesandbox/codesandbox-client / number

Function number

packages/app/static/js/babel.6.26.js:48327–48416  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48325 return key;
48326 },
48327 number = function number() {
48328
48329 // Parse a number value.
48330
48331 var number,
48332 sign = '',
48333 string = '',
48334 base = 10;
48335
48336 if (ch === '-' || ch === '+') {
48337 sign = ch;
48338 next(ch);
48339 }
48340
48341 // support for Infinity (could tweak to allow other words):
48342 if (ch === 'I') {
48343 number = word();
48344 if (typeof number !== 'number' || isNaN(number)) {
48345 error('Unexpected word for number');
48346 }
48347 return sign === '-' ? -number : number;
48348 }
48349
48350 // support for NaN
48351 if (ch === 'N') {
48352 number = word();
48353 if (!isNaN(number)) {
48354 error('expected word to be NaN');
48355 }
48356 // ignore sign as -NaN also is NaN
48357 return number;
48358 }
48359
48360 if (ch === '0') {
48361 string += ch;
48362 next();
48363 if (ch === 'x' || ch === 'X') {
48364 string += ch;
48365 next();
48366 base = 16;
48367 } else if (ch >= '0' && ch <= '9') {
48368 error('Octal literal');
48369 }
48370 }
48371
48372 switch (base) {
48373 case 10:
48374 while (ch >= '0' && ch <= '9') {
48375 string += ch;
48376 next();
48377 }
48378 if (ch === '.') {
48379 string += '.';
48380 while (next() && ch >= '0' && ch <= '9') {
48381 string += ch;
48382 }
48383 }
48384 if (ch === 'e' || ch === 'E') {

Callers 1

babel.6.26.jsFile · 0.85

Calls 5

isNaNFunction · 0.85
isFiniteFunction · 0.85
nextFunction · 0.70
wordFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected