import os from "os" ; export function wrapAndIndent ( spacesToIndent , columnsPerLine , s ) { const indentText = " " . repeat ( spacesToIndent ) ; const words = s . split ( " " ) ; let text = indentText ; let column = indentText . length ; const firstWord = words . shift ( ) ; text += firstWord ; column += firstWord ?. length ?? 0 ; for ( const word of words ) { if ( column + 1 + word . length < columnsPerLine ) { text += " " ; column += 1 ; } else { text += os . EOL + indentText ; column = indentText . length ; } text += word ; column += word . length ; } return text ; }