1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee
tools/utils/stringUtils.js

13 lines
396 B
JavaScript
Raw Permalink Normal View History

2022-10-29 17:40:25 +08:00
// 数字转成字符串,同时在前面填充
function fill(num, length, fillers = " ", atLast = false) {
var result = `${num}`;
if (result.length < length) {
let fillString = new Array(length - result.length + 1).join(fillers)
result = atLast ? `${result}${fillString}` : `${fillString}${result}`;
}
return result;
}
module.exports = {
fill,
}