lib/libs.js
function ellipses_ (s, length, place, ellipses) {
                    if(isNaN(parseInt(length, 10))) length = s.length;
                    if(length < 0 || !isFinite(length)) length = 0;

                    ellipses = typeof ellipses === 'string' ? ellipses : '...';
                    if(s.length <= length) return s;

                    if(length <= ellipses.length) {
                        return ellipses.substring(0, length);
                    }
                    else if(!place || place !== 'front') {
                        return s.substr(0, length - ellipses.length) + ellipses;
                    }
                    else {
                        return ellipses + s.substr(0, length - ellipses.length);
                    }
                }
function ellipses_ (s, length, place, ellipses) {
                    if(isNaN(parseInt(length, 10))) length = s.length;
                    if(length < 0 || !isFinite(length)) length = 0;

                    ellipses = typeof ellipses === 'string' ? ellipses : '...';
                    if(s.length <= length) return s;

                    if(length <= ellipses.length) {
                        return ellipses.substring(0, length);
                    }
                    else if(!place || place !== 'front') {
                        return s.substr(0, length - ellipses.length) + ellipses;
                    }
                    else {
                        return ellipses + s.substr(0, length - ellipses.length);
                    }
                }
function ellipses_ ( s , length , place , ellipses ) { if ( isNaN ( parseInt ( length , 10 ) ) ) length = s . length ; if ( length < 0 || ! isFinite ( length ) ) length = 0 ; ellipses = typeof ellipses === 'string' ? ellipses : '...' ; if ( s . length <= length ) return s ; if ( length <= ellipses . length ) { return ellipses . substring ( 0 , length ) ; } else if ( ! place || place !== 'front' ) { return s . substr ( 0 , length - ellipses . length ) + ellipses ; } else { return ellipses + s . substr ( 0 , length - ellipses . length ) ; } }
Return a truncated string with ellipses.
@param {String} s The string to operate on.
@param {Number=} length The length of the desired string. If ommited, the strings original length will be used.
@param {String=} [place='back'] Possible values are 'front' and 'back'. Specifying 'front' will truncate the
string and add ellipses to the front, 'back' (or any other value) will add the ellipses to the back.
@param {String=} [ellipses='...'] The string value of the ellipses. Use this to add anything other than '...'
@returns {String} A truncated string with ellipses (if its length is greater than 'length')
@function
Return a truncated string with ellipses .