Here you can find the source of truncateFilename()
String.prototype.truncateFilename = function() { var fileParts = this.split('.'); var extension = fileParts[fileParts.length-1]; var filename = this.substr(0, this.length - extension.length + 1); return filename.substr(0, 10) + '*.' + extension; };
String.prototype.truncate = function(n) { var tooLong = this.length > n, string = tooLong ? this.substr(0,n-1) : this; string = tooLong ? string.substr(0,string.lastIndexOf(' ')) : string; return tooLong ? string + '...' : string; };
String.prototype.truncate = function (options) { var length = (options && options.length) || 50; var ending = (options && options.ending) || "..."; var truncated = this.slice(0, length); if (truncated.length < this.length) truncated += ending; return truncated; };
String.prototype.truncate = function (options) { var length = (options && options.length) || 70; var ending = (options && options.ending) || "..."; var truncated = this.slice(0, length); if (truncated.length < this.length) truncated += ending; return truncated; };
String.prototype.truncate = function(x){ return this.length > x ? this.substr(0,x) : this ;
String.prototype.truncate = function(x){ if(this.length < x) return this.valueOf(); else return this.substring(0, x - 3) + "..."; };
function truncateString(str, num) { if (str.length <= num) { return str; } else { return str.slice(0, num > 3 ? num - 3 : num) + '...'; truncateString("A-", 1);
function truncateString(str, num) { if(str.length > num){ if(num < 3){ str = str.slice(0,num) + "..."; }else{ str = str.slice(0,num-3) + "..."; console.log("actual str is " + str); }else{ ...
function truncateString(str, num) { var trunc; if (num <= 3) { if (num < str.length){ return str.slice(0,num) + "..."; } else{ trunc = str.slice(0,num); return trunc; } else if (num >= str.length) { return str; } else { trunc = str.slice(0,num - 3); return trunc + "..."; truncateString("A-tisket a-tasket A green and yellow basket", 11);