wallet-core/node_modules/equal-length/index.js

21 lines
425 B
JavaScript
Raw Normal View History

2017-05-28 00:38:50 +02:00
'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');
};