MCPcopy Create free account
hub / github.com/nodejs/node / getIndentationString

Function getIndentationString

test/fixtures/snapshot/typescript.js:148028–148066  ·  view source on GitHub ↗
(indentation, options)

Source from the content-addressed store, hash-verified

148026 var internedTabsIndentation;
148027 var internedSpacesIndentation;
148028 function getIndentationString(indentation, options) {
148029 // reset interned strings if FormatCodeOptions were changed
148030 var resetInternedStrings = !internedSizes || (internedSizes.tabSize !== options.tabSize || internedSizes.indentSize !== options.indentSize);
148031 if (resetInternedStrings) {
148032 internedSizes = { tabSize: options.tabSize, indentSize: options.indentSize };
148033 internedTabsIndentation = internedSpacesIndentation = undefined;
148034 }
148035 if (!options.convertTabsToSpaces) {
148036 var tabs = Math.floor(indentation / options.tabSize);
148037 var spaces = indentation - tabs * options.tabSize;
148038 var tabString = void 0;
148039 if (!internedTabsIndentation) {
148040 internedTabsIndentation = [];
148041 }
148042 if (internedTabsIndentation[tabs] === undefined) {
148043 internedTabsIndentation[tabs] = tabString = ts.repeatString("\t", tabs);
148044 }
148045 else {
148046 tabString = internedTabsIndentation[tabs];
148047 }
148048 return spaces ? tabString + ts.repeatString(" ", spaces) : tabString;
148049 }
148050 else {
148051 var spacesString = void 0;
148052 var quotient = Math.floor(indentation / options.indentSize);
148053 var remainder = indentation % options.indentSize;
148054 if (!internedSpacesIndentation) {
148055 internedSpacesIndentation = [];
148056 }
148057 if (internedSpacesIndentation[quotient] === undefined) {
148058 spacesString = ts.repeatString(" ", options.indentSize * quotient);
148059 internedSpacesIndentation[quotient] = spacesString;
148060 }
148061 else {
148062 spacesString = internedSpacesIndentation[quotient];
148063 }
148064 return remainder ? spacesString + ts.repeatString(" ", remainder) : spacesString;
148065 }
148066 }
148067 formatting.getIndentationString = getIndentationString;
148068 })(formatting = ts.formatting || (ts.formatting = {}));
148069})(ts || (ts = {}));

Callers 2

insertIndentationFunction · 0.85
indentMultilineCommentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected