MCPcopy Index your code
hub / github.com/reactjs/react-rails / scanStringLiteral

Function scanStringLiteral

lib/assets/javascripts/JSXTransformer.js:3480–3589  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3478 // 7.8.4 String Literals
3479
3480 function scanStringLiteral() {
3481 var str = '', quote, start, ch, code, unescaped, restore, octal = false;
3482
3483 quote = source[index];
3484 assert((quote === '\'' || quote === '"'),
3485 'String literal must starts with a quote');
3486
3487 start = index;
3488 ++index;
3489
3490 while (index < length) {
3491 ch = source[index++];
3492
3493 if (ch === quote) {
3494 quote = '';
3495 break;
3496 } else if (ch === '\\') {
3497 ch = source[index++];
3498 if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
3499 switch (ch) {
3500 case 'n':
3501 str += '\n';
3502 break;
3503 case 'r':
3504 str += '\r';
3505 break;
3506 case 't':
3507 str += '\t';
3508 break;
3509 case 'u':
3510 case 'x':
3511 if (source[index] === '{') {
3512 ++index;
3513 str += scanUnicodeCodePointEscape();
3514 } else {
3515 restore = index;
3516 unescaped = scanHexEscape(ch);
3517 if (unescaped) {
3518 str += unescaped;
3519 } else {
3520 index = restore;
3521 str += ch;
3522 }
3523 }
3524 break;
3525 case 'b':
3526 str += '\b';
3527 break;
3528 case 'f':
3529 str += '\f';
3530 break;
3531 case 'v':
3532 str += '\x0B';
3533 break;
3534
3535 default:
3536 if (isOctalDigit(ch)) {
3537 code = '01234567'.indexOf(ch);

Callers 1

advanceFunction · 0.85

Calls 6

assertFunction · 0.85
isLineTerminatorFunction · 0.85
scanHexEscapeFunction · 0.85
isOctalDigitFunction · 0.85
throwErrorFunction · 0.85

Tested by

no test coverage detected