MCPcopy
hub / github.com/webpack/webpack / _consumeAnEscapedCodePoint

Function _consumeAnEscapedCodePoint

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

Source from the content-addressed store, hash-verified

375 * @returns {number} position past the escape sequence
376 */
377const _consumeAnEscapedCodePoint = (input, pos) => {
378 // Caller has verified the `\` and the next code point form a valid
379 // escape. Hex digits: consume up to 6 hex digits, then one optional
380 // whitespace. Non-hex: consume one code point.
381 // `\` at EOF: nothing to consume; return pos so callers don't overrun.
382 if (pos >= input.length) return pos;
383 const cc = input.charCodeAt(pos);
384 pos++;
385 if (pos === input.length) return pos;
386 if (_isHexDigit(cc)) {
387 for (let i = 0; i < 5; i++) {
388 if (_isHexDigit(input.charCodeAt(pos))) pos++;
389 }
390 const trail = input.charCodeAt(pos);
391 if (_isWhiteSpace(trail)) {
392 pos++;
393 pos = consumeExtraNewline(trail, input, pos);
394 }
395 }
396 return pos;
397};
398
399/**
400 * Spec: "two code points are a valid escape" — first is `\`, second is

Callers 4

_consumeAnIdentSequenceFunction · 0.85
consumeAStringTokenFunction · 0.85
consumeAUrlTokenFunction · 0.85

Calls 3

_isHexDigitFunction · 0.85
_isWhiteSpaceFunction · 0.85
consumeExtraNewlineFunction · 0.85

Tested by

no test coverage detected