Str Lib

String helper functions

目前為 2017-02-11 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址