sigit.io/src/utils/string.ts

10 lines
251 B
TypeScript
Raw Normal View History

export const shorten = (str: string, offset = 9) => {
// return original string if it is not long enough
if (str.length < offset * 2 + 4) return str
return `${str.slice(0, offset)}...${str.slice(
str.length - offset,
str.length
)}`
}