Skip to content

Instantly share code, notes, and snippets.

@rimzzlabs
Last active September 26, 2022 07:45
Show Gist options
  • Save rimzzlabs/8df26ac98222ecb5473d004e4793e7a2 to your computer and use it in GitHub Desktop.
Save rimzzlabs/8df26ac98222ecb5473d004e4793e7a2 to your computer and use it in GitHub Desktop.
given number length, make the string ellipsis
export const toElipsis = (str: string, range?: = 10): string => {
return str.slice(0, range) + '...'
}
// usage
const elipsis = toElipsis("Please mister, call me Robin, I will be your company while at your trip to Mongo Island", 44)
console.info(elipsis) // -> 'Please mister, call me robin, I will be your...'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment