truncate.js 273 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 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; };