lodash: Ensure max and min do not error when computing the result of massive arrays. [cederberg, jddalton, jeeyoungk]

Former-commit-id: af982790c3bb62777523f972a95b7115fb645180
This commit is contained in:
John-David Dalton
2012-05-06 19:38:15 -04:00
parent d26fc7154c
commit 52cf17b24a
4 changed files with 114 additions and 92 deletions

2
lodash.min.js vendored
View File

@@ -11,7 +11,7 @@ b,c){c||(c=[]);if(a===b)return 0!==a||1/a==1/b;if(a==k||b==k)return a===b;a.n&&(
for(var e=c.length;e--;)if(c[e]==a)return o;var e=o,f=0;c.push(a);if(d==H){if(f=a.length,e=f==b.length)for(;f--&&(e=f in a==f in b&&V(a[f],b[f],c)););}else{if("constructor"in a!="constructor"in b||a.constructor!=b.constructor)return u;for(var g in a)if(v.call(a,g)&&(f++,!(e=v.call(b,g)&&V(a[g],b[g],c))))break;if(e){for(g in b)if(v.call(b,g)&&!f--)break;e=!f}}c.pop();return e}function ka(a){return(a+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,
"&#x2F;")}function $(a){return a}function la(a){F(L(a),function(b){var c=l[b]=a[b];m.prototype[b]=function(){var a=[this.m];E.apply(a,arguments);a=c.apply(l,a);return this.n?(new m(a)).chain():a}})}var ta={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},W="object"==typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(q=global),exports),xa=0,ya=q._,w=/\{\s*\[native code\]\s*\}/,za=/__token__(\d+)/g,Aa=/\\|['\n\r\t\u2028\u2029]/g,R="__token__",
r=[],H="[object Array]",ha="[object Boolean]",ia="[object Date]",p="[object Function]",K="[object Number]",ja="[object RegExp]",J="[object String]",t=Array.prototype,z=Object.prototype,D=t.concat,v=z.hasOwnProperty,Ba=t.join,E=t.push,j=t.slice,h=z.toString,y=w.test(y=j.bind)&&/\n|Opera/.test(y+h.call(q.opera))&&y,A=w.test(A=Array.isArray)&&A,Ca=q.isFinite,X=w.test(X=Object.keys)&&X,Da=q.clearTimeout,M=q.setTimeout,B={g:"I",f:"if(!f(h[p],p,h))return!B"},w={a:"w",g:"w",k:"for(var D,j=1,v=arguments.length;j<v;j++){D=arguments[j]",
i:"p in D",l:u,f:"w[p]=D[p]",d:"}"},G={g:"[]",f:"f(h[p],p,h)&&B.push(h[p])"},n={a:"h,f,G",g:"h",k:"if(!f){f=o}else if(G){f=e(f,G)}",f:"f(h[p],p,h)"},z={g:"",e:"if(!h)return[]",c:{b:"B=Array(v)",j:"B=[]"},f:{b:"B[p]=f(h[p],p,h)",j:"B.push(f(h[p],p,h))"}},C={k:"var k,i=-r,B=i;if(!f){if(s(h)&&h[0]===+h[0])return x.max.apply(x,h);if(t(h))return B}else if(G)f=e(f,G)",f:"k=f?f(h[p],p,h):h[p];if(k>=i)i=k,B=h[p]"},I=A||function(a){return h.call(a)==H},aa=i({a:"K",h:"b",g:"I",k:"var g=H.call(K);if(g==d||g==E)return!K.length",
i:"p in D",l:u,f:"w[p]=D[p]",d:"}"},G={g:"[]",f:"f(h[p],p,h)&&B.push(h[p])"},n={a:"h,f,G",g:"h",k:"if(!f){f=o}else if(G){f=e(f,G)}",f:"f(h[p],p,h)"},z={g:"",e:"if(!h)return[]",c:{b:"B=Array(v)",j:"B=[]"},f:{b:"B[p]=f(h[p],p,h)",j:"B.push(f(h[p],p,h))"}},C={k:"var k,i=-r,B=i;if(!f){if(s(h)&&h[0]===+h[0]){try{return x.max.apply(x,h);}catch(e){}}if(t(h))return B}else if(G)f=e(f,G)",f:"k=f?f(h[p],p,h):h[p];if(k>=i)i=k,B=h[p]"},I=A||function(a){return h.call(a)==H},aa=i({a:"K",h:"b",g:"I",k:"var g=H.call(K);if(g==d||g==E)return!K.length",
f:"return l"}),A=i({a:"h,F",g:"l",f:"if(h[p]===F)return I"}),U=i(n,B),ma=i(n,G),na=i(n,{f:"if(f(h[p],p,h))return h[p]"}),F=i(n),Ea=i(n,{g:"{}",k:"var z,u=H.call(f)==m;if(u&&G)f=e(f,G)",f:"z=u?f(h[p],p,h):h[p][f];(B[z]||(B[z]=[])).push(h[p])"}),Y=i(n,z),oa=i(n,C),C=i(n,C,{k:C.k.replace("-","").replace("max","min"),f:C.f.replace(">=","<")}),N=i(z,{a:"h,A",f:{b:"B[p]=h[p][A]",j:"B.push(h[p][A])"}}),Z=i({a:"h,f,a,G",g:"a",k:"var y=arguments.length<3;if(G)f=e(f,G)",c:{b:"if(y)B=h[++p]"},f:{b:"B=f(B,h[p],p,h)",
j:"B=y?(y=l,h[p]):f(B,h[p],p,h)"}}),G=i(n,G,{f:"!"+G.f}),B=i(n,B,{g:"l",f:B.f.replace("!","")}),pa=i(z,{a:"h",f:{b:"B[p]=h[p]",j:"B.push(h[p])"}}),qa=i(w,{f:"if(w[p]==J)"+w.f}),O=i(w),L=i({a:"w",g:"[]",l:u,f:"if(H.call(w[p])==m)B.push(p)",d:"B.sort()"});P(arguments)||(P=function(a){return!(!a||!v.call(a,"callee"))});var S=X||i({a:"w",e:"if(w!==Object(w))throw TypeError()",g:"[]",f:"B.push(p)"});O(l,{VERSION:"0.1.0",templateSettings:{escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g},
after:function(a,b){return 1>a?b():function(){if(1>--a)return b.apply(this,arguments)}},bind:x,bindAll:function(a){var b=arguments,c=1;1==b.length&&(c=0,b=L(a));for(var d=b.length;c<d;c++)a[b[c]]=x(a[b[c]],a);return a},chain:function(a){return(new m(a)).chain()},clone:function(a){return a!==Object(a)?a:I(a)?a.slice():O({},a)},compact:function(a){for(var b=-1,c=a.length,d=[];++b<c;)a[b]&&d.push(a[b]);return d},compose:function(){var a=arguments;return function(){for(var b=arguments,c=a.length;c--;)b=