blob: 2085dde666cad730834f7ae5d17758aaaee1c63a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
'use strict';
module.exports = input => {
if (typeof input !== 'string') {
throw new TypeError(`Expected input to be a string, got ${typeof input}`);
}
const lines = input.split('\n');
const maxLength = Math.max.apply(null, lines.map(line => line.length));
return lines
.map(line => {
if (line.length < maxLength) {
line += ' '.repeat(maxLength - line.length);
}
return line;
})
.join('\n');
};
|