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

Function createTextWriter

test/fixtures/snapshot/typescript.js:18208–18311  ·  view source on GitHub ↗
(newLine)

Source from the content-addressed store, hash-verified

18206 }
18207 ts.isNightly = isNightly;
18208 function createTextWriter(newLine) {
18209 var output;
18210 var indent;
18211 var lineStart;
18212 var lineCount;
18213 var linePos;
18214 var hasTrailingComment = false;
18215 function updateLineCountAndPosFor(s) {
18216 var lineStartsOfS = ts.computeLineStarts(s);
18217 if (lineStartsOfS.length > 1) {
18218 lineCount = lineCount + lineStartsOfS.length - 1;
18219 linePos = output.length - s.length + ts.last(lineStartsOfS);
18220 lineStart = (linePos - output.length) === 0;
18221 }
18222 else {
18223 lineStart = false;
18224 }
18225 }
18226 function writeText(s) {
18227 if (s && s.length) {
18228 if (lineStart) {
18229 s = getIndentString(indent) + s;
18230 lineStart = false;
18231 }
18232 output += s;
18233 updateLineCountAndPosFor(s);
18234 }
18235 }
18236 function write(s) {
18237 if (s)
18238 hasTrailingComment = false;
18239 writeText(s);
18240 }
18241 function writeComment(s) {
18242 if (s)
18243 hasTrailingComment = true;
18244 writeText(s);
18245 }
18246 function reset() {
18247 output = "";
18248 indent = 0;
18249 lineStart = true;
18250 lineCount = 0;
18251 linePos = 0;
18252 hasTrailingComment = false;
18253 }
18254 function rawWrite(s) {
18255 if (s !== undefined) {
18256 output += s;
18257 updateLineCountAndPosFor(s);
18258 hasTrailingComment = false;
18259 }
18260 }
18261 function writeLiteral(s) {
18262 if (s && s.length) {
18263 write(s);
18264 }
18265 }

Callers

nothing calls this directly

Calls 3

getIndentSizeFunction · 0.85
resetFunction · 0.70
writeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…