File size: 371 Bytes
06227db
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
const borderedText = (text: string) => {
  const lines = text.split('\n');
  const width = Math.max(...lines.map((l) => l.length));
  const res = [`┌${'─'.repeat(width + 2)}┐`];
  for (const line of lines) {
    res.push(`│ ${line.padEnd(width)} │`);
  }
  res.push(`└${'─'.repeat(width + 2)}┘`);
  return res.join('\n');
};

export default borderedText;