Str Lib

String helper functions

Versión del día 11/02/2017. Echa un vistazo a la versión más reciente.

Este script no debería instalarse directamente. Es una biblioteca que utilizan otros scripts mediante la meta-directiva de inclusión // @require https://update.greasyfork.org/scripts/27278/174477/Str%20Lib.js

// region [ Str Lib ]
var Str = {};

Str.trim = function (s) {
	return s.replace(/^\s+/, '').replace(/\s+$/, '');
};

Str.padRight = function(s, padStr, totalLength){
	return s.length >= totalLength  ? s : s + Str.repeat(padStr, (totalLength-s.length)/padStr.length);
};

Str.repeat = function(s, count) {
	var newS = "", i;
	for (i=0; i<count; i++) {
		newS += s;
	}
	return newS;
};
// endregion