/**
 * truncate text to a specified length.
 *
 * {{ 'this is a big city!' | truncate 11 '...' true }} => this is...
 */

function truncate(str, length, ellipses, preserveWords) {
    length = length || 30;
    str = (str.length > length) ? str.slice(0, length) : str;

    if (preserveWords) {
        str = str.substr(0, Math.min(str.length, str.lastIndexOf(' ')));
    }

    if (ellipses === undefined) {
        ellipses = '...';
    }
    ellipses = '' + ellipses;

    return str + ellipses;
}

export default truncate;

@@ -80,17 +80,17 @@
 uncate 1
-1
+5
  '...' t
@@ -106,16 +106,18 @@
  this is
+ a
 ...%0A */%0A
@@ -202,16 +202,114 @@
  %7C%7C 30;%0A
+%0A    if (ellipses === undefined) %7B%0A        ellipses = '...';%0A    %7D%0A    ellipses = '' + ellipses;%0A%0A
     str 
@@ -353,16 +353,34 @@
 , length
+ - ellipses.length
 ) : str;
@@ -490,105 +490,8 @@
  %7D%0A%0A
-    if (ellipses === undefined) %7B%0A        ellipses = '...';%0A    %7D%0A    ellipses = '' + ellipses;%0A%0A
     

fix ellipses