MCPcopy
hub / github.com/Exrick/xpay / indentString

Function indentString

xpay-code/src/main/resources/static/swagger/swagger-ui.js:10349–10373  ·  view source on GitHub ↗
(string, spaces)

Source from the content-addressed store, hash-verified

10347
10348// Indents every line in a string. Empty lines (\n only) are not indented.
10349function indentString(string, spaces) {
10350 var ind = common.repeat(' ', spaces),
10351 position = 0,
10352 next = -1,
10353 result = '',
10354 line,
10355 length = string.length;
10356
10357 while (position < length) {
10358 next = string.indexOf('\n', position);
10359 if (next === -1) {
10360 line = string.slice(position);
10361 position = length;
10362 } else {
10363 line = string.slice(position, next + 1);
10364 position = next + 1;
10365 }
10366
10367 if (line.length && line !== '\n') result += ind;
10368
10369 result += line;
10370 }
10371
10372 return result;
10373}
10374
10375function generateNextLine(state, level) {
10376 return '\n' + common.repeat(' ', state.indent * level);

Callers 1

writeScalarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected