11 lines
245 B
Plaintext
11 lines
245 B
Plaintext
"use strict";
|
|
function pad(str, width, alignLeft = true) {
|
|
const diff = width - str.length;
|
|
if (diff <= 0) {
|
|
return str;
|
|
}
|
|
const padding = " ".repeat(diff);
|
|
return alignLeft ? str + padding : padding + str;
|
|
}
|
|
module.exports = pad;
|