MCPcopy Index your code
hub / github.com/BloombergGraphics/whatiscode / scanUnicodeCodePointEscape

Function scanUnicodeCodePointEscape

scripts/libs/esprima.js:540–570  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

538 }
539
540 function scanUnicodeCodePointEscape() {
541 var ch, code, cu1, cu2;
542
543 ch = source[index];
544 code = 0;
545
546 // At least, one hex digit is required.
547 if (ch === '}') {
548 throwUnexpectedToken();
549 }
550
551 while (index < length) {
552 ch = source[index++];
553 if (!isHexDigit(ch)) {
554 break;
555 }
556 code = code * 16 + '0123456789abcdef'.indexOf(ch.toLowerCase());
557 }
558
559 if (code > 0x10FFFF || ch !== '}') {
560 throwUnexpectedToken();
561 }
562
563 // UTF-16 Encoding
564 if (code <= 0xFFFF) {
565 return String.fromCharCode(code);
566 }
567 cu1 = ((code - 0x10000) >> 10) + 0xD800;
568 cu2 = ((code - 0x10000) & 1023) + 0xDC00;
569 return String.fromCharCode(cu1, cu2);
570 }
571
572 function getEscapedIdentifier() {
573 var ch, id;

Callers 1

scanStringLiteralFunction · 0.85

Calls 2

throwUnexpectedTokenFunction · 0.85
isHexDigitFunction · 0.85

Tested by

no test coverage detected