MCPcopy
hub / github.com/niklasvh/html2canvas / consumeNumber

Method consumeNumber

src/css/syntax/tokenizer.ts:707–740  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

705 }
706
707 private consumeNumber() {
708 const repr = [];
709 let type = FLAG_INTEGER;
710 let c1 = this.peekCodePoint(0);
711 if (c1 === PLUS_SIGN || c1 === HYPHEN_MINUS) {
712 repr.push(this.consumeCodePoint());
713 }
714
715 while (isDigit(this.peekCodePoint(0))) {
716 repr.push(this.consumeCodePoint());
717 }
718 c1 = this.peekCodePoint(0);
719 let c2 = this.peekCodePoint(1);
720 if (c1 === FULL_STOP && isDigit(c2)) {
721 repr.push(this.consumeCodePoint(), this.consumeCodePoint());
722 type = FLAG_NUMBER;
723 while (isDigit(this.peekCodePoint(0))) {
724 repr.push(this.consumeCodePoint());
725 }
726 }
727
728 c1 = this.peekCodePoint(0);
729 c2 = this.peekCodePoint(1);
730 const c3 = this.peekCodePoint(2);
731 if ((c1 === E || c1 === e) && (((c2 === PLUS_SIGN || c2 === HYPHEN_MINUS) && isDigit(c3)) || isDigit(c2))) {
732 repr.push(this.consumeCodePoint(), this.consumeCodePoint());
733 type = FLAG_NUMBER;
734 while (isDigit(this.peekCodePoint(0))) {
735 repr.push(this.consumeCodePoint());
736 }
737 }
738
739 return [stringToNumber(repr), type];
740 }
741
742 private consumeNumericToken(): NumberValueToken | DimensionToken {
743 const [number, flags] = this.consumeNumber();

Callers 1

consumeNumericTokenMethod · 0.95

Calls 4

peekCodePointMethod · 0.95
consumeCodePointMethod · 0.95
isDigitFunction · 0.85
stringToNumberFunction · 0.85

Tested by

no test coverage detected