leafiy
5/18/2018 - 6:53 PM

truncateString #js

截取字符串

const truncateString = (str, num) =>
str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str;
// truncateString('boomerang', 7) -> 'boom...