JS: implement Icinga.Utils.padString()

refs #10625
This commit is contained in:
Alexander A. Klimov 2016-02-22 11:14:41 +01:00
parent 17d0f7be5e
commit c4a69191a3
1 changed files with 18 additions and 0 deletions

View File

@ -386,6 +386,24 @@
}[c];
}
);
},
/**
* Pad a string with another one
*
* @param {String} str the string to pad
* @param {String} padding the string to use for padding
* @param {Number} minLength the minimum length of the result
*
* @returns {String} the padded string
*/
padString: function(str, padding, minLength) {
str = String(str);
padding = String(padding);
while (str.length < minLength) {
str = padding + str;
}
return str;
}
};