Files
lodash/lodash.min.js
2012-04-26 01:10:45 -04:00

27 lines
11 KiB
JavaScript

/*!
Lo-Dash 0.1.0 github.com/bestiejs/lodash/blob/master/LICENSE.txt
Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE
*/
;(function(q,h){"use strict";var m=!0,o=!1;function R(a){return"[object Arguments]"==k.call(a)}function i(a){return new p(a)}function p(a){this.o=a}function g(){for(var a,b=-1,c={},d={},e={},f=["c","j","g"];++b<arguments.length;)for(a in arguments[b])e[a]=arguments[b][a];for(;a=f.pop();)"object"==typeof e[a]?(c[a]=e[a].b,d[a]=e[a].k):c[a]=d[a]=e[a]||"";a=e.a;var b=/^[^,]+/.exec(a)[0],f=e.h,j=e.i,g=!("x"==a||"b"==j),j=!("c"==a||"a"==j),h=e.n!==o;return Function("d,e,j,m,n,o,q,r,t,u,y,D,F,I,J,l,K",'"use strict";return function('+a+
"){"+("var p,C"+(f?"="+f:""))+";if("+(e.f||b+"==K")+")return "+(e.e||"C")+";"+(e.m||"")+";"+(g?"var w="+b+".length;p=-1;"+((j?"if(w===+w){":"")+(c.c||"")+";while("+(c.j||"++p<w")+"){"+c.g+"}"+(j?"}":"")):"")+(j?(g?"else{":"")+(d.c||"")+";for("+(d.j||"p in "+b)+"){"+(h?"if(n.call("+/\S+$/.exec(d.j||b)[0]+",p)){":"")+d.g+(h?"}":"")+"}"+(g?"}":""):"")+(e.d||"")+";return "+(e.l||"C")+"}")(B,s,C,aa,r,ba,D,Infinity,E,ca,Math,n,F,k,m,o)}function S(a){return a.replace(ta,function(a,c){return y[c]})}function da(a,
b,c,d){if(a==h)return c;var e=2<arguments.length,f=a.length;d&&(b=s(b,d));if(f===+f){for(f&&!e&&(c=a[--f]);f--;)c=b(c,a[f],f,a);return c}var j=T(a);for((f=j.length)&&!e&&(c=a[j[--f]]);f--;)e=j[f],c=b(c,a[e],e,a);return c}function ea(a,b,c){for(var d,e=0,f=a.length;e<f;)d=e+f>>1,(c?c(a[d])<c(b):a[d]<b)?e=d+1:f=d;return e}function U(a,b,c){return b==h||c?a[0]:n.call(a,0,b)}function fa(a,b){if(b)return C.apply([],a);for(var c=-1,d=a.length,e=[];++c<d;)E(a[c])?G.apply(e,fa(a[c])):e.push(a[c]);return e}
function D(a,b,c){var d;if(a==h)return-1;if(c)return c=ea(a,b),a[c]===b?c:-1;c=0;for(d=a.length;c<d;c++)if(a[c]===b)return c;return-1}function ga(a){var b=n.call(arguments,1);return V(H(a),function(a){return W(b,function(b){return-1<D(b,a)})})}function ha(a,b,c){var d=a.length;return b==h||c?a[d-1]:n.call(a,-b||d)}function ia(a,b,c){return n.call(a,b==h||c?1:b)}function H(a,b,c){var c=c?I(a,c):a,d=[];3>a.length&&(b=m);J(c,function(c,f,j){if(b?ha(c)!==f||!c.length:0>D(c,f))c.push(f),d.push(a[j]);return c},
[]);return d}function s(a,b){var c=n.call(arguments,2),d=c.length;return function(){c.length=d;G.apply(c,arguments);return a.apply(b,c)}}function ja(a,b,c){var d;return function(){var e=arguments,f=this;c&&!d&&a.apply(f,e);ua(d);d=K(function(){d=h;c||a.apply(f,e)},b)}}function X(a,b,c){c||(c=[]);if(a===b)return 0!==a||1/a==1/b;if(a==h||b==h)return a===b;a.p&&(a=a.o);b.p&&(b=b.o);if(a.isEqual&&t(a.isEqual))return a.isEqual(b);if(b.isEqual&&t(b.isEqual))return b.isEqual(a);var d=k.call(a);if(d!=k.call(b))return o;
switch(d){case F:return a==""+b;case L:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case ka:case la:return+a==+b;case ma:return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if("object"!=typeof a||"object"!=typeof b)return o;for(var e=c.length;e--;)if(c[e]==a)return m;var e=m,f=0;c.push(a);if(d==B){if(f=a.length,e=f==b.length)for(;f--&&(e=f in a==f in b&&X(a[f],b[f],c)););}else{if("constructor"in a!="constructor"in b||a.constructor!=b.constructor)return o;
for(var j in a)if(r.call(a,j)&&(f++,!(e=r.call(b,j)&&X(a[j],b[j],c))))break;if(e){for(j in b)if(r.call(b,j)&&!f--)break;e=!f}}c.pop();return e}function t(a){return k.call(a)==aa}function ba(a){return a}function na(a){u(M(a),function(b){var c=i[b]=a[b];i.prototype[b]=function(){var a=[this.o];G.apply(a,arguments);a=c.apply(i,a);return this.p?(new p(a)).chain():a}})}var y={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"};(function(){for(var a in y)y[y[a]]=a})();var Y="object"==
typeof exports&&exports&&("object"==typeof global&&global&&global==global.global&&(q=global),exports),va=0,wa=q._,xa=/\\|'|\r|\n|\t|\u2028|\u2029/g,Z=/.^/,ta=/\\(\\|'|r|n|t|u2028|u2029)/g,B="[object Array]",ka="[object Boolean]",la="[object Date]",aa="[object Function]",L="[object Number]",ma="[object RegExp]",F="[object String]",z=Array.prototype,N=Object.prototype,C=z.concat,r=N.hasOwnProperty,G=z.push,n=z.slice,k=N.toString,ya=q.isFinite,N=Object.keys,ua=q.clearTimeout,K=q.setTimeout,O={a:"c",
h:"[]",m:"var M=j.apply([],D.call(arguments,1))",g:"if(q(M,c[p])<0)C.push(c[p])"},v={h:"J",g:"if(!f(h[p],p,h))return!C"},$={a:"x",h:"x",m:"for(var E,j=1,w=arguments.length;j<w;j++){E=arguments[j]",j:"p in E",n:o,g:"x[p]=E[p]",d:"}"},A={h:"[]",g:"f(h[p],p,h)&&C.push(h[p])"},l={a:"h,f,H",h:"h",m:"if(!f){f=o}else if(H){f=e(f,H)}",g:"f(h[p],p,h)"},w={h:"",e:"[]",c:{b:"C=Array(w)",k:"C=[]"},g:{b:"C[p]=f(h[p],p,h)",k:"C.push(f(h[p],p,h))"}},x={m:"var k,i=-r,C=i;if(!f){if(t(h)&&h[0]===+h[0])return y.max.apply(y,h);if(u(h))return C}else if(H)f=e(f,H)",
g:"k=f?f(h[p],p,h):h[p];if(k>=i)i=k,C=h[p]"},E=Array.isArray||function(a){return k.call(a)==B},ca=g({a:"L",i:"b",h:"J",m:"var g=I.call(L);if(g==d||g==F)return!L.length",g:"return l"}),oa=g({a:"h,G",h:"l",g:"if(h[p]===G)return J"}),W=g(l,v),V=g(l,A),pa=g(l,{g:"if(f(h[p],p,h))return h[p]"}),u=g(l),za=g(l,{h:"{}",m:"var A,v=I.call(f)==m;if(v&&H)f=e(f,H)",g:"A=v?f(h[p],p,h):h[p][f];(C[A]||(C[A]=[])).push(h[p])"}),Aa=g(w,{a:"h,z",m:"var b=D.call(arguments,2),v=I.call(z)==m",g:{b:"C[p]=(v?z:h[p][z]).apply(h[p],b)",
k:"C.push(v?z:h[p][z]).apply(h[p],b)"}}),I=g(l,w),qa=g(l,x),x=g(l,x,{m:x.m.replace("-","").replace("max","min"),g:x.g.replace(">=","<")}),P=g(w,{a:"h,B",g:{b:"C[p]=h[p][B]",k:"C.push(h[p][B])"}}),J=g({a:"h,f,a,H",h:"a",m:"var s=arguments.length>2;if(H)f=e(f,H)",c:{b:"if(!s)C=h[++p]"},g:{b:"C=f(C,h[p],p,h)",k:"C=s?f(C,h[p],p,h):(s=J,h[p])"}}),A=g(l,A,{g:"!"+A.g}),v=g(l,v,{h:"l",g:v.g.replace("!","")}),ra=g(w,{a:"h",g:{b:"C[p]=h[p]",k:"C.push(h[p])"}}),w=g({a:"c",h:"[]",g:"if(c[p])C.push(c[p])"}),l=
g(O),O=g(O,{h:"[]",m:"var M=D.call(arguments,1)"}),sa=g($,{g:"if(x[p]==K)"+$.g}),Q=g($),M=g({a:"x",h:"[]",n:o,g:"if(I.call(x[p])==m)C.push(p)",l:"C.sort()"});R(arguments)||(R=function(a){return!(!a||!r.call(a,"callee"))});var T=N||g({a:"x",f:"x!==Object(x)",e:"throw TypeError()",h:"[]",g:"C.push(p)"});Q(i,{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:s,bindAll:function(a){var b=arguments,c=1;1==b.length&&(c=0,b=M(a));for(var d=b.length;c<d;c++)a[b[c]]=s(a[b[c]],a);return a},chain:function(a){return(new p(a)).chain()},clone:function(a){return a!==Object(a)?a:E(a)?a.slice():Q({},a)},compact:w,compose:function(){var a=arguments;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}},contains:oa,debounce:ja,defaults:sa,defer:function(a){var b=n.call(arguments,1);return K(function(){return a.apply(h,
b)},1)},delay:function(a,b){var c=n.call(arguments,2);return K(function(){return a.apply(h,c)},b)},difference:l,escape:function(a){return(a+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")},every:W,extend:Q,filter:V,find:pa,first:U,flatten:fa,forEach:u,functions:M,groupBy:za,has:function(a,b){return r.call(a,b)},identity:ba,indexOf:D,initial:function(a,b,c){return n.call(a,0,-(b==h||c?1:b))},intersection:ga,invoke:Aa,
isArguments:R,isArray:E,isBoolean:function(a){return a===m||a===o||k.call(a)==ka},isDate:function(a){return k.call(a)==la},isElement:function(a){return!!(a&&1==a.nodeType)},isEmpty:ca,isEqual:X,isFinite:function(a){return ya(a)&&k.call(a)==L},isFunction:t,isNaN:function(a){return k.call(a)==L&&a!=+a},isNull:function(a){return null===a},isNumber:function(a){return k.call(a)==L},isObject:function(a){return a===Object(a)},isRegExp:function(a){return k.call(a)==ma},isString:function(a){return k.call(a)==
F},isUndefined:function(a){return a===h},keys:T,last:ha,lastIndexOf:function(a,b){if(a==h)return-1;for(var c=a.length;c--;)if(a[c]===b)return c;return-1},map:I,max:qa,memoize:function(a,b){var c={};return function(){var d=b?b.apply(this,arguments):arguments[0];return r.call(c,d)?c[d]:c[d]=a.apply(this,arguments)}},min:x,mixin:na,noConflict:function(){q._=wa;return this},once:function(a){var b,c=o;return function(){if(c)return b;c=m;return b=a.apply(this,arguments)}},pick:function(a){for(var b,c=0,
d=C.apply([],arguments),e=d.length,f={};++c<e;)b=d[c],b in a&&(f[b]=a[b]);return f},pluck:P,range:function(a,b,c){c||(c=1);2>arguments.length&&(b=a||0,a=0);for(var d=-1,e=Math.max(Math.ceil((b-a)/c),0),f=Array(e);++d<e;)f[d]=a,a+=c;return f},reduce:J,reduceRight:da,reject:A,rest:ia,result:function(a,b){if(a==h)return null;var c=a[b];return t(c)?a[b]():c},shuffle:function(a){var b,c=[];u(a,function(a,e){b=Math.floor(Math.random()*(e+1));c[e]=c[b];c[b]=a});return c},size:function(a){var b=k.call(a);
return b==B||b==F?a.length:T(a).length},some:v,sortBy:function(a,b,c){if(t(b))c&&(b=s(b,c));else var d=b,b=function(a){return a[d]};return P(I(a,function(c,f){return{a:b(c,f,a),b:c}}).sort(function(a,b){var c=a.a,d=b.a;return c===h?1:d===h?-1:c<d?-1:c>d?1:0}),"b")},sortedIndex:ea,tap:function(a,b){b(a);return a},template:function(a,b,c){function d(a){return e.call(this,a,i)}c=sa(c||{},i.templateSettings);a="__p+='"+a.replace(xa,function(a){return"\\"+y[a]}).replace(c.escape||Z,function(a,b){return"'+((__t=("+
S(b)+"))==null?'':_['escape'](__t))+'"}).replace(c.interpolate||Z,function(a,b){return"'+((__t=("+S(b)+"))==null?'':__t)+'"}).replace(c.evaluate||Z,function(a,b){return"';"+S(b)+";__p+='"})+"';\n";c.variable||(a="with(object||{}){"+a+"}");var a='var __t,__j=Array.prototype.join,__p="";function print(){__p+=__j.call(arguments,"")}'+a+"return __p",e=Function(c.variable||"object","_",a);if(b)return e(b,i);d.source="function("+(c.variable||"object")+"){"+a+"}";return d},throttle:function(a,b){var c,d,
e,f,g,i,k=ja(function(){d=g=o},b);return function(){c=arguments;f=this;i||(i=K(function(){i=h;d&&a.apply(f,c);k()},b));g?d=m:e=a.apply(f,c);k();g=m;return e}},times:function(a,b,c){c&&(b=s(b,c));for(c=0;c<a;c++)b(c)},toArray:function(a){if(!a)return[];if(t(a.toArray))return a.toArray();var b=a.length;return b===+b?n.call(a):ra(a)},union:function(){return H(C.apply([],arguments))},uniq:H,uniqueId:function(a){var b=va++;return a?a+b:b},values:ra,without:O,wrap:function(a,b){return function(){var c=
[a];G.apply(c,arguments);return b.apply(this,c)}},zip:function(){for(var a=-1,b=qa(P(arguments,"length")),c=Array(b);++a<b;)c[a]=P(arguments,a);return c},all:W,any:v,collect:I,detect:pa,each:u,foldl:J,foldr:da,head:U,include:oa,inject:J,intersect:ga,methods:M,select:V,tail:ia,take:U,unique:H});p.prototype=i.prototype;na(i);u("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=z[a];i.prototype[a]=function(){var a=this.o;b.apply(a,arguments);a.length===0&&delete a[0];return this.p?
(new p(a)).chain():a}});u(["concat","join","slice"],function(a){var b=z[a];p.prototype[a]=function(){var a=b.apply(this.o,arguments);return this.p?(new p(a)).chain():a}});Q(p.prototype,{chain:function(){this.p=m;return this},value:function(){return this.o}});Y?"object"==typeof module&&module&&module.q==Y?(module.q=i)._=i:Y._=i:(q._=i,"function"==typeof define&&"object"==typeof define.amd&&define.amd&&define(function(){return i}))})(this);