import R from "ramda"

export const fillColumns = (fillSymbol, content = ``) =>
  R.pipe(
    R.split(`\n`),
    R.map(
      (line) =>
        fillSymbol.repeat(Math.floor(Math.max(process.stdout.columns - line.length, 0) / 2)) +
        line.slice(
          Math.max((line.length - process.stdout.columns) / 2, 0),
          (line.length + process.stdout.columns) / 2,
        ) +
        fillSymbol.repeat(Math.ceil(Math.max(process.stdout.columns - line.length, 0) / 2)),
    ),
    R.join(`\n`),
  )(content)
