File size: 309 Bytes
f5071ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
const Truncate = function(str, length, ending) {
if (length == null) {
length = 150;
}
if (ending == null) {
ending = "...";
}
if (str.length > length) {
return str.substring(0, length - ending.length) + ending;
} else {
return str;
}
};
export default Truncate;
|