wallet-core/node_modules/equal-length/index.js
2017-05-28 00:40:43 +02:00

21 lines
425 B
JavaScript

'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');
};