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

Function computeLineStarts

test/fixtures/snapshot/typescript.js:10275–10302  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

10273 ts.stringToToken = stringToToken;
10274 /* @internal */
10275 function computeLineStarts(text) {
10276 var result = new Array();
10277 var pos = 0;
10278 var lineStart = 0;
10279 while (pos < text.length) {
10280 var ch = text.charCodeAt(pos);
10281 pos++;
10282 switch (ch) {
10283 case 13 /* CharacterCodes.carriageReturn */:
10284 if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
10285 pos++;
10286 }
10287 // falls through
10288 case 10 /* CharacterCodes.lineFeed */:
10289 result.push(lineStart);
10290 lineStart = pos;
10291 break;
10292 default:
10293 if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) {
10294 result.push(lineStart);
10295 lineStart = pos;
10296 }
10297 break;
10298 }
10299 }
10300 result.push(lineStart);
10301 return result;
10302 }
10303 ts.computeLineStarts = computeLineStarts;
10304 function getPositionOfLineAndCharacter(sourceFile, line, character, allowEdits) {
10305 return sourceFile.getPositionOfLineAndCharacter ?

Callers 2

getLineStartsFunction · 0.85

Calls 2

isLineBreakFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…