src/aria/utils/String.js
function (string, size, character, begin) {
            string = "" + string;
            var length = string.length;
            if (length < size) {
                var padding = [];
                for (var difference = size - length; difference > 0; difference -= 1) {
                    padding.push(character);
                }

                if (begin === true) {
                    string = padding.join("") + string;
                } else {
                    string = string + padding.join("");
                }
            }
            return string;
        }
function (string, size, character, begin) {
            string = "" + string;
            var length = string.length;
            if (length < size) {
                var padding = [];
                for (var difference = size - length; difference > 0; difference -= 1) {
                    padding.push(character);
                }

                if (begin === true) {
                    string = padding.join("") + string;
                } else {
                    string = string + padding.join("");
                }
            }
            return string;
        }
function ( string , size , character , begin ) { string = "" + string ; var length = string . length ; if ( length < size ) { var padding = [ ] ; for ( var difference = size - length ; difference > 0 ; difference -= 1 ) { padding . push ( character ) ; } if ( begin === true ) { string = padding . join ( "" ) + string ; } else { string = string + padding . join ( "" ) ; } } return string ; }
Add some padding to a string in order to have a minimu length. If the minimum length is smaller than the
string length, nothing is done.
@param {String} string The string that requires padding
@param {Number} size Minimum length
@param {String} character Character to add.
@param {Boolean} begin Add character at the beginning or at the end of the string. If true at the beginning.
Default false.
@return {String} Padded string
Add some padding to a string in order to have a minimu length . If the minimum length is smaller than the string length nothing is done .