Skip to content

Instantly share code, notes, and snippets.

@amcdnl
Created August 2, 2016 11:32
Show Gist options
  • Save amcdnl/ec2347fbbe9384eeb4dfc1aee7a62d5f to your computer and use it in GitHub Desktop.
Save amcdnl/ec2347fbbe9384eeb4dfc1aee7a62d5f to your computer and use it in GitHub Desktop.
export function truncate(text, length) {
if (text.toString().length > length) {
return text.toString().substring(0, length) + "...";
} else {
return text;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment