MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / indentPiece

Method indentPiece

src/MagicString.ts:451–461  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

449 // `str` starts a line in the generated output. Any match after offset 0
450 // necessarily follows a line break inside `str`, so it always gets indented.
451 const indentPiece = (str: string) => {
452 if (str === '')
453 return str
454
455 const indented = str.replace(pattern, (match: string, offset: number) =>
456 offset > 0 || shouldIndentNextCharacter ? `${resolvedIndentStr}${match}` : match)
457
458 shouldIndentNextCharacter = str[str.length - 1] === '\n'
459
460 return indented
461 }
462
463 this.intro = indentPiece(this.intro)
464

Callers

nothing calls this directly

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected