MCPcopy Create free account
hub / github.com/dchester/jsonpath / getEscapedIdentifier

Function getEscapedIdentifier

jsonpath.js:537–580  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

535 }
536
537 function getEscapedIdentifier() {
538 var ch, id;
539
540 ch = source.charCodeAt(index++);
541 id = String.fromCharCode(ch);
542
543 // '\u' (U+005C, U+0075) denotes an escaped character.
544 if (ch === 0x5C) {
545 if (source.charCodeAt(index) !== 0x75) {
546 throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
547 }
548 ++index;
549 ch = scanHexEscape('u');
550 if (!ch || ch === '\\' || !isIdentifierStart(ch.charCodeAt(0))) {
551 throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
552 }
553 id = ch;
554 }
555
556 while (index < length) {
557 ch = source.charCodeAt(index);
558 if (!isIdentifierPart(ch)) {
559 break;
560 }
561 ++index;
562 id += String.fromCharCode(ch);
563
564 // '\u' (U+005C, U+0075) denotes an escaped character.
565 if (ch === 0x5C) {
566 id = id.substr(0, id.length - 1);
567 if (source.charCodeAt(index) !== 0x75) {
568 throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
569 }
570 ++index;
571 ch = scanHexEscape('u');
572 if (!ch || ch === '\\' || !isIdentifierPart(ch.charCodeAt(0))) {
573 throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
574 }
575 id += ch;
576 }
577 }
578
579 return id;
580 }
581
582 function getIdentifier() {
583 var start, ch;

Callers 2

getIdentifierFunction · 0.85
scanIdentifierFunction · 0.85

Calls 4

throwErrorFunction · 0.85
scanHexEscapeFunction · 0.85
isIdentifierStartFunction · 0.85
isIdentifierPartFunction · 0.85

Tested by

no test coverage detected