MCPcopy
hub / github.com/webpack/webpack / _consumeANumber

Function _consumeANumber

lib/css/syntax.js:507–536  ·  view source on GitHub ↗
(input, pos)

Source from the content-addressed store, hash-verified

505 * @returns {number} position just past the number
506 */
507const _consumeANumber = (input, pos) => {
508 let cc = input.charCodeAt(pos);
509 if (cc === CC_HYPHEN_MINUS || cc === CC_PLUS_SIGN) {
510 pos++;
511 }
512 while (_isDigit(input.charCodeAt(pos))) pos++;
513 if (
514 input.charCodeAt(pos) === CC_FULL_STOP &&
515 _isDigit(input.charCodeAt(pos + 1))
516 ) {
517 pos++;
518 while (_isDigit(input.charCodeAt(pos))) pos++;
519 }
520 cc = input.charCodeAt(pos);
521 if (
522 (cc === CC_LOWER_E || cc === CC_UPPER_E) &&
523 (((input.charCodeAt(pos + 1) === CC_HYPHEN_MINUS ||
524 input.charCodeAt(pos + 1) === CC_PLUS_SIGN) &&
525 _isDigit(input.charCodeAt(pos + 2))) ||
526 _isDigit(input.charCodeAt(pos + 1)))
527 ) {
528 pos++;
529 cc = input.charCodeAt(pos);
530 if (cc === CC_PLUS_SIGN || cc === CC_HYPHEN_MINUS) {
531 pos++;
532 }
533 while (_isDigit(input.charCodeAt(pos))) pos++;
534 }
535 return pos;
536};
537
538/**
539 * Spec recovery: when the tokenizer realises it's mid-bad-url, consume

Callers 5

consumeANumericTokenFunction · 0.85
numericValueMethod · 0.85
typeFlagMethod · 0.85
unitMethod · 0.85
syntax.jsFile · 0.85

Calls 1

_isDigitFunction · 0.85

Tested by

no test coverage detected