MCPcopy Index your code
hub / github.com/nodejs/node / skipTrivia

Function skipTrivia

test/fixtures/snapshot/typescript.js:10469–10557  ·  view source on GitHub ↗
(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc)

Source from the content-addressed store, hash-verified

10467 ts.couldStartTrivia = couldStartTrivia;
10468 /* @internal */
10469 function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments, inJSDoc) {
10470 if (ts.positionIsSynthesized(pos)) {
10471 return pos;
10472 }
10473 var canConsumeStar = false;
10474 // Keep in sync with couldStartTrivia
10475 while (true) {
10476 var ch = text.charCodeAt(pos);
10477 switch (ch) {
10478 case 13 /* CharacterCodes.carriageReturn */:
10479 if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) {
10480 pos++;
10481 }
10482 // falls through
10483 case 10 /* CharacterCodes.lineFeed */:
10484 pos++;
10485 if (stopAfterLineBreak) {
10486 return pos;
10487 }
10488 canConsumeStar = !!inJSDoc;
10489 continue;
10490 case 9 /* CharacterCodes.tab */:
10491 case 11 /* CharacterCodes.verticalTab */:
10492 case 12 /* CharacterCodes.formFeed */:
10493 case 32 /* CharacterCodes.space */:
10494 pos++;
10495 continue;
10496 case 47 /* CharacterCodes.slash */:
10497 if (stopAtComments) {
10498 break;
10499 }
10500 if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
10501 pos += 2;
10502 while (pos < text.length) {
10503 if (isLineBreak(text.charCodeAt(pos))) {
10504 break;
10505 }
10506 pos++;
10507 }
10508 canConsumeStar = false;
10509 continue;
10510 }
10511 if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
10512 pos += 2;
10513 while (pos < text.length) {
10514 if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
10515 pos += 2;
10516 break;
10517 }
10518 pos++;
10519 }
10520 canConsumeStar = false;
10521 continue;
10522 }
10523 break;
10524 case 60 /* CharacterCodes.lessThan */:
10525 case 124 /* CharacterCodes.bar */:
10526 case 61 /* CharacterCodes.equals */:

Callers

nothing calls this directly

Calls 6

isLineBreakFunction · 0.85
isConflictMarkerTriviaFunction · 0.85
scanConflictMarkerTriviaFunction · 0.85
isShebangTriviaFunction · 0.85
scanShebangTriviaFunction · 0.85
isWhiteSpaceLikeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…