Str Lib

String helper functions

2017-02-11 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @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