mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
29 lines
12 KiB
JavaScript
29 lines
12 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,k){"use strict";var o=!0,u=!1;function P(a){return"[object Arguments]"==h.call(a)}function l(a){return new m(a)}function m(a){this.m=a}function ra(a,b){return r[b]}function sa(a){return"\\"+ta[a]}function i(){for(var a,b=-1,c={},d={},e={},f=["c","i","f"];++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].j):c[a]=d[a]=e[a]||"";a=e.a;var b=/^[^,]+/.exec(a)[0],f=e.g,g=e.h,Q=!("w"==b||"b"==g),g=!("c"==b||"a"==g),i=e.l!==u;return Function("d,e,j,m,n,o,q,r,s,t,x,C,E,H,I,l,J",
|
|
'"use strict";return function('+a+"){"+("var p,B"+(f?"="+f:""))+";"+(e.e||"if(!"+b+")return B")+";"+(e.k||"")+";"+(Q?"var v="+b+".length;p=-1;"+((g?"if(v===+v){":"")+(c.c||"")+";while("+(c.i||"++p<v")+"){"+c.f+"}"+(g?"}":"")):"")+(g?(Q?"else{":"")+(d.c||"")+";for("+(d.i||"p in "+b)+"){"+(i?"if(n.call("+/\S+$/.exec(d.i||b)[0]+",p)){":"")+d.f+(i?"}":"")+"}"+(Q?"}":""):"")+(e.d||"")+";return B}")(H,x,D,p,v,$,s,Infinity,I,aa,Math,j,J,h,o,u)}function ua(a,b){var c=r.length;r[c]="'+((__t=("+b+"))==null?'':__e(__t))+'";
|
|
return R+c}function va(a,b){var c=r.length;r[c]="'+((__t=("+b+"))==null?'':__t)+'";return R+c}function wa(a,b){var c=r.length;r[c]="';"+b+";__p+='";return R+c}function ba(a,b,c,d){if(!a)return c;var e=a.length,f=3>arguments.length;d&&(b=x(b,d));if(e===+e){for(e&&f&&(c=a[--e]);e--;)c=b(c,a[e],e,a);return c}var g=S(a);for((e=g.length)&&f&&(c=a[g[--e]]);e--;)f=g[e],c=b(c,a[f],f,a);return c}function T(a,b,c){return b==k||c?a[0]:j.call(a,0,b)}function ca(a,b){if(b)return D.apply(t,a);for(var c,d=-1,e=
|
|
a.length,f=[];++d<e;)c=a[d],I(c)?E.apply(f,ca(c)):f.push(c);return f}function s(a,b,c){var d;if(!a)return-1;if(c)return c=da(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 ea(a){for(var b,c=-1,d=a.length,e=j.call(arguments,1),f=[];++c<d;)b=a[c],0>s(f,b)&&U(e,function(a){return-1<s(a,b)})&&f.push(b);return f}function fa(a,b,c){return j.call(a,b==k||c?1:b)}function da(a,b,c){var d,e=0,f=a.length;for(c&&(b=c(b));e<f;)d=e+f>>1,(c?c(a[d]):a[d])<b?e=d+1:f=d;return e}
|
|
function ga(a,b,c){var d,e=-1,f=a.length,g=[],h=[];for(3>f&&(b=o);++e<f;)if(d=c?c(a[e]):a[e],b?!e||h[h.length-1]!==d:0>s(h,d))h.push(d),g.push(a[e]);return g}function x(a,b){var c,d=h.call(a)==p;if(d){if(y)return a=y.call.apply(y,arguments),function(){return arguments.length?a.apply(k,arguments):a()}}else c=b,b=a;var e=j.call(arguments,2),f=e.length;return function(){var g;g=arguments;d||(a=b[c]);f&&(g.length&&(e.length=f,E.apply(e,g)),g=e);g=g.length?a.apply(b,g):a.call(b);e.length=f;return g}}function V(a,
|
|
b,c){c||(c=[]);if(a===b)return 0!==a||1/a==1/b;if(a==k||b==k)return a===b;a.n&&(a=a.m);b.n&&(b=b.m);if(a.isEqual&&h.call(a.isEqual)==p)return a.isEqual(b);if(b.isEqual&&h.call(b.isEqual)==p)return b.isEqual(a);var d=h.call(a);if(d!=h.call(b))return u;switch(d){case J:return a==""+b;case K:return a!=+a?b!=+b:0==a?1/a==1/b:a==+b;case ha:case ia:return+a==+b;case ja: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 u;
|
|
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,"&").replace(/</g,"<").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,
|
|
"/")}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",
|
|
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=
|
|
[a[c].apply(this,b)];return b[0]}},contains:A,debounce:function(a,b,c){function d(){h=k;c||a.apply(g,e)}var e,f,g,h;return function(){var i=c&&!h;e=arguments;g=this;Da(h);h=M(d,b);i&&(f=a.apply(g,e));return f}},defaults:qa,defer:function(a){var b=j.call(arguments,1);return M(function(){return a.apply(k,b)},1)},delay:function(a,b){var c=j.call(arguments,2);return M(function(){return a.apply(k,c)},b)},difference:function(a){for(var b=-1,c=a.length,d=[],e=D.apply(d,j.call(arguments,1));++b<c;)0>s(e,
|
|
a[b])&&d.push(a[b]);return d},escape:ka,every:U,extend:O,filter:ma,find:na,first:T,flatten:ca,forEach:F,functions:L,groupBy:Ea,has:function(a,b){return v.call(a,b)},identity:$,indexOf:s,initial:function(a,b,c){return j.call(a,0,-(b==k||c?1:b))},intersection:ea,invoke:function(a,b){for(var c=j.call(arguments,2),d=-1,e=a.length,f=h.call(b)==p,g=[];++d<e;)g[d]=(f?b:a[d][b]).apply(a[d],c);return g},isArguments:P,isArray:I,isBoolean:function(a){return a===o||a===u||h.call(a)==ha},isDate:function(a){return h.call(a)==
|
|
ia},isElement:function(a){return!!(a&&1==a.nodeType)},isEmpty:aa,isEqual:V,isFinite:function(a){return Ca(a)&&h.call(a)==K},isFunction:function(a){return h.call(a)==p},isNaN:function(a){return h.call(a)==K&&a!=+a},isNull:function(a){return null===a},isNumber:function(a){return h.call(a)==K},isObject:function(a){return a===Object(a)},isRegExp:function(a){return h.call(a)==ja},isString:function(a){return h.call(a)==J},isUndefined:function(a){return a===k},keys:S,last:function(a,b,c){var d=a.length;
|
|
return b==k||c?a[d-1]:j.call(a,-b||d)},lastIndexOf:function(a,b){if(!a)return-1;for(var c=a.length;c--;)if(a[c]===b)return c;return-1},map:Y,max:oa,memoize:function(a,b){var c={};return function(){var d=b?b.apply(this,arguments):arguments[0];return v.call(c,d)?c[d]:c[d]=a.apply(this,arguments)}},min:C,mixin:la,noConflict:function(){q._=ya;return this},once:function(a){var b,c=u;return function(){if(c)return b;c=o;return b=a.apply(this,arguments)}},partial:function(a){var b=j.call(arguments,1),c=b.length;
|
|
return function(){var d;d=arguments;d.length&&(b.length=c,E.apply(b,d));d=1==b.length?a.call(this,b[0]):a.apply(this,b);b.length=c;return d}},pick:function(a){for(var b,c=0,d=D.apply(t,arguments),e=d.length,f={};++c<e;)b=d[c],b in a&&(f[b]=a[b]);return f},pluck:N,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:Z,reduceRight:ba,reject:G,rest:fa,result:function(a,b){if(!a)return null;var c=a[b];
|
|
return h.call(c)==p?a[b]():c},shuffle:function(a){for(var b,c=-1,d=a.length,e=Array(d);++c<d;)b=Math.floor(Math.random()*(c+1)),e[c]=e[b],e[b]=a[c];return e},size:function(a){var b=h.call(a);return b==H||b==J?a.length:S(a).length},some:B,sortBy:function(a,b,c){if(h.call(b)!=p)var d=b,b=function(a){return a[d]};else c&&(b=x(b,c));return N(Y(a,function(c,d){return{a:b(c,d,a),b:c}}).sort(function(a,b){var c=a.a,d=b.a;return c===k?1:d===k?-1:c<d?-1:c>d?1:0}),"b")},sortedIndex:da,tap:function(a,b){b(a);
|
|
return a},template:function(a,b,c){var c=qa(c||{},l.templateSettings),d;d=c.escape;var e=c.evaluate,f=c.interpolate,c=c.variable;d&&(a=a.replace(d,ua));f&&(a=a.replace(f,va));e&&(a=a.replace(e,wa));a="__p='"+a.replace(Aa,sa).replace(za,ra)+"';\n";r.length=0;c||(a="with(object||{}){"+a+"}");a="function("+(c||"object")+'){var __p,__t;function print(){__p+=__j.call(arguments,"")}'+a+"return __p}";d=Function("_,__e,__j","return "+a)(l,ka,Ba);if(b)return d(b);d.source=a;return d},throttle:function(a,b){function c(){h=
|
|
new Date;g=k;a.apply(f,d)}var d,e,f,g,h=0;return function(){var i=new Date,j=b-(i-h);d=arguments;f=this;0>=j?(h=i,e=a.apply(f,d)):g||(g=M(c,j));return e}},times:function(a,b,c){c&&(b=x(b,c));for(c=0;c<a;c++)b(c)},toArray:function(a){if(!a)return[];if(h.call(a.toArray)==p)return a.toArray();var b=a.length;return b===+b?j.call(a):pa(a)},union:function(){for(var a=-1,b=[],c=D.apply(b,arguments),d=c.length;++a<d;)0>s(b,c[a])&&b.push(c[a]);return b},uniq:ga,uniqueId:function(a){var b=xa++;return a?a+b:
|
|
b},values:pa,without:function(a){for(var b=j.call(arguments,1),c=-1,d=a.length,e=[];++c<d;)0>s(b,a[c])&&e.push(a[c]);return e},wrap:function(a,b){return function(){var c=[a];E.apply(c,arguments);return b.apply(this,c)}},zip:function(){for(var a=-1,b=oa(N(arguments,"length")),c=Array(b);++a<b;)c[a]=N(arguments,a);return c},all:U,any:B,collect:Y,detect:na,each:F,foldl:Z,foldr:ba,head:T,include:A,inject:Z,intersect:ea,methods:L,select:ma,tail:fa,take:T,unique:ga});m.prototype=l.prototype;la(l);F("pop,push,reverse,shift,sort,splice,unshift".split(","),
|
|
function(a){var b=t[a];m.prototype[a]=function(){var a=this.m;b.apply(a,arguments);a.length===0&&delete a[0];return this.n?(new m(a)).chain():a}});F(["concat","join","slice"],function(a){var b=t[a];m.prototype[a]=function(){var a=b.apply(this.m,arguments);return this.n?(new m(a)).chain():a}});O(m.prototype,{chain:function(){this.n=o;return this},value:function(){return this.m}});W?"object"==typeof module&&module&&module.o==W?(module.o=l)._=l:W._=l:(q._=l,"function"==typeof define&&"object"==typeof define.amd&&
|
|
define.amd&&define(function(){return l}))})(this);
|