Files
certd/packages/core/basic/src/utils/util.string.ts

18 lines
353 B
TypeScript
Raw Normal View History

2026-01-31 19:30:20 +08:00
import dayjs from "dayjs";
2024-11-13 22:42:11 +08:00
export const stringUtils = {
maxLength(str?: string, length = 100) {
if (str) {
2026-01-31 19:30:20 +08:00
return str.length > length ? str.slice(0, length) + "..." : str;
2024-11-13 22:42:11 +08:00
}
2026-01-31 19:30:20 +08:00
return "";
},
appendTimeSuffix(str?: string) {
if (str) {
return `${str}-${dayjs().format("YYYYMMDDHHmmssSSS")}`;
}
return "";
2024-11-13 22:42:11 +08:00
},
};