fix: truncate text function (#431)

This commit is contained in:
Aaryan Khandelwal 2023-03-14 12:16:38 +05:30 committed by GitHub
parent d6d51c2f43
commit 3f5bbf336c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,8 +4,11 @@ export const replaceUnderscoreIfSnakeCase = (str: string) => str.replace(/_/g, "
export const capitalizeFirstLetter = (str: string) => str.charAt(0).toUpperCase() + str.slice(1); export const capitalizeFirstLetter = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);
export const truncateText = (str: string, length: number) => export const truncateText = (str: string, length: number) => {
str.length > length ? `${str.substring(0, length)}...` : str; if (!str || str === "") return "";
return str.length > length ? `${str.substring(0, length)}...` : str;
};
export const createSimilarString = (str: string) => { export const createSimilarString = (str: string) => {
const shuffled = str const shuffled = str