MCPcopy
hub / github.com/sparkjsdev/spark / unindentLines

Function unindentLines

src/dyno/base.ts:451–481  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

449}
450
451export function unindentLines(s: string): string[] {
452 let seenNonEmpty = false;
453 const lines = s
454 .split("\n")
455 .map((line) => {
456 const trimmedLine = line.trimEnd();
457 if (seenNonEmpty) {
458 return trimmedLine;
459 }
460 if (trimmedLine.length > 0) {
461 seenNonEmpty = true;
462 return trimmedLine;
463 }
464 return null;
465 })
466 .filter((line) => line != null);
467 while (lines.length > 0 && lines[lines.length - 1].length === 0) {
468 lines.pop();
469 }
470 if (lines.length === 0) {
471 return [];
472 }
473
474 const indent = lines[0].match(/^\s*/)?.[0];
475 if (!indent) {
476 return lines; // No indent, return as is
477 }
478 // Remove indent from the beginning of each line
479 const regex = new RegExp(`^${indent}`);
480 return lines.map((line) => line.replace(regex, ""));
481}
482
483export function unindent(s: string): string {
484 return unindentLines(s).join("\n");

Callers 15

evaluatePackedSHFunction · 0.90
EmptySplatSourceClass · 0.90
maybeLookupIndexFunction · 0.90
maybeInjectSplatRgbaFunction · 0.90
computeSortMetricFunction · 0.90
applyGsplatSkinningFunction · 0.90
applyCovSplatDQSkinningFunction · 0.90
applyCovSplatLBSkinningFunction · 0.90
evaluateExtSHFunction · 0.90
prepareGenerateMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected