Ensure _.truncate doesn't truncate strings if they are equal to the given length.

This commit is contained in:
John-David Dalton
2014-03-10 01:11:08 -07:00
parent 4eaf91c3dc
commit 05dce760d6
5 changed files with 5 additions and 5 deletions

View File

@@ -60,7 +60,7 @@ e=typeof n;var u=typeof t;if(n===n&&(null==n||null==t||"function"!=e&&"object"!=
return-1},u.mixin=xr,u.noConflict=function(){return n._=Br,this},u.noop=Cr,u.now=Fe,u.pad=function(n,t,r){n=null==n?"":Lr(n),t=+t||0;var e=n.length;return e<t?(e=(t-e)/2,t=Vr(e),e=Kr(e),r=Ot("",e,r),r.slice(0,t)+n+r):n},u.padLeft=function(n,t,r){return n=null==n?"":Lr(n),Ot(n,t,r)+n},u.padRight=function(n,t,r){return n=null==n?"":Lr(n),n+Ot(n,t,r)},u.parseInt=Pe,u.random=function(n,t,r){var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=he(),ce(n+r*(t-n+parseFloat("1e-"+((r+"").length-1))),t)):wt(n,t)
},u.reduce=Ht,u.reduceRight=Jt,u.repeat=dr,u.result=function(n,t,r){var e=null==n?_:n[t];return typeof e=="undefined"?r:fr(e)?n[t]():e},u.runInContext=b,u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Se(n).length},u.some=nr,u.sortedIndex=$t,u.snakeCase=Ne,u.startsWith=function(n,t,r){return n=null==n?"":Lr(n),r=typeof r=="number"?ce(fe(r,0),n.length):0,n.lastIndexOf(t,r)==r},u.template=function(n,t,r){var e=u.templateSettings;r=or({},r,e),n=Lr(null==n?"":n);var o,a,i=or({},r.imports,e.imports),e=Se(i),i=yr(i),l=0,f=r.interpolate||U,c="__p+='",f=Tr((r.escape||U).source+"|"+f.source+"|"+(f===P?$:U).source+"|"+(r.evaluate||U).source+"|$","g");
n.replace(f,function(t,r,e,u,i,f){return e||(e=u),c+=n.slice(l,f).replace(V,s),r&&(o=true,c+="'+__e("+r+")+'"),i&&(a=true,c+="';"+i+";\n__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),l=f+t.length,t}),c+="';",(r=r.variable)||(c="with(obj){"+c+"}"),c=(a?c.replace(I,""):c).replace(R,"$1").replace(N,"$1;"),c="function("+(r||"obj")+"){"+(r?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(a?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var p=Sr(e,"return "+c).apply(_,i)
}catch(h){throw h.source=c,h}return t?p(t):(p.source=c,p)},u.trim=Te,u.trimLeft=Le,u.trimRight=We,u.truncate=function(n,t){var r=30,e="...";if(t&&cr(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?Lr(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":Lr(n),r>n.length)return n;var o=r-e.length;if(1>o)return e;if(r=n.slice(0,o),null==u)return r+e;if(pr(u)){if(n.slice(o).search(u)){var a,i,l=n.slice(0,o);for(u.global||(u=Tr(u.source,(D.exec(u)||"")+"g")),u.lastIndex=0;a=u.exec(l);)i=a.index;
}catch(h){throw h.source=c,h}return t?p(t):(p.source=c,p)},u.trim=Te,u.trimLeft=Le,u.trimRight=We,u.truncate=function(n,t){var r=30,e="...";if(t&&cr(t))var u="separator"in t?t.separator:u,r="length"in t?+t.length||0:r,e="omission"in t?Lr(t.omission):e;else null!=t&&(r=+t||0);if(n=null==n?"":Lr(n),r>=n.length)return n;var o=r-e.length;if(1>o)return e;if(r=n.slice(0,o),null==u)return r+e;if(pr(u)){if(n.slice(o).search(u)){var a,i,l=n.slice(0,o);for(u.global||(u=Tr(u.source,(D.exec(u)||"")+"g")),u.lastIndex=0;a=u.exec(l);)i=a.index;
r=r.slice(0,null==i?o:i)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),-1<u&&(r=r.slice(0,u)));return r+e},u.unescape=function(n){return null==n?"":(n=Lr(n),0>n.indexOf(";")?n:n.replace(T,d))},u.uniqueId=function(n){var t=++S;return Lr(null==n?"":n)+t},u.all=Kt,u.any=nr,u.detect=Vt,u.findWhere=Vt,u.foldl=Ht,u.foldr=Jt,u.include=Ut,u.inject=Ht,xr(function(){var n={};return mt(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),false),u.first=Nt,u.last=Wt,u.sample=function(n,t,r){return n&&typeof n.length!="number"?n=yr(n):be.unindexedChars&&hr(n)&&(n=n.split("")),null==t||r?n?n[wt(0,n.length-1)]:_:(n=Qt(n),n.length=ce(fe(0,t),n.length),n)
},u.take=Nt,u.takeRight=Wt,u.takeRightWhile=Wt,u.takeWhile=Nt,u.head=Nt,mt(u,function(n,t){var r="sample"!==t;u.prototype[t]||(u.prototype[t]=function(t,e){var u=this.__chain__,a=n(this.__wrapped__,t,e);return u||null!=t&&(!e||r&&typeof t=="function")?new o(a,u):a})}),u.VERSION=E,u.prototype.chain=function(){return this.__chain__=true,this},u.prototype.toString=function(){return Lr(this.__wrapped__)},u.prototype.value=qt,u.prototype.valueOf=qt,st(["join","pop","shift"],function(n){var t=Fr[n];u.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments);
return n?new o(r,n):r}}),st(["push","reverse","sort","unshift"],function(n){var t=Fr[n];u.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),st(["concat","splice"],function(n){var t=Fr[n];u.prototype[n]=function(){return new o(t.apply(this.__wrapped__,arguments),this.__chain__)}}),be.spliceObjects||st(["pop","shift","splice"],function(n){var t=Fr[n],r="splice"==n;u.prototype[n]=function(){var n=this.__chain__,e=this.__wrapped__,u=t.apply(e,arguments);return 0===e.length&&delete e[0],n||r?new o(u,n):u