mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
35 lines
15 KiB
JavaScript
35 lines
15 KiB
JavaScript
/*!
|
|
Lo-Dash 0.4.2 lodash.com/license
|
|
Underscore.js 1.3.3 github.com/documentcloud/underscore/blob/master/LICENSE
|
|
*/
|
|
;(function(e,t){"use strict";function s(e){return new o(e)}function o(e){if(e&&e._wrapped)return e;this._wrapped=e}function u(e,t,n){t||(t=0);var r=e.length,i=r-t>=(n||30),s=i?{}:e;if(i)for(var o=t-1;++o<r;)n=e[o]+"",(Z.call(s,n)?s[n]:s[n]=[]).push(e[o]);return function(e){if(i){var n=e+"";return Z.call(s,n)&&-1<E(s[n],e)}return-1<E(s,e,t)}}function a(){for(var e,t,n,s=-1,o=arguments.length,u={e:"",f:"",j:"",p:"",c:{d:""},m:{d:""}};++s<o;)for(t in e=arguments[s],e)n=(n=e[t])==r?"":n,/d|i/.test(t)?
|
|
("string"==typeof n&&(n={b:n,l:n}),u.c[t]=n.b,u.m[t]=n.l):u[t]=n;e=u.a,t=/^[^,]+/.exec(e)[0],u.g=t,u.h=yt,u.k=xt,u.o=K,u.q=u.q!==i,u.r=u.r!==i,"n"in u||(u.n=Et),u.f||(u.f="if(!"+t+")return H");if("h"!=t||!u.c.i)u.c=r;t="",u.r&&(t+="'use strict';"),t+="var p,t="+u.g+",H",u.j&&(t+="="+u.j),t+=";"+u.f+";"+u.p+";",u.c&&(t+="var w=t.length;p=-1;",u.m&&(t+="if(w===w>>>0){"),u.n&&(t+="if(N.call(t)==K){t=t.split('')}"),t+=u.c.d+";while(++p<w){"+u.c.i+"}",u.m&&(t+="}"));if(u.m){u.c&&(t+="else{"),u.h||(t+="var I=typeof t=='function'&&G.call(t,'prototype');"
|
|
),u.k&&u.q?t+="var E=y(t),D=-1,w=E.length;"+u.m.d+";while(++D<w){p=E[D];if(!(I&&p=='prototype')){"+u.m.i+"}}":(t+=u.m.d+";for(p in t){",u.h?(u.q&&(t+="if(n.call(t,p)){"),t+=u.m.i+";",u.q&&(t+="}")):(t+="if(!(I&&p=='prototype')",u.q&&(t+="&&n.call(t,p)"),t+="){"+u.m.i+"}"),t+="}");if(u.h){t+="var k=t.constructor;";for(n=0;7>n;n++)t+="p='"+u.o[n]+"';if(","constructor"==u.o[n]&&(t+="!(k&&k.prototype===t)&&"),t+="n.call(t,p)){"+u.m.i+"}"}u.c&&(t+="}")}return t+=u.e+";return H",Function("c,d,e,f,i,j,l,n,o,q,r,v,B,y,G,J,K,N"
|
|
,"return function("+e+"){"+t+"}")(ft,Tt,B,C,f,Y,ht,Z,A,E,k,p,Ct,ut,tt,nt,vt,rt)}function f(e,n){return e=e.a,n=n.a,e===t?1:n===t?-1:e<n?-1:e>n?1:0}function l(e,t){return G[t]}function c(e){return"\\"+kt[e]}function h(e){return Nt[e]}function p(e,t){return function(n,r,i){return e.call(t,n,r,i)}}function d(){}function v(e,t){if(q.test(t))return"<e%-"+t+"%>";var n=G.length;return G[n]="'+__e("+t+")+'",Q+n}function m(e,t,n,r){return e=G.length,t?G[e]="'+__e("+t+")+'":r?G[e]="';"+r+";__p+='":n&&(G[e]="'+((__t=("+
|
|
n+"))==null?'':__t)+'"),Q+e}function g(e,t){if(q.test(t))return"<e%="+t+"%>";var n=G.length;return G[n]="'+((__t=("+t+"))==null?'':__t)+'",Q+n}function y(e,t,n,r){if(!e)return n;var i=e.length,s=3>arguments.length;r&&(t=p(t,r));if(i===i>>>0){var o=Et&&rt.call(e)==vt?e.split(""):e;for(i&&s&&(n=o[--i]);i--;)n=t(n,o[i],i,e);return n}o=un(e);for((i=o.length)&&s&&(n=e[o[--i]]);i--;)s=o[i],n=t(n,e[s],s,e);return n}function b(e,t,n){if(e)return t==r||n?e[0]:nt.call(e,0,t)}function w(e,t){var n=[];if(!e)
|
|
return n;for(var r,i=-1,s=e.length;++i<s;)r=e[i],sn(r)?et.apply(n,t?r:w(r)):n.push(r);return n}function E(e,t,n){if(!e)return-1;var r=-1,i=e.length;if(n){if("number"!=typeof n)return r=T(e,t),e[r]===t?r:-1;r=(0>n?Math.max(0,i+n):n)-1}for(;++r<i;)if(e[r]===t)return r;return-1}function S(e,t,n){var r=-Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]>i&&(i=e[s]);return i}for(n&&(t=p(t,n));++s<o;)n=t(e[s],s,e),n>r&&(r=n,i=e[s]);return i}function x(e,t,n){return e?nt.call(e,t==r||
|
|
n?1:t):[]}function T(e,t,n,r){if(!e)return 0;var i=0,s=e.length;if(n){r&&(n=C(n,r));for(t=n(t);i<s;)r=i+s>>>1,n(e[r])<t?i=r+1:s=r}else for(;i<s;)r=i+s>>>1,e[r]<t?i=r+1:s=r;return i}function N(e,t,n,r){var s=[];if(!e)return s;var o=-1,u=e.length,a=[];"function"==typeof t&&(r=n,n=t,t=i);for(n?r&&(n=p(n,r)):n=A;++o<u;)if(r=n(e[o],o,e),t?!o||a[a.length-1]!==r:0>E(a,r))a.push(r),s.push(e[o]);return s}function C(e,t){function n(){var o=arguments,u=t;return i||(e=t[r]),s.length&&(o=o.length?Y.apply(s,o)
|
|
:s),this instanceof n?(d.prototype=e.prototype,u=new d,(o=e.apply(u,o))&&Ct[typeof o]?o:u):e.apply(u,o)}var r,i=rt.call(e)==ht;if(i){if(St||it&&2<arguments.length)return it.call.apply(it,arguments)}else r=t,t=e;var s=nt.call(arguments,2);return n}function k(e){return rt.call(e)==at}function L(e,t,s){s||(s=[]);if(e===t)return 0!==e||1/e==1/t;if(e==r||t==r)return e===t;e._chain&&(e=e._wrapped),t._chain&&(t=t._wrapped);if(e.isEqual&&rt.call(e.isEqual)==ht)return e.isEqual(t);if(t.isEqual&&rt.call(t.
|
|
isEqual)==ht)return t.isEqual(e);var o=rt.call(e);if(o!=rt.call(t))return i;switch(o){case lt:case ct:return+e==+t;case pt:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case dt:case vt:return e==t+""}if("object"!=typeof e||"object"!=typeof t)return i;for(var u=s.length;u--;)if(s[u]==e)return n;var u=-1,a=n,f=0;s.push(e);if(o==ft){if(f=e.length,a=f==t.length)for(;f--&&(a=L(e[f],t[f],s)););}else{if("constructor"in e!="constructor"in t||e.constructor!=t.constructor)return i;for(var l in e)if(Z.call(e,l)&&(
|
|
f++,!(a=Z.call(t,l)&&L(e[l],t[l],s))))break;if(a){for(l in t)if(Z.call(t,l)&&!(f--))break;a=!f}if(a&&yt)for(;7>++u&&(l=K[u],!Z.call(e,l)||!!(a=Z.call(t,l)&&L(e[l],t[l],s))););}return s.pop(),a}function A(e){return e}function O(e){Ut(rn(e),function(t){var r=s[t]=e[t];o.prototype[t]=function(){var e=[this._wrapped];return arguments.length&&et.apply(e,arguments),e=r.apply(s,e),this._chain&&(e=new o(e),e._chain=n),e}})}var n=!0,r=null,i=!1,M,_,D,P,H="object"==typeof exports&&exports&&("object"==typeof
|
|
global&&global&&global==global.global&&(e=global),exports),B=Array.prototype,j=Object.prototype,F=0,I=e._,q=/[-+=!~*%&^<>|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,R=/\b__p\+='';/g,U=/\b(__p\+=)''\+/g,z=/(__e\(.*?\)|\b__t\))\+'';/g,W=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,X=RegExp("^"+(j.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),V=/__token__(\d+)/g,$=/[&<"']/g,J=/['\n\r\t\u2028\u2029\\]/g,K="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf"
|
|
.split(" "),Q="__token__",G=[],Y=B.concat,Z=j.hasOwnProperty,et=B.push,tt=j.propertyIsEnumerable,nt=B.slice,rt=j.toString,it=X.test(it=nt.bind)&&it,st=X.test(st=Array.isArray)&&st,ot=e.isFinite,ut=X.test(ut=Object.keys)&&ut,at="[object Arguments]",ft="[object Array]",lt="[object Boolean]",ct="[object Date]",ht="[object Function]",pt="[object Number]",dt="[object RegExp]",vt="[object String]",mt=e.clearTimeout,gt=e.setTimeout,yt=!tt.call({valueOf:0},"valueOf"),bt=!k(arguments),wt="x"!=nt.call("x")
|
|
[0],Et="xx"!="x"[0]+Object("x")[0],St=it&&/\n|Opera/.test(it+rt.call(e.opera)),xt=ut&&/^.+$|true/.test(ut+!!e.attachEvent),Tt={"[object Arguments]":n,"[object Array]":n,"[object String]":n},Nt={"&":"&","<":"<",'"':""","'":"'"},Ct={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i},kt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};s.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g
|
|
,variable:"obj"};var Lt={a:"h,g,M",j:"h",p:"if(!g){g=o}else if(M)g=v(g,M)",i:"g(t[p],p,h)"},At={j:"{}",p:"var C;if(typeof g!='function'){var P=g;g=function(O){return O[P]}}else if(M)g=v(g,M)",i:"C=g(t[p],p,h);(n.call(H,C)?H[C]++:H[C]=1)"},Ot={j:"true",i:"if(!g(t[p],p,h))return!H"},Mt={q:i,r:i,a:"A",j:"A",p:"for(var u=1,w=arguments.length;u<w;u++){t=arguments[u];"+(yt?"if(t){":""),i:"H[p]=t[p]",e:(yt?"}":"")+"}"},_t={j:"[]",i:"g(t[p],p,h)&&H.push(t[p])"},Dt={p:"if(M)g=v(g,M)"},Pt={i:{l:Lt.i}},Ht={
|
|
j:"",f:"if(!h)return[]",d:{b:"H=Array(w)",l:"H="+(xt?"Array(w)":"[]")},i:{b:"H[p]=g(t[p],p,h)",l:"H"+(xt?"[D]=":".push")+"(g(t[p],p,h))"}},Bt=a({a:"A",f:"if(!(A&&B[typeof A]))throw TypeError()",j:"[]",i:"H.push(p)"}),jt=a({a:"h,L",j:"false",n:i,d:{b:"if(N.call(t)==K)return h.indexOf(L)>-1"},i:"if(t[p]===L)return true"}),Ft=a(Lt,At),It=a(Lt,Ot),qt=a(Lt,_t),Rt=a(Lt,Dt,{j:"",i:"if(g(t[p],p,h))return t[p]"}),Ut=a(Lt,Dt),zt=a(Lt,At,{i:"C=g(t[p],p,h);(n.call(H,C)?H[C]:H[C]=[]).push(t[p])"}),Wt=a(Ht,{a:"h,x"
|
|
,p:"var b=J.call(arguments,2),s=typeof x=='function'",i:{b:"H[p]=(s?x:t[p][x]).apply(t[p],b)",l:"H"+(xt?"[D]=":".push")+"((s?x:t[p][x]).apply(t[p],b))"}}),Xt=a(Lt,Ht),Vt=a(Ht,{a:"h,F",i:{b:"H[p]=t[p][F]",l:"H"+(xt?"[D]=":".push")+"(t[p][F])"}}),$t=a({a:"h,g,a,M",j:"a",p:"var z=arguments.length<3;if(M)g=v(g,M)",d:{b:"if(z)H=h[++p]"},i:{b:"H=g(H,t[p],p,h)",l:"H=z?(z=false,t[p]):g(H,t[p],p,h)"}}),Jt=a(Lt,_t,{i:"!"+_t.i}),Kt=a(Lt,Ot,{j:"false",i:Ot.i.replace("!","")}),Qt=a(Lt,At,Ht,{i:{b:"H[p]={a:g(t[p],p,h),b:t[p]}"
|
|
,l:"H"+(xt?"[D]=":".push")+"({a:g(t[p],p,h),b:t[p]})"},e:"H.sort(i);w=H.length;while(w--){H[w]=H[w].b}"}),Gt=a({q:i,r:i,a:"A",j:"A",p:"var m=arguments,w=m.length;if(w>1){for(var p=1;p<w;p++)H[m[p]]=f(H[m[p]],H);return H}",i:"if(N.call(H[p])==l)H[p]=f(H[p],H)"}),Yt=a(Mt,{i:"if(H[p]==null)"+Mt.i}),Zt=a({q:i,a:"A",j:"{}",p:"var E=j.apply(e,arguments)",i:"if(q(E,p)<0)H[p]=t[p]"}),en=a(Mt),tn=a(Lt,Dt,Pt,{q:i}),nn=a(Lt,Dt,Pt),rn=a({q:i,a:"A",j:"[]",i:"if(N.call(t[p])==l)H.push(p)",e:"H.sort()"});bt&&(k=
|
|
function(e){return!!e&&!!Z.call(e,"callee")});var sn=st||function(e){return rt.call(e)==ft};Ut({Date:ct,Function:ht,Number:pt,RegExp:dt,String:vt},function(e,t){s["is"+t]=function(t){return rt.call(t)==e}});var on=a({a:"O",j:"true",p:"if(d[N.call(O)]"+(bt?"||r(O)":"")+")return!O.length",i:{l:"return false"}}),un=ut?function(e){return"function"==typeof e&&tt.call(e,"prototype")?Bt(e):ut(e)}:Bt,an=a({a:"A",j:"[]",i:"H.push(t[p])"});s.VERSION="0.4.2",s.after=function(e,t){return 1>e?t():function(){if(1>--
|
|
e)return t.apply(this,arguments)}},s.bind=C,s.bindAll=Gt,s.chain=function(e){return e=new o(e),e._chain=n,e},s.clone=function(e){return e&&Ct[typeof e]?sn(e)?e.slice():en({},e):e},s.compact=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length;++n<r;)e[n]&&t.push(e[n]);return t},s.compose=function(){var e=arguments;return function(){for(var t=arguments,n=e.length;n--;)t=[e[n].apply(this,t)];return t[0]}},s.contains=jt,s.countBy=Ft,s.debounce=function(e,t,n){function i(){a=r,n||e.apply(u,s)}
|
|
var s,o,u,a;return function(){var r=n&&!a;return s=arguments,u=this,mt(a),a=gt(i,t),r&&(o=e.apply(u,s)),o}},s.defaults=Yt,s.defer=function(e){var n=nt.call(arguments,1);return gt(function(){return e.apply(t,n)},1)},s.delay=function(e,n){var r=nt.call(arguments,2);return gt(function(){return e.apply(t,r)},n)},s.difference=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=Y.apply(t,arguments),i=u(i,r);++n<r;)i(e[n])||t.push(e[n]);return t},s.drop=Zt,s.escape=function(e){return e==r?"":(
|
|
e+"").replace($,h)},s.every=It,s.extend=en,s.filter=qt,s.find=Rt,s.first=b,s.flatten=w,s.forEach=Ut,s.forIn=tn,s.forOwn=nn,s.functions=rn,s.groupBy=zt,s.has=function(e,t){return Z.call(e,t)},s.identity=A,s.indexOf=E,s.initial=function(e,t,n){return e?nt.call(e,0,-(t==r||n?1:t)):[]},s.intersection=function(e){var t=[];if(!e)return t;for(var n,r=-1,i=e.length,s=nt.call(arguments,1),o=[];++r<i;)n=e[r],0>E(t,n)&&It(s,function(e,t){return(o[t]||(o[t]=u(e)))(n)})&&t.push(n);return t},s.invoke=Wt,s.isArguments=
|
|
k,s.isArray=sn,s.isBoolean=function(e){return e===n||e===i||rt.call(e)==lt},s.isElement=function(e){return!!e&&1==e.nodeType},s.isEmpty=on,s.isEqual=L,s.isFinite=function(e){return ot(e)&&rt.call(e)==pt},s.isNaN=function(e){return rt.call(e)==pt&&e!=+e},s.isNull=function(e){return e===r},s.isObject=function(e){return e&&Ct[typeof e]},s.isUndefined=function(e){return e===t},s.keys=un,s.last=function(e,t,n){if(e){var i=e.length;return t==r||n?e[i-1]:nt.call(e,-t||i)}},s.lastIndexOf=function(e,t,n){
|
|
if(!e)return-1;var r=e.length;for(n&&"number"==typeof n&&(r=(0>n?Math.max(0,r+n):Math.min(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},s.map=Xt,s.max=S,s.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return Z.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},s.min=function(e,t,n){var r=Infinity,i=r;if(!e)return i;var s=-1,o=e.length;if(!t){for(;++s<o;)e[s]<i&&(i=e[s]);return i}for(n&&(t=p(t,n));++s<o;)n=t(e[s],s,e),n<r&&(r=n,i=e[s]);return i},s.mixin=
|
|
O,s.noConflict=function(){return e._=I,this},s.once=function(e){var t,r=i;return function(){return r?t:(r=n,t=e.apply(this,arguments))}},s.partial=function(e){var t=nt.call(arguments,1),n=t.length;return function(){var r;return r=arguments,r.length&&(t.length=n,et.apply(t,r)),r=1==t.length?e.call(this,t[0]):e.apply(this,t),t.length=n,r}},s.pick=function(e){for(var t,n=0,r=Y.apply(B,arguments),i=r.length,s={};++n<i;)t=r[n],t in e&&(s[t]=e[t]);return s},s.pluck=Vt,s.range=function(e,t,n){n||(n=1),t==
|
|
r&&(t=e||0,e=0);for(var i=-1,t=Math.max(0,Math.ceil((t-e)/n)),s=Array(t);++i<t;)s[i]=e,e+=n;return s},s.reduce=$t,s.reduceRight=y,s.reject=Jt,s.rest=x,s.result=function(e,t){if(!e)return r;var n=e[t];return rt.call(n)==ht?e[t]():n},s.shuffle=function(e){if(!e)return[];for(var t,n=-1,r=e.length,i=Array(r);++n<r;)t=Math.floor(Math.random()*(n+1)),i[n]=i[t],i[t]=e[n];return i},s.size=function(e){return e?Tt[rt.call(e)]||bt&&k(e)?e.length:un(e).length:0},s.some=Kt,s.sortBy=Qt,s.sortedIndex=T,s.tap=function(
|
|
e,t){return t(e),e},s.template=function(e,t,n){n||(n={});var o,u;o=n.escape;var a=n.evaluate,f=n.interpolate,h=s.templateSettings,n=n.variable;o==r&&(o=h.escape),a==r&&(a=h.evaluate||i),f==r&&(f=h.interpolate),o&&(e=e.replace(o,v)),f&&(e=e.replace(f,g)),a!=M&&(M=a,P=RegExp("<e%-([\\s\\S]+?)%>|<e%=([\\s\\S]+?)%>"+(a?"|"+a.source:""),"g")),o=G.length,e=e.replace(P,m),o=o!=G.length,e="__p += '"+e.replace(J,c).replace(V,l)+"';",G.length=0,n||(n=h.variable||_||"obj",o?e="with("+n+"){"+e+"}":(n!=_&&(_=
|
|
n,D=RegExp("(\\(\\s*)"+n+"\\."+n+"\\b","g")),e=e.replace(W,"$&"+n+".").replace(D,"$1__d"))),e=(o?e.replace(R,""):e).replace(U,"$1").replace(z,"$1;"),e="function("+n+"){"+n+"||("+n+"={});var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":",__d="+n+"."+n+"||"+n+";")+e+"return __p}";try{u=Function("_","return "+e)(s)}catch(p){u=function(){throw p}}return t?u(t):(u.source=e,u)},s.throttle=function(e,t){function n(){a=new Date,u=r,e.apply(o,i)}var i
|
|
,s,o,u,a=0;return function(){var r=new Date,f=t-(r-a);return i=arguments,o=this,0>=f?(a=r,s=e.apply(o,i)):u||(u=gt(n,f)),s}},s.times=function(e,t,n){var r=-1;if(n)for(;++r<e;)t.call(n,r);else for(;++r<e;)t(r)},s.toArray=function(e){if(!e)return[];if(e.toArray&&rt.call(e.toArray)==ht)return e.toArray();var t=e.length;return t===t>>>0?(wt?rt.call(e)==vt:"string"==typeof e)?e.split(""):nt.call(e):an(e)},s.union=function(){for(var e=-1,t=[],n=Y.apply(t,arguments),r=n.length;++e<r;)0>E(t,n[e])&&t.push
|
|
(n[e]);return t},s.uniq=N,s.uniqueId=function(e){var t=F++;return e?e+t:t},s.values=an,s.without=function(e){var t=[];if(!e)return t;for(var n=-1,r=e.length,i=u(arguments,1,20);++n<r;)i(e[n])||t.push(e[n]);return t},s.wrap=function(e,t){return function(){var n=[e];return arguments.length&&et.apply(n,arguments),t.apply(this,n)}},s.zip=function(e){if(!e)return[];for(var t=-1,n=S(Vt(arguments,"length")),r=Array(n);++t<n;)r[t]=Vt(arguments,t);return r},s.zipObject=function(e,t){if(!e)return{};var n=-1
|
|
,r=e.length,i={};for(t||(t=[]);++n<r;)i[e[n]]=t[n];return i},s.all=It,s.any=Kt,s.collect=Xt,s.detect=Rt,s.each=Ut,s.foldl=$t,s.foldr=y,s.head=b,s.include=jt,s.inject=$t,s.methods=rn,s.select=qt,s.tail=x,s.take=b,s.unique=N,o.prototype=s.prototype,O(s),o.prototype.chain=function(){return this._chain=n,this},o.prototype.value=function(){return this._wrapped},Ut("pop push reverse shift sort splice unshift".split(" "),function(e){var t=B[e];o.prototype[e]=function(){var e=this._wrapped;return t.apply
|
|
(e,arguments),e.length===0&&delete e[0],this._chain&&(e=new o(e),e._chain=n),e}}),Ut(["concat","join","slice"],function(e){var t=B[e];o.prototype[e]=function(){var e=t.apply(this._wrapped,arguments);return this._chain&&(e=new o(e),e._chain=n),e}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(e._=s,define(function(){return s})):H?"object"==typeof module&&module&&module.s==H?(module.s=s)._=s:H._=s:e._=s})(this); |