Nodejs Utililty Methods String Truncate

List of utility methods to do String Truncate

Description

The list of methods to do String Truncate are organized into topic(s).

Method

trunc
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_;
      };
trunc
String.prototype.trunc =
    function( n, useWordBoundary ){
        var isTooLong = this.length > n,
            s_ = isTooLong ? this.substr(0,n-1) : this;
        s_ = (useWordBoundary && isTooLong) ? s_.substr(0,s_.lastIndexOf(' ')) : s_;
        return  isTooLong ? s_ + '…' : s_;
    };
trunc
String.prototype.trunc = 
      function(n){
          return this.substr(0,n-1)+(this.length>n?'…':'');
      };
trunc
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 () {
...
trunc()
String.prototype.trunc = String.prototype.trunc ||
      function(n){
          return (this.length > n) ? this.substr(0,n-1)+'…' : this;
      };
trunc()
String.prototype.trunc = String.prototype.trunc ||
function(n){
  return this.length>n ? this.substr(0,n-1)+'?' : this;
};
trunc()
String.prototype.trunc = String.prototype.trunc ||
  function(n){
      return this.length>n ? this.substr(0,n-1)+'...' : this;
  };
trunc(len,suffix)
String.prototype.trunc = function(len,suffix) {
    return this.length > len ? this.slice(0, len) + (suffix||'…') : this;
};
trunc(len,suffix)
String.prototype.trunc = String.prototype.trunc || function(len,suffix) {
    return this.length > len ? this.slice(0, len) + (suffix||'…') : this;
};
trunc(length, options)
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();
};