9 lines
273 B
JavaScript
9 lines
273 B
JavaScript
![]() |
var makeString = require('./helper/makeString');
|
||
|
|
||
|
module.exports = function truncate(str, length, truncateStr) {
|
||
|
str = makeString(str);
|
||
|
truncateStr = truncateStr || '...';
|
||
|
length = ~~length;
|
||
|
return str.length > length ? str.slice(0, length) + truncateStr : str;
|
||
|
};
|