MCPcopy
hub / github.com/inlife/nexrender / scanStringLiteral

Function scanStringLiteral

packages/nexrender-action-lottie/lib/jsx/esprima.jsx:958–1053  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

956
957
958 function scanStringLiteral() {
959 var str = '', quote, start, ch, unescaped, octToDec, octal = false;
960
961 quote = source[index];
962 assert((quote === '\'' || quote === '"'),
963 'String literal must starts with a quote');
964
965 start = index;
966 ++index;
967
968 while (index < length) {
969 ch = source[index++];
970
971 if (ch === quote) {
972 quote = '';
973 break;
974 } else if (ch === '\\') {
975 ch = source[index++];
976 if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
977 switch (ch) {
978 case 'u':
979 case 'x':
980 if (source[index] === '{') {
981 ++index;
982 str += scanUnicodeCodePointEscape();
983 } else {
984 unescaped = scanHexEscape(ch);
985 if (!unescaped) {
986 throw throwUnexpectedToken();
987 }
988 str += unescaped;
989 }
990 break;
991 case 'n':
992 str += '\n';
993 break;
994 case 'r':
995 str += '\r';
996 break;
997 case 't':
998 str += '\t';
999 break;
1000 case 'b':
1001 str += '\b';
1002 break;
1003 case 'f':
1004 str += '\f';
1005 break;
1006 case 'v':
1007 str += '\x0B';
1008 break;
1009 case '8':
1010 case '9':
1011 str += ch;
1012 tolerateUnexpectedToken();
1013 break;
1014
1015 default:

Callers 1

advanceFunction · 0.85

Calls 8

assertFunction · 0.85
scanHexEscapeFunction · 0.85
throwUnexpectedTokenFunction · 0.85
tolerateUnexpectedTokenFunction · 0.85
isOctalDigitFunction · 0.85
octalToDecimalFunction · 0.85
isLineTerminatorFunction · 0.70

Tested by

no test coverage detected