lodash.underscore.min.js
13 KB
/*!
Lo-Dash 0.9.2 lodash.com/license
Underscore.js 1.4.2 underscorejs.org/LICENSE
*/
;(function(n,t){function r(n,t,r){var e;if(!n)return n;var t=l(t,r),u=n.length,r=-1;if(typeof u=="number"){for(;++r<u;)if(e=n[r],t(e,r,n)===Q)return n}else for(r in n)if(it.call(n,r)&&(e=n[r],t(e,r,n)===Q))return n}function e(n){var t,r,e=n;if(!n)return n;for(var u=1,i=arguments.length;u<i;u++)if(e=arguments[u])for(t in e)r=e[t],n[t]=r;return n}function u(n){var t,r,e=n;if(!n)return n;for(var u=1,i=arguments.length;u<i;u++)if(e=arguments[u])for(t in e)r=e[t],n[t]==V&&(n[t]=r);return n}function i(n,t){var r,e;
if(n)for(r in t=l(t),n)if(it.call(n,r)&&(e=n[r],t(e,r,n)===Q))break}function o(n,t){var r,e;if(n)for(r in t=l(t),n)if(e=n[r],t(e,r,n)===Q)break}function a(n){return n&&n.__wrapped__?n:this instanceof a?(this.__wrapped__=n,void 0):new a(n)}function c(n,r){var e=n.b,u=r.b,n=n.a,r=r.a;if(n!==r){if(n>r||n===t)return 1;if(n<r||r===t)return-1}return e<u?-1:1}function f(n,t,r){function e(){var u=arguments,i=t;return r.length&&(u=u.length?r.concat(at.call(u)):r),this instanceof e?(h.prototype=n.prototype,i=new h,u=n.apply(i,u),b(u)?u:i):n.apply(i,u)
}return e}function l(n,r){return n?typeof n!="function"?function(t){return t[n]}:r!==t?function(t,e,u){return n.call(r,t,e,u)}:n:C}function s(n){return"\\"+Et[n]}function p(n){return St[n]}function h(){}function g(n){return kt[n]}function v(n){var t=[];return i(n,function(n,r){t.push(r)}),t}function _(n){var t=[];return o(n,function(n,r){d(n)&&t.push(r)}),t.sort()}function m(n){var t={};return i(n,function(n,r){t[n]=r}),t}function y(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(n==V||t==V)return n===t;
var u=ct.call(n);if(u!=ct.call(t))return G;switch(u){case mt:case yt:return+n==+t;case dt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case wt:case jt:return n==t+""}var i=u==_t;if(!i){if(n.__wrapped__||t.__wrapped__)return y(n.__wrapped__||n,t.__wrapped__||t);if(u!=bt)return G;var u=n.constructor,o=t.constructor;if(u!=o&&(!d(u)||!(u instanceof u&&d(o)&&o instanceof o)))return G}for(r||(r=[]),e||(e=[]),u=r.length;u--;)if(r[u]==n)return e[u]==t;if(u=U,o=0,r.push(n),e.push(t),i){if(o=n.length,u=o==t.length)for(;o--&&(u=y(n[o],t[o],r,e)););return u
}for(var a in n)if(it.call(n,a)&&(o++,!it.call(t,a)||!y(n[a],t[a],r,e)))return G;for(a in t)if(it.call(t,a)&&!o--)return G;return U}function d(n){return typeof n=="function"}function b(n){return n?Ot[typeof n]:G}function w(n){return ct.call(n)==jt}function j(n){var t=[];return i(n,function(n){t.push(n)}),t}function x(n,t){return typeof(n?n.length:0)=="number"?-1<M(n,t):R(n,function(n){return n===t})}function A(n,t,e){var u=U,t=l(t,e);if(Tt(n))for(var e=-1,i=n.length;++e<i&&(u=!!t(n[e],e,n)););else r(n,function(n,r,e){return!(u=!!t(n,r,e))&&Q
});return u}function O(n,t,e){var u=[],t=l(t,e);return r(n,function(n,r,e){t(n,r,e)&&u.push(n)}),u}function E(n,t,e){var u,t=l(t,e);return r(n,function(n,r,e){return t(n,r,e)?(u=n,G):void 0}),u}function S(n,t,e){var u=-1,i=n?n.length:0,o=Array(typeof i=="number"?i:0),t=l(t,e);if(Tt(n))for(;++u<i;)o[u]=t(n[u],u,n);else r(n,function(n,r,e){o[++u]=t(n,r,e)});return o}function k(n,t,e){var u=-1/0,i=-1,o=n?n.length:0,a=u;if(t||!Tt(n))t=l(t,e),r(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,a=n)});else for(;++i<o;)n[i]>a&&(a=n[i]);
return a}function T(n,t){var e=[];return r(n,function(n){e.push(n[t])}),e}function N(n,t,e,u){var i=3>arguments.length,t=l(t,u);return r(n,function(n,r,u){e=i?(i=G,n):t(e,n,r,u)}),e}function q(n,t,e,u){var i=n?n.length:0,o=3>arguments.length;if(typeof i!="number")var a=Nt(n),i=a.length;return r(n,function(r,c,f){c=a?a[--i]:--i,e=o?(o=G,n[c]):t.call(u,e,n[c],c,f)}),e}function R(n,t,e){var u,t=l(t,e);if(Tt(n))for(var e=-1,i=n.length;++e<i&&!(u=t(n[e],e,n)););else r(n,function(n,r,e){return(u=t(n,r,e))&&Q
});return!!u}function B(n,t,r){return n?t==V||r?n[0]:at.call(n,0,t):void 0}function F(n,t){for(var r=-1,e=n?n.length:0,u=[];++r<e;){var i=n[r];Tt(i)?ot.apply(u,t?i:F(i)):u.push(i)}return u}function M(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?ht(0,u+r):r||0)-1;else if(r)return e=I(n,t),n[e]===t?e:-1;for(;++e<u;)if(n[e]===t)return e;return-1}function $(n,t,r){return n?at.call(n,t==V||r?1:t):[]}function I(n,t,r,e){for(var u=0,i=n?n.length:u,r=r?l(r,e):C,t=r(t);u<i;)e=u+i>>>1,r(n[e])<t?u=e+1:i=e;
return u}function D(n,t,r,e){var u=-1,i=n?n.length:0,o=[],a=o;for(r&&(a=[],r=l(r,e));++u<i;){var e=n[u],c=r?r(e,u,n):e;(t?!u||a[a.length-1]!==c:0>M(a,c))&&(r&&a.push(c),o.push(e))}return o}function z(n,t){return At||ft&&2<arguments.length?ft.call.apply(ft,arguments):f(n,t,at.call(arguments,2))}function C(n){return n}function P(n){r(_(n),function(t){var r=a[t]=n[t];a.prototype[t]=function(){var n=[this.__wrapped__];return ot.apply(n,arguments),n=r.apply(a,n),this.__chain__&&(n=new a(n),n.__chain__=U),n
}})}var U=!0,V=null,G=!1,H=typeof exports=="object"&&exports,J=typeof global=="object"&&global;J.global===J&&(n=J);var K=[],J=new function(){},L=0,Q=J,W=n._,X=/&(?:amp|lt|gt|quot|#x27);/g,Y=RegExp("^"+(J.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Z=/($^)/,nt=/[&<>"']/g,tt=/['\n\r\t\u2028\u2029\\]/g,rt=Math.ceil,et=K.concat,ut=Math.floor,it=J.hasOwnProperty,ot=K.push,at=K.slice,ct=J.toString,ft=Y.test(ft=at.bind)&&ft,lt=Y.test(lt=Array.isArray)&<,st=n.isFinite,pt=Y.test(pt=Object.keys)&&pt,ht=Math.max,gt=Math.min,vt=Math.random,_t="[object Array]",mt="[object Boolean]",yt="[object Date]",dt="[object Number]",bt="[object Object]",wt="[object RegExp]",jt="[object String]",xt=(xt={0:1,length:1},K.splice.call(xt,0,1),xt[0]),At=ft&&/\n|Opera/.test(ft+ct.call(n.opera)),Ot={"boolean":G,"function":U,object:U,number:G,string:G,undefined:G},Et={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};
a.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},a.isArguments=function(n){return"[object Arguments]"==ct.call(n)},a.isArguments(arguments)||(a.isArguments=function(n){return n?it.call(n,"callee"):G});var St={"&":"&","<":"<",">":">",'"':""","'":"'"},kt=m(St),Tt=lt||function(n){return ct.call(n)==_t};d(/x/)&&(d=function(n){return"[object Function]"==ct.call(n)});var Nt=pt?function(n){return b(n)?pt(n):[]}:v;a.VERSION="0.9.2",a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0
}},a.bind=z,a.bindAll=function(n){for(var t=arguments,r=1<t.length?0:(t=_(n),-1),e=t.length;++r<e;){var u=t[r];n[u]=z(n[u],n)}return n},a.chain=function(n){return n=new a(n),n.__chain__=U,n},a.clone=function(n){return n&&Ot[typeof n]?Tt(n)?at.call(n):e({},n):n},a.compact=function(n){for(var t=-1,r=n?n.length:0,e=[];++t<r;){var u=n[t];u&&e.push(u)}return e},a.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)];return t[0]}},a.contains=x,a.countBy=function(n,t,e){var u={},t=l(t,e);
return r(n,function(n,r,e){r=t(n,r,e),it.call(u,r)?u[r]++:u[r]=1}),u},a.debounce=function(n,t,r){function e(){a=V,r||(i=n.apply(o,u))}var u,i,o,a;return function(){var c=r&&!a;return u=arguments,o=this,clearTimeout(a),a=setTimeout(e,t),c&&(i=n.apply(o,u)),i}},a.defaults=u,a.defer=function(n){var r=at.call(arguments,1);return setTimeout(function(){n.apply(t,r)},1)},a.delay=function(n,r){var e=at.call(arguments,2);return setTimeout(function(){n.apply(t,e)},r)},a.difference=function(n){for(var t=-1,r=n.length,e=et.apply(K,arguments),u=[];++t<r;){var i=n[t];
0>M(e,i,r)&&u.push(i)}return u},a.escape=function(n){return n==V?"":(n+"").replace(nt,p)},a.every=A,a.extend=e,a.filter=O,a.find=E,a.first=B,a.flatten=F,a.forEach=r,a.functions=_,a.groupBy=function(n,t,e){var u={},t=l(t,e);return r(n,function(n,r,e){r=t(n,r,e),(it.call(u,r)?u[r]:u[r]=[]).push(n)}),u},a.has=function(n,t){return n?it.call(n,t):G},a.identity=C,a.indexOf=M,a.initial=function(n,t,r){return n?at.call(n,0,-(t==V||r?1:t)):[]},a.intersection=function(n){var t=arguments,e=t.length,u=[];return r(n,function(n){if(0>M(u,n)){for(var r=e;--r;)if(0>M(t[r],n))return;
u.push(n)}}),u},a.invert=m,a.invoke=function(n,t){var e=at.call(arguments,2),u=typeof t=="function",i=[];return r(n,function(n){i.push((u?t:n[t]).apply(n,e))}),i},a.isArray=Tt,a.isBoolean=function(n){return n===U||n===G||ct.call(n)==mt},a.isDate=function(n){return ct.call(n)==yt},a.isElement=function(n){return n?1===n.nodeType:G},a.isEmpty=function(n){if(!n)return U;if(Tt(n)||w(n))return!n.length;for(var t in n)if(it.call(n,t))return G;return U},a.isEqual=y,a.isFinite=function(n){return st(n)&&ct.call(n)==dt
},a.isFunction=d,a.isNaN=function(n){return ct.call(n)==dt&&n!=+n},a.isNull=function(n){return n===V},a.isNumber=function(n){return ct.call(n)==dt},a.isObject=b,a.isRegExp=function(n){return ct.call(n)==wt},a.isString=w,a.isUndefined=function(n){return n===t},a.keys=Nt,a.last=function(n,t,r){if(n){var e=n.length;return t==V||r?n[e-1]:at.call(n,-t||e)}},a.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?ht(0,e+r):gt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},a.map=S,a.max=k,a.memoize=function(n,t){var r={};
return function(){var e=t?t.apply(this,arguments):arguments[0];return it.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},a.min=function(n,t,e){var u=1/0,i=-1,o=n?n.length:0,a=u;if(t||!Tt(n))t=l(t,e),r(n,function(n,r,e){r=t(n,r,e),r<u&&(u=r,a=n)});else for(;++i<o;)n[i]<a&&(a=n[i]);return a},a.mixin=P,a.noConflict=function(){return n._=W,this},a.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};++r<e;){var i=n[r];t?u[i]=t[r]:u[i[0]]=i[1]}return u},a.omit=function(n){var t=et.apply(K,arguments),r={};
return o(n,function(n,e){0>M(t,e,1)&&(r[e]=n)}),r},a.once=function(n){var t,r=G;return function(){return r?t:(r=U,t=n.apply(this,arguments),n=V,t)}},a.pairs=function(n){var t=[];return i(n,function(n,r){t.push([r,n])}),t},a.pick=function(n){for(var t=0,r=et.apply(K,arguments),e=r.length,u={};++t<e;){var i=r[t];i in n&&(u[i]=n[i])}return u},a.pluck=T,a.random=function(n,t){return n==V&&t==V&&(t=1),n=+n||0,t==V&&(t=n,n=0),n+ut(vt()*((+t||0)-n+1))},a.range=function(n,t,r){n=+n||0,r=+r||1,t==V&&(t=n,n=0);
for(var e=-1,t=ht(0,rt((t-n)/r)),u=Array(t);++e<t;)u[e]=n,n+=r;return u},a.reduce=N,a.reduceRight=q,a.reject=function(n,t,r){return t=l(t,r),O(n,function(n,r,e){return!t(n,r,e)})},a.rest=$,a.result=function(n,t){var r=n?n[t]:V;return d(r)?n[t]():r},a.shuffle=function(n){var t=-1,e=Array(n?n.length:0);return r(n,function(n){var r=ut(vt()*(++t+1));e[t]=e[r],e[r]=n}),e},a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Nt(n).length},a.some=R,a.sortBy=function(n,t,e){var u=[],t=l(t,e);
for(r(n,function(n,r,e){u.push({a:t(n,r,e),b:r,c:n})}),n=u.length,u.sort(c);n--;)u[n]=u[n].c;return u},a.sortedIndex=I,a.tap=function(n,t){return t(n),n},a.template=function(n,t,r){n||(n="");var r=u({},r,a.templateSettings),e=0,i="__p += '",o=r.variable;n.replace(RegExp((r.escape||Z).source+"|"+(r.interpolate||Z).source+"|"+(r.evaluate||Z).source+"|$","g"),function(t,r,u,o,a){i+=n.slice(e,a).replace(tt,s),i+=r?"'+_['escape']("+r+")+'":o?"';"+o+";__p+='":u?"'+((__t=("+u+"))==null?'':__t)+'":"",e=a+t.length
}),i+="';",o||(o="obj",i="with("+o+"||{}){"+i+"}"),i="function("+o+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+i+"return __p}";try{var c=Function("_","return "+i)(a)}catch(f){throw f.source=i,f}return t?c(t):(c.source=i,c)},a.throttle=function(n,t){function r(){a=new Date,o=V,u=n.apply(i,e)}var e,u,i,o,a=0;return function(){var c=new Date,f=t-(c-a);return e=arguments,i=this,0<f?o||(o=setTimeout(r,f)):(clearTimeout(o),a=c,u=n.apply(i,e)),u}},a.times=function(n,t,r){for(var n=+n||0,e=-1,u=Array(n);++e<n;)u[e]=t.call(r,e);
return u},a.toArray=function(n){return n&&typeof n.length=="number"?typeof n=="string"?n.split(""):at.call(n):j(n)},a.unescape=function(n){return n==V?"":(n+"").replace(X,g)},a.union=function(){return D(et.apply(K,arguments))},a.uniq=D,a.uniqueId=function(n){var t=L++;return n?n+t:t},a.values=j,a.where=function(n,t){var r=[];return o(t,function(n,t){r.push(t)}),O(n,function(n){for(var e=r.length;e--;){var u=n[r[e]]===t[r[e]];if(!u)break}return!!u})},a.without=function(n){for(var t=-1,r=n.length,e=[];++t<r;){var u=n[t];
0>M(arguments,u,1)&&e.push(u)}return e},a.wrap=function(n,t){return function(){var r=[n];return ot.apply(r,arguments),t.apply(this,r)}},a.zip=function(n){for(var t=-1,r=n?k(T(arguments,"length")):0,e=Array(r);++t<r;)e[t]=T(arguments,t);return e},a.all=A,a.any=R,a.collect=S,a.detect=E,a.drop=$,a.each=r,a.foldl=N,a.foldr=q,a.head=B,a.include=x,a.inject=N,a.methods=_,a.select=O,a.tail=$,a.take=B,a.unique=D,P(a),a.prototype.chain=function(){return this.__chain__=U,this},a.prototype.value=function(){return this.__wrapped__
},r("pop push reverse shift sort splice unshift".split(" "),function(n){var t=K[n];a.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),xt&&0===n.length&&delete n[0],this.__chain__&&(n=new a(n),n.__chain__=U),n}}),r(["concat","join","slice"],function(n){var t=K[n];a.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new a(n),n.__chain__=U),n}}),H?typeof module=="object"&&module&&module.exports==H?(module.exports=a)._=a:H._=a:n._=a})(this);