MCPcopy Create free account
hub / github.com/Noumena-Network/code / padAligned

Function padAligned

src/utils/markdown.ts:781–796  ·  view source on GitHub ↗
(
  content: string,
  displayWidth: number,
  targetWidth: number,
  align: 'left' | 'center' | 'right' | null | undefined,
)

Source from the content-addressed store, hash-verified

779 * stripAnsi'd text, so ANSI codes in `content` don't affect padding).
780 */
781export function padAligned(
782 content: string,
783 displayWidth: number,
784 targetWidth: number,
785 align: 'left' | 'center' | 'right' | null | undefined,
786): string {
787 const padding = Math.max(0, targetWidth - displayWidth)
788 if (align === 'center') {
789 const leftPad = Math.floor(padding / 2)
790 return ' '.repeat(leftPad) + content + ' '.repeat(padding - leftPad)
791 }
792 if (align === 'right') {
793 return ' '.repeat(padding) + content
794 }
795 return content + ' '.repeat(padding)
796}

Callers 2

renderRowLinesFunction · 0.85
formatTokenFunction · 0.85

Calls 1

maxMethod · 0.80

Tested by

no test coverage detected