Here you can find the source of trunc(len,suffix)
/**/*from w w w . ja v a 2s . c o m*/ * shorten a string, adding a suffix in place of excessive characters * default suffix is an html encoded ellipsis '…' * * @function external:String.prototype.trunc * @param {number} len The lenth of the string to keep (not counting suffix) * @param {string} suffix The suffix to append (e.g. '...<a>read more</a>') * @return {string} * @example * 'this is a description that is too detailed'.trunc(10) === 'this is a …' */ String.prototype.trunc = function(len,suffix) { return this.length > len ? this.slice(0, len) + (suffix||'…') : this; };
String.prototype.trunc = function(n){ return this.substr(0,n-1)+(this.length>n?'…':''); };
String.prototype.trunc = function (n, useWordBoundary) { var toLong = this.length > n, s_ = toLong ? this.substr(0, n - 1) : this; s_ = useWordBoundary && toLong ? s_.substr(0, s_.lastIndexOf(' ')) : s_; return toLong ? s_ + '...' : s_; }; String.prototype.nl2br = function () { ...
String.prototype.trunc = String.prototype.trunc || function(n){ return (this.length > n) ? this.substr(0,n-1)+'…' : this; };
String.prototype.trunc = String.prototype.trunc || function(n){ return this.length>n ? this.substr(0,n-1)+'?' : this; };
String.prototype.trunc = String.prototype.trunc || function(n){ return this.length>n ? this.substr(0,n-1)+'...' : this; };
String.prototype.trunc = String.prototype.trunc || function(len,suffix) { return this.length > len ? this.slice(0, len) + (suffix||'…') : this; };
String.prototype.trunc = function(length, options) { var defaults = Ext.Object.merge({omission: "..."}, options || {}); var stop = length - defaults.omission.length; return (this.length > length ? this.substring(0, stop) + defaults.omission : this).toString(); };
String.prototype.trunc = function(n) { 'use strict'; return this.length > n ? this.substr(0, n-1) + '...' : this; };
String.prototype.trunc = String.prototype.trunc || function(n){ return (this.length > n) ? this.substr(0,n-1)+'…' : this; };