lodash-rails 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +1,42 @@
1
1
  /**
2
2
  * @license
3
- * Lo-Dash 1.0.1 (Custom Build) lodash.com/license
3
+ * Lo-Dash 1.1.0 (Custom Build) lodash.com/license
4
4
  * Build: `lodash modern -o ./dist/lodash.js`
5
5
  * Underscore.js 1.4.4 underscorejs.org/LICENSE
6
6
  */
7
- ;(function(n,t){function r(n){if(!n||typeof n!="object")return W;var t=n.valueOf,r=typeof t=="function"&&(r=bt(t))&&bt(r);if(r)n=n==r||bt(n)==r&&!h(n);else{var e=W;!n||typeof n!="object"||h(n)?n=e:(t=n.constructor,!j(t)||t instanceof t?(Yt(n,function(n,t){e=t}),n=e===W||jt.call(n,e)):n=e)}return n}function e(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof e?(this.__wrapped__=n,void 0):new e(n)}function u(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||ut);if(u){var o={};for(r=t-1;++r<e;){var i=n[r]+"";
8
- (jt.call(o,i)?o[i]:o[i]=[]).push(n[r])}}return function(r){if(u){var e=r+"";return jt.call(o,e)&&-1<z(o[e],r)}return-1<z(n,r,t)}}function o(n){return n.charCodeAt(0)}function i(n,t){var r=n.b,e=t.b;if(n=n.a,t=t.a,n!==t){if(n>t||typeof n=="undefined")return 1;if(n<t||typeof t=="undefined")return-1}return r<e?-1:1}function f(n,t,r,e){function u(){var a=arguments,c=i?this:t;return o||(n=t[f]),r.length&&(a=a.length?(a=v(a),e?a.concat(r):r.concat(a)):r),this instanceof u?(s.prototype=n.prototype,c=new s,s.prototype=Q,a=n.apply(c,a),w(a)?a:c):n.apply(c,a)
9
- }var o=j(n),i=!r,f=t;return i&&(r=t),o||(t=n),u}function a(n,t,r){if(n==Q)return G;var e=typeof n;if("function"!=e){if("object"!=e)return function(t){return t[n]};var u=tr(n);return function(t){for(var r=u.length,e=W;r--&&(e=b(t[u[r]],n[u[r]],et)););return e}}return typeof t!="undefined"?1===r?function(r){return n.call(t,r)}:2===r?function(r,e){return n.call(t,r,e)}:4===r?function(r,e,u,o){return n.call(t,r,e,u,o)}:function(r,e,u){return n.call(t,r,e,u)}:n}function c(){for(var n,t={g:Ut,b:"l(n)",c:"",h:"",l:"",m:L},r=0;n=arguments[r];r++)for(var e in n)t[e]=n[e];
10
- return n=t.a,t.d=/^[^,]+/.exec(n)[0],r="var j,n="+t.d+",u=n;if(!n)return u;"+t.l+";",t.b&&(r+="var o=n.length;j=-1;if("+t.b+"){while(++j<o){"+t.h+"}}else{"),t.g&&t.m?r+="var s=-1,t=r[typeof n]?p(n):[],o=t.length;while(++s<o){j=t[s];"+t.h+"}":(r+="for(j in n){",t.m&&(r+="if(",t.m&&(r+="i.call(n,j)"),r+="){"),r+=t.h+";",t.m&&(r+="}"),r+="}"),t.b&&(r+="}"),r+=t.c+";return u",Function("f,i,k,l,m,r,p","return function("+n+"){"+r+"}")(a,jt,h,nr,A,Ht,kt)}function l(n){return"\\"+Jt[n]}function p(n){return rr[n]
11
- }function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=Array(0>r?0:r);++e<r;)u[e]=n[t+e];return u}function g(n){return er[n]}function h(n){return xt.call(n)==Ft}function y(n){var t=[];return Zt(n,function(n,r){t.push(r)}),t}function m(n,r,e,u,o,i){var f=n;if(typeof r=="function"&&(u=e,e=r,r=W),typeof e=="function"){e=typeof u=="undefined"?e:a(e,u,1);var f=e(f),c=typeof f!="undefined";c||(f=n)}if(u=w(f)){var l=xt.call(f);if(!Vt[l])return f;var p=nr(f)
12
- }if(!u||!r)return u&&!c?p?v(f):ur({},f):f;switch(u=Gt[l],l){case Dt:case It:return c?f:new u(+f);case Tt:case zt:return c?f:new u(f);case Mt:return c?f:u(f.source,lt.exec(f))}for(o||(o=[]),i||(i=[]),l=o.length;l--;)if(o[l]==n)return i[l];return c||(f=p?u(f.length):{},p&&(jt.call(n,"index")&&(f.index=n.index),jt.call(n,"input")&&(f.input=n.input))),o.push(n),i.push(f),(p?$:Zt)(c?f:n,function(n,u){f[u]=m(n,r,e,t,o,i)}),f}function d(n){var t=[];return Yt(n,function(n,r){j(n)&&t.push(r)}),t.sort()}function _(n){for(var t=-1,r=tr(n),e=r.length,u={};++t<e;){var o=r[t];
13
- u[n[o]]=o}return u}function b(n,t,r,e,u,o){var i=r===et;if(r&&!i){r=typeof e=="undefined"?r:a(r,e,2);var f=r(n,t);if(typeof f!="undefined")return!!f}if(n===t)return 0!==n||1/n==1/t;var c=typeof n,l=typeof t;if(n===n&&(!n||"function"!=c&&"object"!=c)&&(!t||"function"!=l&&"object"!=l))return W;if(n==Q||t==Q)return n===t;if(l=xt.call(n),c=xt.call(t),l==Ft&&(l=Bt),c==Ft&&(c=Bt),l!=c)return W;switch(l){case Dt:case It:return+n==+t;case Tt:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case Mt:case zt:return n==t+""
14
- }if(c=l==qt,!c){if(n.__wrapped__||t.__wrapped__)return b(n.__wrapped__||n,t.__wrapped__||t,r,e,u,o);if(l!=Bt)return W;var l=n.constructor,p=t.constructor;if(l!=p&&(!j(l)||!(l instanceof l&&j(p)&&p instanceof p)))return W}for(u||(u=[]),o||(o=[]),l=u.length;l--;)if(u[l]==n)return o[l]==t;var s=0,f=L;if(u.push(n),o.push(t),c){if(l=n.length,s=t.length,f=s==n.length,!f&&!i)return f;for(;s--;)if(c=l,p=t[s],i)for(;c--&&!(f=b(n[c],p,r,e,u,o)););else if(!(f=b(n[s],p,r,e,u,o)))break;return f}return Yt(t,function(t,i,a){return jt.call(a,i)?(s++,f=jt.call(n,i)&&b(n[i],t,r,e,u,o)):void 0
15
- }),f&&!i&&Yt(n,function(n,t,r){return jt.call(r,t)?f=-1<--s:void 0}),f}function j(n){return typeof n=="function"}function w(n){return n?Ht[typeof n]:W}function x(n){return typeof n=="number"||xt.call(n)==Tt}function A(n){return typeof n=="string"||xt.call(n)==zt}function O(n,t,e){var u=arguments,o=0,i=2;if(!w(n))return n;if(e===et)var f=u[3],c=u[4],l=u[5];else c=[],l=[],typeof e!="number"&&(i=u.length),3<i&&"function"==typeof u[i-2]?f=a(u[--i-1],u[i--],2):2<i&&"function"==typeof u[i-1]&&(f=u[--i]);for(;++o<i;)(nr(u[o])?$:Zt)(u[o],function(t,e){var u,o,i=t,a=n[e];
16
- if(t&&((o=nr(t))||r(t))){for(i=c.length;i--;)if(u=c[i]==t){a=l[i];break}u||(a=o?nr(a)?a:[]:r(a)?a:{},f&&(i=f(a,t),typeof i!="undefined"&&(a=i)),c.push(t),l.push(a),f||(a=O(a,t,et,f,c,l)))}else f&&(i=f(a,t),typeof i=="undefined"&&(i=t)),typeof i!="undefined"&&(a=i);n[e]=a});return n}function E(n){for(var t=-1,r=tr(n),e=r.length,u=Array(e);++t<e;)u[t]=n[r[t]];return u}function S(n,t,r){var e=-1,u=n?n.length:0,o=W;return r=(0>r?Nt(0,u+r):r)||0,typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):z(n,t,r)):Xt(n,function(n){return++e<r?void 0:!(o=n===t)
17
- }),o}function k(n,t,r){var e=L;if(t=a(t,r),nr(n)){r=-1;for(var u=n.length;++r<u&&(e=!!t(n[r],r,n)););}else Xt(n,function(n,r,u){return e=!!t(n,r,u)});return e}function N(n,t,r){var e=[];if(t=a(t,r),nr(n)){r=-1;for(var u=n.length;++r<u;){var o=n[r];t(o,r,n)&&e.push(o)}}else Xt(n,function(n,r,u){t(n,r,u)&&e.push(n)});return e}function R(n,t,r){var e;return t=a(t,r),$(n,function(n,r,u){return t(n,r,u)?(e=n,W):void 0}),e}function $(n,t,r){if(t&&typeof r=="undefined"&&nr(n)){r=-1;for(var e=n.length;++r<e&&t(n[r],r,n)!==W;);}else Xt(n,t,r);
18
- return n}function F(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0);if(t=a(t,r),nr(n))for(;++e<u;)o[e]=t(n[e],e,n);else Xt(n,function(n,r,u){o[++e]=t(n,r,u)});return o}function q(n,t,r){var e=-1/0,u=e;if(!t&&nr(n)){r=-1;for(var i=n.length;++r<i;){var f=n[r];f>u&&(u=f)}}else t=!t&&A(n)?o:a(t,r),Xt(n,function(n,r,o){r=t(n,r,o),r>e&&(e=r,u=n)});return u}function D(n,t,r,e){var u=3>arguments.length;if(t=a(t,e,4),nr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++o<i;)r=t(r,n[o],o,n)}else Xt(n,function(n,e,o){r=u?(u=W,n):t(r,n,e,o)
19
- });return r}function I(n,t,r,e){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=tr(n),u=i.length;return t=a(t,e,4),$(n,function(e,f,a){f=i?i[--u]:--u,r=o?(o=W,n[f]):t(r,n[f],f,a)}),r}function T(n,t,r){var e;if(t=a(t,r),nr(n)){r=-1;for(var u=n.length;++r<u&&!(e=t(n[r],r,n)););}else Xt(n,function(n,r,u){return!(e=t(n,r,u))});return!!e}function B(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=Q){var o=-1;for(t=a(t,r);++o<u&&t(n[o],o,n);)e++}else if(e=t,e==Q||r)return n[0];
20
- return v(n,0,Rt(Nt(0,e),u))}}function M(n,t){for(var r=-1,e=n?n.length:0,u=[];++r<e;){var o=n[r];nr(o)?wt.apply(u,t?o:M(o)):u.push(o)}return u}function z(n,t,r){var e=-1,u=n?n.length:0;if(typeof r=="number")e=(0>r?Nt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e<u;)if(n[e]===t)return e;return-1}function P(n,t,r){if(typeof t!="number"&&t!=Q){var e=0,u=-1,o=n?n.length:0;for(t=a(t,r);++u<o&&t(n[u],u,n);)e++}else e=t==Q||r?1:Nt(0,t);return v(n,e)}function C(n,t,r,e){var u=0,o=n?n.length:u;
21
- for(r=r?a(r,e,1):G,t=r(t);u<o;)e=u+o>>>1,r(n[e])<t?u=e+1:o=e;return u}function K(n,t,r,e){var u=-1,o=n?n.length:0,i=[],f=i;typeof t=="function"&&(e=r,r=t,t=W);var c=!t&&75<=o;if(c)var l={};for(r&&(f=[],r=a(r,e));++u<o;){e=n[u];var p=r?r(e,u,n):e;if(c)var s=p+"",s=jt.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>z(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Kt||At&&2<arguments.length?At.call.apply(At,arguments):f(n,t,v(arguments,2))}function V(n){var r=v(arguments,1);
22
- return setTimeout(function(){n.apply(t,r)},1)}function G(n){return n}function H(n){$(d(n),function(t){var r=e[t]=n[t];e.prototype[t]=function(){var n=[this.__wrapped__];return wt.apply(n,arguments),new e(r.apply(e,n))}})}function J(){return this.__wrapped__}var L=!0,Q=null,W=!1,X=typeof exports=="object"&&exports,Y=typeof module=="object"&&module&&module.exports==X&&module,Z=typeof global=="object"&&global;Z.global===Z&&(n=Z);var nt=[],tt={},rt=0,et=tt,ut=30,ot=n._,it=/&(?:amp|lt|gt|quot|#39);/g,ft=/\b__p\+='';/g,at=/\b(__p\+=)''\+/g,ct=/(__e\(.*?\)|\b__t\))\+'';/g,lt=/\w*$/,pt=RegExp("^"+(tt.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),st=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vt=/<%=([\s\S]+?)%>/g,gt=/($^)/,ht=/[&<>"']/g,yt=/['\n\r\t\u2028\u2029\\]/g,mt=Math.ceil,dt=nt.concat,_t=Math.floor,bt=pt.test(bt=Object.getPrototypeOf)&&bt,jt=tt.hasOwnProperty,wt=nt.push,xt=tt.toString,At=pt.test(At=v.bind)&&At,Ot=pt.test(Ot=Array.isArray)&&Ot,Et=n.isFinite,St=n.isNaN,kt=pt.test(kt=Object.keys)&&kt,Nt=Math.max,Rt=Math.min,$t=Math.random,Ft="[object Arguments]",qt="[object Array]",Dt="[object Boolean]",It="[object Date]",Tt="[object Number]",Bt="[object Object]",Mt="[object RegExp]",zt="[object String]",Pt=!!n.attachEvent,Ct=At&&!/\n|true/.test(At+Pt),Kt=At&&!Ct,Ut=kt&&(Pt||Ct),Vt={"[object Function]":W};
23
- Vt[Ft]=Vt[qt]=Vt[Dt]=Vt[It]=Vt[Tt]=Vt[Bt]=Vt[Mt]=Vt[zt]=L;var Gt={};Gt[qt]=Array,Gt[Dt]=Boolean,Gt[It]=Date,Gt[Bt]=Object,Gt[Tt]=Number,Gt[Mt]=RegExp,Gt[zt]=String;var Ht={"boolean":W,"function":L,object:L,number:W,string:W,undefined:W},Jt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:vt,variable:"",imports:{_:e}};var Lt={a:"q,w,h",l:"var a=arguments,b=0,c=typeof h=='number'?2:a.length;while(++b<c){n=a[b];if(n&&r[typeof n]){",h:"if(typeof u[j]=='undefined')u[j]=n[j]",c:"}}"},Qt={a:"e,d,x",l:"d=d&&typeof x=='undefined'?d:f(d,x)",b:"typeof o=='number'",h:"if(d(n[j],j,e)===false)return u"},Wt={l:"if(!r[typeof n])return u;"+Qt.l,b:W},Xt=c(Qt),Yt=c(Qt,Wt,{m:W}),Zt=c(Qt,Wt),nr=Ot||function(n){return n instanceof Array||xt.call(n)==qt
24
- },tr=kt?function(n){return w(n)?kt(n):[]}:y,rr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},er=_(rr),ur=c(Lt,{l:Lt.l.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=f(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),h:"u[j]=d?d(u[j],n[j]):n[j]"}),or=c(Lt);j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==xt.call(n)}),Ct&&Y&&typeof setImmediate=="function"&&(V=U(setImmediate,n)),e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0
25
- }},e.assign=ur,e.at=function(n){for(var t=-1,r=dt.apply(nt,v(arguments,1)),e=r.length,u=Array(e);++t<e;)u[t]=n[r[t]];return u},e.bind=U,e.bindAll=function(n){for(var t=dt.apply(nt,arguments),r=1<t.length?0:(t=d(n),-1),e=t.length;++r<e;){var u=t[r];n[u]=U(n[u],n)}return n},e.bindKey=function(n,t){return f(n,t,v(arguments,2))},e.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},e.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length;r--;)t=[n[r].apply(this,t)];
26
- return t[0]}},e.countBy=function(n,t,r){var e={};return t=a(t,r),$(n,function(n,r,u){r=t(n,r,u)+"",jt.call(e,r)?e[r]++:e[r]=1}),e},e.debounce=function(n,t,r){function e(){f=Q,r||(o=n.apply(i,u))}var u,o,i,f;return function(){var a=r&&!f;return u=arguments,i=this,clearTimeout(f),f=setTimeout(e,t),a&&(o=n.apply(i,u)),o}},e.defaults=or,e.defer=V,e.delay=function(n,r){var e=v(arguments,2);return setTimeout(function(){n.apply(t,e)},r)},e.difference=function(n){for(var t=-1,r=n?n.length:0,e=dt.apply(nt,arguments),e=u(e,r),o=[];++t<r;){var i=n[t];
27
- e(i)||o.push(i)}return o},e.filter=N,e.flatten=M,e.forEach=$,e.forIn=Yt,e.forOwn=Zt,e.functions=d,e.groupBy=function(n,t,r){var e={};return t=a(t,r),$(n,function(n,r,u){r=t(n,r,u)+"",(jt.call(e,r)?e[r]:e[r]=[]).push(n)}),e},e.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t!="number"&&t!=Q){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else e=t==Q||r?1:t||e;return v(n,0,Rt(Nt(0,u-e),u))},e.intersection=function(n){var t=arguments,r=t.length,e={0:{}},o=-1,i=n?n.length:0,f=100<=i,a=[],c=a;
28
- n:for(;++o<i;){var l=n[o];if(f)var p=l+"",p=jt.call(e[0],p)?!(c=e[0][p]):c=e[0][p]=[];if(p||0>z(c,l)){f&&c.push(l);for(var s=r;--s;)if(!(e[s]||(e[s]=u(t[s],0,100)))(l))continue n;a.push(l)}}return a},e.invert=_,e.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return $(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},e.keys=tr,e.map=F,e.max=q,e.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+"";
29
- return jt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},e.merge=O,e.min=function(n,t,r){var e=1/0,u=e;if(!t&&nr(n)){r=-1;for(var i=n.length;++r<i;){var f=n[r];f<u&&(u=f)}}else t=!t&&A(n)?o:a(t,r),Xt(n,function(n,r,o){r=t(n,r,o),r<e&&(e=r,u=n)});return u},e.object=function(n,t){for(var r=-1,e=n?n.length:0,u={};++r<e;){var o=n[r];t?u[o]=t[r]:u[o[0]]=o[1]}return u},e.omit=function(n,t,r){var e=typeof t=="function",u={};if(e)t=a(t,r);else var o=dt.apply(nt,arguments);return Yt(n,function(n,r,i){(e?!t(n,r,i):0>z(o,r,1))&&(u[r]=n)
30
- }),u},e.once=function(n){var t,r;return function(){return t?r:(t=L,r=n.apply(this,arguments),n=Q,r)}},e.pairs=function(n){for(var t=-1,r=tr(n),e=r.length,u=Array(e);++t<e;){var o=r[t];u[t]=[o,n[o]]}return u},e.partial=function(n){return f(n,v(arguments,1))},e.partialRight=function(n){return f(n,v(arguments,1),Q,et)},e.pick=function(n,t,r){var e={};if(typeof t!="function")for(var u=0,o=dt.apply(nt,arguments),i=w(n)?o.length:0;++u<i;){var f=o[u];f in n&&(e[f]=n[f])}else t=a(t,r),Yt(n,function(n,r,u){t(n,r,u)&&(e[r]=n)
31
- });return e},e.pluck=F,e.range=function(n,t,r){n=+n||0,r=+r||1,t==Q&&(t=n,n=0);var e=-1;t=Nt(0,mt((t-n)/r));for(var u=Array(t);++e<t;)u[e]=n,n+=r;return u},e.reject=function(n,t,r){return t=a(t,r),N(n,function(n,r,e){return!t(n,r,e)})},e.rest=P,e.shuffle=function(n){var t=-1,r=n?n.length:0,e=Array(typeof r=="number"?r:0);return $(n,function(n){var r=_t($t()*(++t+1));e[t]=e[r],e[r]=n}),e},e.sortBy=function(n,t,r){var e=-1,u=n?n.length:0,o=Array(typeof u=="number"?u:0);for(t=a(t,r),$(n,function(n,r,u){o[++e]={a:t(n,r,u),b:e,c:n}
32
- }),u=o.length,o.sort(i);u--;)o[u]=o[u].c;return o},e.tap=function(n,t){return t(n),n},e.throttle=function(n,t){function r(){f=new Date,i=Q,u=n.apply(o,e)}var e,u,o,i,f=0;return function(){var a=new Date,c=t-(a-f);return e=arguments,o=this,0<c?i||(i=setTimeout(r,c)):(clearTimeout(i),i=Q,f=a,u=n.apply(o,e)),u}},e.times=function(n,t,r){n=+n||0;for(var e=-1,u=Array(n);++e<n;)u[e]=t.call(r,e);return u},e.toArray=function(n){return n&&typeof n.length=="number"?v(n):E(n)},e.union=function(){return K(dt.apply(nt,arguments))
33
- },e.uniq=K,e.values=E,e.where=N,e.without=function(n){for(var t=-1,r=n?n.length:0,e=u(arguments,1),o=[];++t<r;){var i=n[t];e(i)||o.push(i)}return o},e.wrap=function(n,t){return function(){var r=[n];return wt.apply(r,arguments),t.apply(this,r)}},e.zip=function(n){for(var t=-1,r=n?q(F(arguments,"length")):0,e=Array(r);++t<r;)e[t]=F(arguments,t);return e},e.collect=F,e.drop=P,e.each=$,e.extend=ur,e.methods=d,e.select=N,e.tail=P,e.unique=K,H(e),e.clone=m,e.cloneDeep=function(n,t,r){return m(n,L,t,r)},e.contains=S,e.escape=function(n){return n==Q?"":(n+"").replace(ht,p)
34
- },e.every=k,e.find=R,e.has=function(n,t){return n?jt.call(n,t):W},e.identity=G,e.indexOf=z,e.isArguments=h,e.isArray=nr,e.isBoolean=function(n){return n===L||n===W||xt.call(n)==Dt},e.isDate=function(n){return n instanceof Date||xt.call(n)==It},e.isElement=function(n){return n?1===n.nodeType:W},e.isEmpty=function(n){var t=L;if(!n)return t;var r=xt.call(n),e=n.length;return r==qt||r==zt||r==Ft||r==Bt&&typeof e=="number"&&j(n.splice)?!e:(Zt(n,function(){return t=W}),t)},e.isEqual=b,e.isFinite=function(n){return Et(n)&&!St(parseFloat(n))
35
- },e.isFunction=j,e.isNaN=function(n){return x(n)&&n!=+n},e.isNull=function(n){return n===Q},e.isNumber=x,e.isObject=w,e.isPlainObject=r,e.isRegExp=function(n){return n instanceof RegExp||xt.call(n)==Mt},e.isString=A,e.isUndefined=function(n){return typeof n=="undefined"},e.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?Nt(0,e+r):Rt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},e.mixin=H,e.noConflict=function(){return n._=ot,this},e.random=function(n,t){return n==Q&&t==Q&&(t=1),n=+n||0,t==Q&&(t=n,n=0),n+_t($t()*((+t||0)-n+1))
36
- },e.reduce=D,e.reduceRight=I,e.result=function(n,r){var e=n?n[r]:t;return j(e)?n[r]():e},e.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:tr(n).length},e.some=T,e.sortedIndex=C,e.template=function(n,r,u){var o=e.templateSettings;n||(n=""),u=or({},u,o);var i,f=or({},u.imports,o.imports),o=tr(f),f=E(f),a=0,c=u.interpolate||gt,p="__p+='";n.replace(RegExp((u.escape||gt).source+"|"+c.source+"|"+(c===vt?st:gt).source+"|"+(u.evaluate||gt).source+"|$","g"),function(t,r,e,u,o,f){return e||(e=u),p+=n.slice(a,f).replace(yt,l),r&&(p+="'+__e("+r+")+'"),o&&(i=L,p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),a=f+t.length,t
37
- }),p+="';\n",c=u=u.variable,c||(u="obj",p="with("+u+"){"+p+"}"),p=(i?p.replace(ft,""):p).replace(at,"$1").replace(ct,"$1;"),p="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=Function(o,"return "+p).apply(t,f)}catch(v){throw v.source=p,v}return r?s(r):(s.source=p,s)},e.unescape=function(n){return n==Q?"":(n+"").replace(it,g)},e.uniqueId=function(n){var t=++rt;return(n==Q?"":n+"")+t
38
- },e.all=k,e.any=T,e.detect=R,e.foldl=D,e.foldr=I,e.include=S,e.inject=D,Zt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(){var t=[this.__wrapped__];return wt.apply(t,arguments),n.apply(e,t)})}),e.first=B,e.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=Q){var o=u;for(t=a(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==Q||r)return n[u-1];return v(n,Nt(0,u-e))}},e.take=B,e.head=B,Zt(e,function(n,t){e.prototype[t]||(e.prototype[t]=function(t,r){var u=n(this.__wrapped__,t,r);
39
- return t==Q||r&&typeof t!="function"?u:new e(u)})}),e.VERSION="1.0.1",e.prototype.toString=function(){return this.__wrapped__+""},e.prototype.value=J,e.prototype.valueOf=J,Xt(["join","pop","shift"],function(n){var t=nt[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Xt(["push","reverse","sort","unshift"],function(n){var t=nt[n];e.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Xt(["concat","slice","splice"],function(n){var t=nt[n];e.prototype[n]=function(){return new e(t.apply(this.__wrapped__,arguments))
40
- }}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=e,define(function(){return e})):X?Y?(Y.exports=e)._=e:X._=e:n._=e})(this);
7
+ ;(function(n){function t(r){function a(n){return n&&typeof n=="object"&&!ae(n)&&Ut.call(n,"__wrapped__")?n:new z(n)}function $(n,t,e){var r=n.length,u=r-t>=e;if(u){var a={};for(e=t-1;++e<r;){var o=$t(n[e]);(Ut.call(a,o)?a[o]:a[o]=[]).push(n[e])}}return function(e){if(u){var r=$t(e);return Ut.call(a,r)&&-1<gt(a[r],e)}return-1<gt(n,e,t)}}function q(n){return n.charCodeAt(0)}function B(n,t){var e=n.b,r=t.b;if(n=n.a,t=t.a,n!==t){if(n>t||typeof n=="undefined")return 1;if(n<t||typeof t=="undefined")return-1
8
+ }return e<r?-1:1}function F(n,t,e,r){function u(){var r=arguments,c=o?this:t;return a||(n=t[i]),e.length&&(r=r.length?(r=M(r),f?r.concat(e):e.concat(r)):e),this instanceof u?(P.prototype=n.prototype,c=new P,P.prototype=null,r=n.apply(c,r),W(r)?r:c):n.apply(c,r)}var a=Q(n),o=!e,i=t;if(o){var f=r;e=t}else if(!a){if(!r)throw new qt;t=n}return u}function R(){for(var n,t={b:"k(m)",c:"",e:"m",f:"",h:"",i:!0,j:!!oe},e=0;n=arguments[e];e++)for(var r in n)t[r]=n[r];return n=t.a,t.d=/^[^,]+/.exec(n)[0],e=Nt,r="var i,m="+t.d+",u="+t.e+";if(!m)return u;"+t.h+";",t.b&&(r+="var n=m.length;i=-1;if("+t.b+"){while(++i<n){"+t.f+"}}else{"),t.i&&t.j?r+="var s=-1,t=r[typeof m]?o(m):[],n=t.length;while(++s<n){i=t[s];"+t.f+"}":(r+="for(i in m){",t.i&&(r+="if(",t.i&&(r+="h.call(m,i)"),r+="){"),r+=t.f+";",t.i&&(r+="}"),r+="}"),t.b&&(r+="}"),r+=t.c+";return u",e("h,j,k,l,o,p,r","return function("+n+"){"+r+"}")(Ut,V,ae,Y,oe,a,I)
9
+ }function T(n){return"\\"+S[n]}function D(n){return ie[n]}function z(n){this.__wrapped__=n}function P(){}function K(n){var t=!1;if(!n||Jt.call(n)!=x)return t;var e=n.constructor;return(Q(e)?e instanceof e:ue.nodeClass||!isNode(n))?(pe(n,function(n,e){t=e}),!1===t||Ut.call(n,t)):t}function M(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0);var r=-1;e=e-t||0;for(var u=Ct(0>e?0:e);++r<e;)u[r]=n[t+r];return u}function U(n){return fe[n]}function V(n){return Jt.call(n)==_}function G(n,t,r,u,o,i){var f=n;
10
+ if(typeof t=="function"&&(u=r,r=t,t=!1),typeof r=="function"){if(r=typeof u=="undefined"?r:a.createCallback(r,u,1),f=r(f),typeof f!="undefined")return f;f=n}if(u=W(f)){var c=Jt.call(f);if(!E[c])return f;var l=ae(f)}if(!u||!t)return u?l?M(f):ce({},f):f;switch(u=re[c],c){case w:case j:return new u(+f);case C:case N:return new u(f);case O:return u(f.source,v.exec(f))}for(o||(o=[]),i||(i=[]),c=o.length;c--;)if(o[c]==n)return i[c];return f=l?u(f.length):{},l&&(Ut.call(n,"index")&&(f.index=n.index),Ut.call(n,"input")&&(f.input=n.input)),o.push(n),i.push(f),(l?at:se)(n,function(n,u){f[u]=G(n,t,r,e,o,i)
11
+ }),f}function H(n){var t=[];return pe(n,function(n,e){Q(n)&&t.push(e)}),t.sort()}function J(n){for(var t=-1,e=oe(n),r=e.length,u={};++t<r;){var a=e[t];u[n[a]]=a}return u}function L(n,t,e,r,u,o){var f=e===i;if(e&&!f){e=typeof r=="undefined"?e:a.createCallback(e,r,2);var c=e(n,t);if(typeof c!="undefined")return!!c}if(n===t)return 0!==n||1/n==1/t;var l=typeof n,p=typeof t;if(n===n&&(!n||"function"!=l&&"object"!=l)&&(!t||"function"!=p&&"object"!=p))return!1;if(null==n||null==t)return n===t;if(p=Jt.call(n),l=Jt.call(t),p==_&&(p=x),l==_&&(l=x),p!=l)return!1;
12
+ switch(p){case w:case j:return+n==+t;case C:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case O:case N:return n==$t(t)}if(l=p==k,!l){if(Ut.call(n,"__wrapped__")||Ut.call(t,"__wrapped__"))return L(n.__wrapped__||n,t.__wrapped__||t,e,r,u,o);if(p!=x)return!1;var p=n.constructor,s=t.constructor;if(p!=s&&(!Q(p)||!(p instanceof p&&Q(s)&&s instanceof s)))return!1}for(u||(u=[]),o||(o=[]),p=u.length;p--;)if(u[p]==n)return o[p]==t;var v=0,c=!0;if(u.push(n),o.push(t),l){if(p=n.length,v=t.length,c=v==n.length,!c&&!f)return c;
13
+ for(;v--;)if(l=p,s=t[v],f)for(;l--&&!(c=L(n[l],s,e,r,u,o)););else if(!(c=L(n[v],s,e,r,u,o)))break;return c}return pe(t,function(t,a,i){return Ut.call(i,a)?(v++,c=Ut.call(n,a)&&L(n[a],t,e,r,u,o)):void 0}),c&&!f&&pe(n,function(n,t,e){return Ut.call(e,t)?c=-1<--v:void 0}),c}function Q(n){return typeof n=="function"}function W(n){return n?I[typeof n]:!1}function X(n){return typeof n=="number"||Jt.call(n)==C}function Y(n){return typeof n=="string"||Jt.call(n)==N}function Z(n,t,e){var r=arguments,u=0,o=2;
14
+ if(!W(n))return n;if(e===i)var f=r[3],c=r[4],l=r[5];else c=[],l=[],typeof e!="number"&&(o=r.length),3<o&&"function"==typeof r[o-2]?f=a.createCallback(r[--o-1],r[o--],2):2<o&&"function"==typeof r[o-1]&&(f=r[--o]);for(;++u<o;)(ae(r[u])?at:se)(r[u],function(t,e){var r,u,a=t,o=n[e];if(t&&((u=ae(t))||ve(t))){for(a=c.length;a--;)if(r=c[a]==t){o=l[a];break}r||(o=u?ae(o)?o:[]:ve(o)?o:{},f&&(a=f(o,t),typeof a!="undefined"&&(o=a)),c.push(t),l.push(o),f||(o=Z(o,t,i,f,c,l)))}else f&&(a=f(o,t),typeof a=="undefined"&&(a=t)),typeof a!="undefined"&&(o=a);
15
+ n[e]=o});return n}function nt(n){for(var t=-1,e=oe(n),r=e.length,u=Ct(r);++t<r;)u[t]=n[e[t]];return u}function tt(n,t,e){var r=-1,u=n?n.length:0,a=!1;return e=(0>e?Zt(0,u+e):e)||0,typeof u=="number"?a=-1<(Y(n)?n.indexOf(t,e):gt(n,t,e)):se(n,function(n){return++r<e?void 0:!(a=n===t)}),a}function et(n,t,e){var r=!0;t=a.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u&&(r=!!t(n[e],e,n)););else se(n,function(n,e,u){return r=!!t(n,e,u)});return r}function rt(n,t,e){var r=[];
16
+ t=a.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e<u;){var o=n[e];t(o,e,n)&&r.push(o)}else se(n,function(n,e,u){t(n,e,u)&&r.push(n)});return r}function ut(n,t,e){t=a.createCallback(t,e),e=-1;var r=n?n.length:0;if(typeof r!="number"){var u;return se(n,function(n,e,r){return t(n,e,r)?(u=n,!1):void 0}),u}for(;++e<r;){var o=n[e];if(t(o,e,n))return o}}function at(n,t,e){var r=-1,u=n?n.length:0;if(typeof u=="number")for(t=t&&typeof e=="undefined"?t:a.createCallback(t,e);++r<u&&!1!==t(n[r],r,n););else se(n,t,e);
17
+ return n}function ot(n,t,e){var r=-1,u=n?n.length:0;if(t=a.createCallback(t,e),typeof u=="number")for(var o=Ct(u);++r<u;)o[r]=t(n[r],r,n);else o=[],se(n,function(n,e,u){o[++r]=t(n,e,u)});return o}function it(n,t,e){var r=-1/0,u=r;if(!t&&ae(n)){e=-1;for(var o=n.length;++e<o;){var i=n[e];i>u&&(u=i)}}else t=!t&&Y(n)?q:a.createCallback(t,e),at(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function ft(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Ct(r);++e<r;)u[e]=n[e][t];return u||ot(n,t)
18
+ }function ct(n,t,e,r){if(!n)return e;var u=3>arguments.length;t=a.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++o<i;)e=t(e,n[o],o,n);else se(n,function(n,r,a){e=u?(u=!1,n):t(e,n,r,a)});return e}function lt(n,t,e,r){var u=n?n.length:0,o=3>arguments.length;if(typeof u!="number")var i=oe(n),u=i.length;return t=a.createCallback(t,r,4),at(n,function(r,a,f){a=i?i[--u]:--u,e=o?(o=!1,n[a]):t(e,n[a],a,f)}),e}function pt(n,t,e){var r;t=a.createCallback(t,e),e=-1;var u=n?n.length:0;
19
+ if(typeof u=="number")for(;++e<u&&!(r=t(n[e],e,n)););else se(n,function(n,e,u){return!(r=t(n,e,u))});return!!r}function st(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=-1;for(t=a.createCallback(t,e);++o<u&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[0];return M(n,0,ne(Zt(0,r),u))}}function vt(n,t,e,r){var u=-1,o=n?n.length:0,i=[];for(typeof t!="boolean"&&null!=t&&(r=e,e=t,t=!1),null!=e&&(e=a.createCallback(e,r));++u<o;)r=n[u],e&&(r=e(r,u,n)),ae(r)?Vt.apply(i,t?r:vt(r)):i.push(r);
20
+ return i}function gt(n,t,e){var r=-1,u=n?n.length:0;if(typeof e=="number")r=(0>e?Zt(0,u+e):e||0)-1;else if(e)return r=yt(n,t),n[r]===t?r:-1;for(;++r<u;)if(n[r]===t)return r;return-1}function ht(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=a.createCallback(t,e);++u<o&&t(n[u],u,n);)r++}else r=null==t||e?1:Zt(0,t);return M(n,r)}function yt(n,t,e,r){var u=0,o=n?n.length:u;for(e=e?a.createCallback(e,r,1):kt,t=e(t);u<o;)r=u+o>>>1,e(n[r])<t?u=r+1:o=r;return u}function mt(n,t,e,r){var u=-1,o=n?n.length:0,i=[],f=i;
21
+ typeof t!="boolean"&&null!=t&&(r=e,e=t,t=!1);var c=!t&&75<=o;if(c)var l={};for(null!=e&&(f=[],e=a.createCallback(e,r));++u<o;){r=n[u];var p=e?e(r,u,n):r;if(c)var s=$t(p),s=Ut.call(l,s)?!(f=l[s]):f=l[s]=[];(t?!u||f[f.length-1]!==p:s||0>gt(f,p))&&((e||c)&&f.push(p),i.push(r))}return i}function bt(n,t){for(var e=-1,r=n?n.length:0,u={};++e<r;){var a=n[e];t?u[a]=t[e]:u[a[0]]=a[1]}return u}function dt(n,t){return ue.fastBind||Lt&&2<arguments.length?Lt.call.apply(Lt,arguments):F(n,t,M(arguments,2))}function _t(n){var t=M(arguments,1);
22
+ return Ht(function(){n.apply(e,t)},1)}function kt(n){return n}function wt(n){at(H(n),function(t){var e=a[t]=n[t];a.prototype[t]=function(){var n=this.__wrapped__,t=[n];return Vt.apply(t,arguments),t=e.apply(a,t),n&&typeof n=="object"&&n==t?this:new z(t)}})}function jt(){return this.__wrapped__}r=r?A.defaults(n.Object(),r,A.pick(n,d)):n;var Ct=r.Array,xt=r.Boolean,Ot=r.Date,Nt=r.Function,Et=r.Math,It=r.Number,St=r.Object,At=r.RegExp,$t=r.String,qt=r.TypeError,Bt=Ct(),Ft=St(),Rt=r._,Tt=At("^"+$t(Ft.valueOf).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),Dt=Et.ceil,zt=r.clearTimeout,Pt=Bt.concat,Kt=Et.floor,Mt=Tt.test(Mt=St.getPrototypeOf)&&Mt,Ut=Ft.hasOwnProperty,Vt=Bt.push,Gt=r.setImmediate,Ht=r.setTimeout,Jt=Ft.toString,Lt=Tt.test(Lt=M.bind)&&Lt,Qt=Tt.test(Qt=Ct.isArray)&&Qt,Wt=r.isFinite,Xt=r.isNaN,Yt=Tt.test(Yt=St.keys)&&Yt,Zt=Et.max,ne=Et.min,te=r.parseInt,ee=Et.random,Et=Tt.test(r.attachEvent),Et=Lt&&!/\n|true/.test(Lt+Et),re={};
23
+ re[k]=Ct,re[w]=xt,re[j]=Ot,re[x]=St,re[C]=It,re[O]=At,re[N]=$t;var ue=a.support={};ue.fastBind=Lt&&!Et,a.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:g,variable:"",imports:{_:a}},xt={a:"q,w,g",h:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b<c){m=a[b];if(m&&r[typeof m]){",f:"if(typeof u[i]=='undefined')u[i]=m[i]",c:"}}"},It={a:"e,d,x",h:"d=d&&typeof x=='undefined'?d:p.createCallback(d,x)",b:!1,f:"if(d(m[i],i,e)===false)return u"},St={h:"if(!r[typeof m])return u;"+It.h,b:!1},z.prototype=a.prototype;
24
+ var ae=Qt||function(n){return n instanceof Ct||Jt.call(n)==k},Qt=R({a:"q",e:"[]",h:"if(!(r[typeof q]))return u",f:"u.push(i)",b:!1}),oe=Yt?function(n){return W(n)?Yt(n):[]}:Qt,ie={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},fe=J(ie),ce=R(xt,{h:xt.h.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=p.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),f:"u[i]=d?d(u[i],m[i]):m[i]"}),le=R(xt),pe=R(It,St,{i:!1}),se=R(It,St),ve=function(n){if(!n||Jt.call(n)!=x)return!1;
25
+ var t=n.valueOf,e=typeof t=="function"&&(e=Mt(t))&&Mt(e);return e?n==e||Mt(n)==e:K(n)};return Et&&u&&typeof Gt=="function"&&(_t=dt(Gt,r)),Gt=8==te("08")?te:function(n,t){return te(Y(n)?n.replace(h,""):n,t||0)},a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=ce,a.at=function(n){for(var t=-1,e=Pt.apply(Bt,M(arguments,1)),r=e.length,u=Ct(r);++t<r;)u[t]=n[e[t]];return u},a.bind=dt,a.bindAll=function(n){for(var t=Pt.apply(Bt,arguments),e=1<t.length?0:(t=H(n),-1),r=t.length;++e<r;){var u=t[e];
26
+ n[u]=dt(n[u],n)}return n},a.bindKey=function(n,t){return F(n,t,M(arguments,2),i)},a.compact=function(n){for(var t=-1,e=n?n.length:0,r=[];++t<e;){var u=n[t];u&&r.push(u)}return r},a.compose=function(){var n=arguments;return function(){for(var t=arguments,e=n.length;e--;)t=[n[e].apply(this,t)];return t[0]}},a.countBy=function(n,t,e){var r={};return t=a.createCallback(t,e),at(n,function(n,e,u){e=$t(t(n,e,u)),Ut.call(r,e)?r[e]++:r[e]=1}),r},a.createCallback=function(n,t,e){if(null==n)return kt;var r=typeof n;
27
+ if("function"!=r){if("object"!=r)return function(t){return t[n]};var u=oe(n);return function(t){for(var e=u.length,r=!1;e--&&(r=L(t[u[e]],n[u[e]],i)););return r}}return typeof t!="undefined"?1===e?function(e){return n.call(t,e)}:2===e?function(e,r){return n.call(t,e,r)}:4===e?function(e,r,u,a){return n.call(t,e,r,u,a)}:function(e,r,u){return n.call(t,e,r,u)}:n},a.debounce=function(n,t,e){function r(){i=null,e||(a=n.apply(o,u))}var u,a,o,i;return function(){var f=e&&!i;return u=arguments,o=this,zt(i),i=Ht(r,t),f&&(a=n.apply(o,u)),a
28
+ }},a.defaults=le,a.defer=_t,a.delay=function(n,t){var r=M(arguments,2);return Ht(function(){n.apply(e,r)},t)},a.difference=function(n){for(var t=-1,e=n?n.length:0,r=Pt.apply(Bt,arguments),r=$(r,e,100),u=[];++t<e;){var a=n[t];r(a)||u.push(a)}return u},a.filter=rt,a.flatten=vt,a.forEach=at,a.forIn=pe,a.forOwn=se,a.functions=H,a.groupBy=function(n,t,e){var r={};return t=a.createCallback(t,e),at(n,function(n,e,u){e=$t(t(n,e,u)),(Ut.call(r,e)?r[e]:r[e]=[]).push(n)}),r},a.initial=function(n,t,e){if(!n)return[];
29
+ var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else r=null==t||e?1:t||r;return M(n,0,ne(Zt(0,u-r),u))},a.intersection=function(n){var t=arguments,e=t.length,r={0:{}},u=-1,a=n?n.length:0,o=100<=a,i=[],f=i;n:for(;++u<a;){var c=n[u];if(o)var l=$t(c),l=Ut.call(r[0],l)?!(f=r[0][l]):f=r[0][l]=[];if(l||0>gt(f,c)){o&&f.push(c);for(var p=e;--p;)if(!(r[p]||(r[p]=$(t[p],0,100)))(c))continue n;i.push(c)}}return i},a.invert=J,a.invoke=function(n,t){var e=M(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Ct(typeof a=="number"?a:0);
30
+ return at(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},a.keys=oe,a.map=ot,a.max=it,a.memoize=function(n,t){var e={};return function(){var r=$t(t?t.apply(this,arguments):arguments[0]);return Ut.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=Z,a.min=function(n,t,e){var r=1/0,u=r;if(!t&&ae(n)){e=-1;for(var o=n.length;++e<o;){var i=n[e];i<u&&(u=i)}}else t=!t&&Y(n)?q:a.createCallback(t,e),at(n,function(n,e,a){e=t(n,e,a),e<r&&(r=e,u=n)});return u},a.omit=function(n,t,e){var r=typeof t=="function",u={};
31
+ if(r)t=a.createCallback(t,e);else var o=Pt.apply(Bt,arguments);return pe(n,function(n,e,a){(r?!t(n,e,a):0>gt(o,e,1))&&(u[e]=n)}),u},a.once=function(n){var t,e;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},a.pairs=function(n){for(var t=-1,e=oe(n),r=e.length,u=Ct(r);++t<r;){var a=e[t];u[t]=[a,n[a]]}return u},a.partial=function(n){return F(n,M(arguments,1))},a.partialRight=function(n){return F(n,M(arguments,1),null,i)},a.pick=function(n,t,e){var r={};if(typeof t!="function")for(var u=0,o=Pt.apply(Bt,arguments),i=W(n)?o.length:0;++u<i;){var f=o[u];
32
+ f in n&&(r[f]=n[f])}else t=a.createCallback(t,e),pe(n,function(n,e,u){t(n,e,u)&&(r[e]=n)});return r},a.pluck=ft,a.range=function(n,t,e){n=+n||0,e=+e||1,null==t&&(t=n,n=0);var r=-1;t=Zt(0,Dt((t-n)/e));for(var u=Ct(t);++r<t;)u[r]=n,n+=e;return u},a.reject=function(n,t,e){return t=a.createCallback(t,e),rt(n,function(n,e,r){return!t(n,e,r)})},a.rest=ht,a.shuffle=function(n){var t=-1,e=n?n.length:0,r=Ct(typeof e=="number"?e:0);return at(n,function(n){var e=Kt(ee()*(++t+1));r[t]=r[e],r[e]=n}),r},a.sortBy=function(n,t,e){var r=-1,u=n?n.length:0,o=Ct(typeof u=="number"?u:0);
33
+ for(t=a.createCallback(t,e),at(n,function(n,e,u){o[++r]={a:t(n,e,u),b:r,c:n}}),u=o.length,o.sort(B);u--;)o[u]=o[u].c;return o},a.tap=function(n,t){return t(n),n},a.throttle=function(n,t){function e(){i=new Ot,o=null,u=n.apply(a,r)}var r,u,a,o,i=0;return function(){var f=new Ot,c=t-(f-i);return r=arguments,a=this,0<c?o||(o=Ht(e,c)):(zt(o),o=null,i=f,u=n.apply(a,r)),u}},a.times=function(n,t,e){n=-1<(n=+n)?n:0;var r=-1,u=Ct(n);for(t=a.createCallback(t,e,1);++r<n;)u[r]=t(r);return u},a.toArray=function(n){return n&&typeof n.length=="number"?M(n):nt(n)
34
+ },a.union=function(){return mt(Pt.apply(Bt,arguments))},a.uniq=mt,a.values=nt,a.where=rt,a.without=function(n){for(var t=-1,e=n?n.length:0,r=$(arguments,1,30),u=[];++t<e;){var a=n[t];r(a)||u.push(a)}return u},a.wrap=function(n,t){return function(){var e=[n];return Vt.apply(e,arguments),t.apply(this,e)}},a.zip=function(n){for(var t=-1,e=n?it(ft(arguments,"length")):0,r=Ct(e);++t<e;)r[t]=ft(arguments,t);return r},a.zipObject=bt,a.collect=ot,a.drop=ht,a.each=at,a.extend=ce,a.methods=H,a.object=bt,a.select=rt,a.tail=ht,a.unique=mt,wt(a),a.clone=G,a.cloneDeep=function(n,t,e){return G(n,!0,t,e)
35
+ },a.contains=tt,a.escape=function(n){return null==n?"":$t(n).replace(m,D)},a.every=et,a.find=ut,a.findIndex=function(n,t,e){var r=-1,u=n?n.length:0;for(t=a.createCallback(t,e);++r<u;)if(t(n[r],r,n))return r;return-1},a.findKey=function(n,t,e){var r;return t=a.createCallback(t,e),se(n,function(n,e,u){return t(n,e,u)?(r=e,!1):void 0}),r},a.has=function(n,t){return n?Ut.call(n,t):!1},a.identity=kt,a.indexOf=gt,a.isArguments=V,a.isArray=ae,a.isBoolean=function(n){return!0===n||!1===n||Jt.call(n)==w},a.isDate=function(n){return n instanceof Ot||Jt.call(n)==j
36
+ },a.isElement=function(n){return n?1===n.nodeType:!1},a.isEmpty=function(n){var t=!0;if(!n)return t;var e=Jt.call(n),r=n.length;return e==k||e==N||e==_||e==x&&typeof r=="number"&&Q(n.splice)?!r:(se(n,function(){return t=!1}),t)},a.isEqual=L,a.isFinite=function(n){return Wt(n)&&!Xt(parseFloat(n))},a.isFunction=Q,a.isNaN=function(n){return X(n)&&n!=+n},a.isNull=function(n){return null===n},a.isNumber=X,a.isObject=W,a.isPlainObject=ve,a.isRegExp=function(n){return n instanceof At||Jt.call(n)==O},a.isString=Y,a.isUndefined=function(n){return typeof n=="undefined"
37
+ },a.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?Zt(0,r+e):ne(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},a.mixin=wt,a.noConflict=function(){return r._=Rt,this},a.parseInt=Gt,a.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Kt(ee()*((+t||0)-n+1))},a.reduce=ct,a.reduceRight=lt,a.result=function(n,t){var r=n?n[t]:e;return Q(r)?n[t]():r},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:oe(n).length
38
+ },a.some=pt,a.sortedIndex=yt,a.template=function(n,t,r){var u=a.templateSettings;n||(n=""),r=le({},r,u);var o,i=le({},r.imports,u.imports),u=oe(i),i=nt(i),p=0,v=r.interpolate||y,h="__p+='",v=At((r.escape||y).source+"|"+v.source+"|"+(v===g?s:y).source+"|"+(r.evaluate||y).source+"|$","g");n.replace(v,function(t,e,r,u,a,i){return r||(r=u),h+=n.slice(p,i).replace(b,T),e&&(h+="'+__e("+e+")+'"),a&&(o=!0,h+="';"+a+";__p+='"),r&&(h+="'+((__t=("+r+"))==null?'':__t)+'"),p=i+t.length,t}),h+="';\n",v=r=r.variable,v||(r="obj",h="with("+r+"){"+h+"}"),h=(o?h.replace(f,""):h).replace(c,"$1").replace(l,"$1;"),h="function("+r+"){"+(v?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+h+"return __p}";
39
+ try{var m=Nt(u,"return "+h).apply(e,i)}catch(d){throw d.source=h,d}return t?m(t):(m.source=h,m)},a.unescape=function(n){return null==n?"":$t(n).replace(p,U)},a.uniqueId=function(n){var t=++o;return $t(null==n?"":n)+t},a.all=et,a.any=pt,a.detect=ut,a.foldl=ct,a.foldr=lt,a.include=tt,a.inject=ct,se(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Vt.apply(t,arguments),n.apply(a,t)})}),a.first=st,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;
40
+ for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[u-1];return M(n,Zt(0,u-r))}},a.take=st,a.head=st,se(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return null==t||e&&typeof t!="function"?r:new z(r)})}),a.VERSION="1.1.0",a.prototype.toString=function(){return $t(this.__wrapped__)},a.prototype.value=jt,a.prototype.valueOf=jt,at(["join","pop","shift"],function(n){var t=Bt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)
41
+ }}),at(["push","reverse","sort","unshift"],function(n){var t=Bt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),at(["concat","slice","splice"],function(n){var t=Bt[n];a.prototype[n]=function(){return new z(t.apply(this.__wrapped__,arguments))}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global;a.global===a&&(n=a);var o=0,i={},f=/\b__p\+='';/g,c=/\b(__p\+=)''\+/g,l=/(__e\(.*?\)|\b__t\))\+'';/g,p=/&(?:amp|lt|gt|quot|#39);/g,s=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,v=/\w*$/,g=/<%=([\s\S]+?)%>/g,h=/^0+(?=.$)/,y=/($^)/,m=/[&<>"']/g,b=/['\n\r\t\u2028\u2029\\]/g,d="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),_="[object Arguments]",k="[object Array]",w="[object Boolean]",j="[object Date]",C="[object Number]",x="[object Object]",O="[object RegExp]",N="[object String]",E={"[object Function]":!1};
42
+ E[_]=E[k]=E[w]=E[j]=E[C]=E[x]=E[O]=E[N]=!0;var I={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},S={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},A=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=A,define(function(){return A})):r&&!r.nodeType?u?(u.exports=A)._=A:r._=A:n._=A})(this);
@@ -0,0 +1,4357 @@
1
+ /**
2
+ * @license
3
+ * Lo-Dash 1.1.0 (Custom Build) <http://lodash.com/>
4
+ * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js`
5
+ * Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
6
+ * Based on Underscore.js 1.4.4 <http://underscorejs.org/>
7
+ * Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud Inc.
8
+ * Available under MIT license <http://lodash.com/license>
9
+ */
10
+ ;(function(window) {
11
+
12
+ /** Used as a safe reference for `undefined` in pre ES5 environments */
13
+ var undefined;
14
+
15
+ /** Detect free variable `exports` */
16
+ var freeExports = typeof exports == 'object' && exports;
17
+
18
+ /** Detect free variable `module` */
19
+ var freeModule = typeof module == 'object' && module && module.exports == freeExports && module;
20
+
21
+ /** Detect free variable `global` and use it as `window` */
22
+ var freeGlobal = typeof global == 'object' && global;
23
+ if (freeGlobal.global === freeGlobal) {
24
+ window = freeGlobal;
25
+ }
26
+
27
+ /** Used to generate unique IDs */
28
+ var idCounter = 0;
29
+
30
+ /** Used internally to indicate various things */
31
+ var indicatorObject = {};
32
+
33
+ /** Used to match empty string literals in compiled template source */
34
+ var reEmptyStringLeading = /\b__p \+= '';/g,
35
+ reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
36
+ reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
37
+
38
+ /** Used to match HTML entities */
39
+ var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g;
40
+
41
+ /**
42
+ * Used to match ES6 template delimiters
43
+ * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6
44
+ */
45
+ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
46
+
47
+ /** Used to match regexp flags from their coerced string values */
48
+ var reFlags = /\w*$/;
49
+
50
+ /** Used to match "interpolate" template delimiters */
51
+ var reInterpolate = /<%=([\s\S]+?)%>/g;
52
+
53
+ /** Used to ensure capturing order of template delimiters */
54
+ var reNoMatch = /($^)/;
55
+
56
+ /** Used to match HTML characters */
57
+ var reUnescapedHtml = /[&<>"']/g;
58
+
59
+ /** Used to match unescaped characters in compiled string literals */
60
+ var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g;
61
+
62
+ /** Used to make template sourceURLs easier to identify */
63
+ var templateCounter = 0;
64
+
65
+ /** `Object#toString` result shortcuts */
66
+ var argsClass = '[object Arguments]',
67
+ arrayClass = '[object Array]',
68
+ boolClass = '[object Boolean]',
69
+ dateClass = '[object Date]',
70
+ funcClass = '[object Function]',
71
+ numberClass = '[object Number]',
72
+ objectClass = '[object Object]',
73
+ regexpClass = '[object RegExp]',
74
+ stringClass = '[object String]';
75
+
76
+ /** Used to determine if values are of the language type Object */
77
+ var objectTypes = {
78
+ 'boolean': false,
79
+ 'function': true,
80
+ 'object': true,
81
+ 'number': false,
82
+ 'string': false,
83
+ 'undefined': false
84
+ };
85
+
86
+ /** Used to escape characters for inclusion in compiled string literals */
87
+ var stringEscapes = {
88
+ '\\': '\\',
89
+ "'": "'",
90
+ '\n': 'n',
91
+ '\r': 'r',
92
+ '\t': 't',
93
+ '\u2028': 'u2028',
94
+ '\u2029': 'u2029'
95
+ };
96
+
97
+ /*--------------------------------------------------------------------------*/
98
+
99
+ /** Used for `Array` and `Object` method references */
100
+ var arrayRef = Array(),
101
+ objectRef = Object();
102
+
103
+ /** Used to restore the original `_` reference in `noConflict` */
104
+ var oldDash = window._;
105
+
106
+ /** Used to detect if a method is native */
107
+ var reNative = RegExp('^' +
108
+ String(objectRef.valueOf)
109
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
110
+ .replace(/valueOf|for [^\]]+/g, '.+?') + '$'
111
+ );
112
+
113
+ /** Native method shortcuts */
114
+ var ceil = Math.ceil,
115
+ clearTimeout = window.clearTimeout,
116
+ concat = arrayRef.concat,
117
+ floor = Math.floor,
118
+ hasOwnProperty = objectRef.hasOwnProperty,
119
+ push = arrayRef.push,
120
+ setTimeout = window.setTimeout,
121
+ slice = arrayRef.slice,
122
+ toString = objectRef.toString;
123
+
124
+ /* Native method shortcuts for methods with the same name as other `lodash` methods */
125
+ var nativeBind = reNative.test(nativeBind = slice.bind) && nativeBind,
126
+ nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
127
+ nativeIsFinite = window.isFinite,
128
+ nativeIsNaN = window.isNaN,
129
+ nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys,
130
+ nativeMax = Math.max,
131
+ nativeMin = Math.min,
132
+ nativeRandom = Math.random;
133
+
134
+ /** Detect various environments */
135
+ var isIeOpera = reNative.test(window.attachEvent),
136
+ isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera);
137
+
138
+ /*--------------------------------------------------------------------------*/
139
+
140
+ /**
141
+ * Creates a `lodash` object, that wraps the given `value`, to enable method
142
+ * chaining.
143
+ *
144
+ * In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
145
+ * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
146
+ * and `unshift`
147
+ *
148
+ * Chaining is supported in custom builds as long as the `value` method is
149
+ * implicitly or explicitly included in the build.
150
+ *
151
+ * The chainable wrapper functions are:
152
+ * `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`,
153
+ * `compose`, `concat`, `countBy`, `createCallback`, `debounce`, `defaults`,
154
+ * `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`,
155
+ * `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`,
156
+ * `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
157
+ * `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`,
158
+ * `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`,
159
+ * `tap`, `throttle`, `times`, `toArray`, `union`, `uniq`, `unshift`, `values`,
160
+ * `where`, `without`, `wrap`, and `zip`
161
+ *
162
+ * The non-chainable wrapper functions are:
163
+ * `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`,
164
+ * `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`,
165
+ * `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`,
166
+ * `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`,
167
+ * `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`,
168
+ * `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`,
169
+ * `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value`
170
+ *
171
+ * The wrapper functions `first` and `last` return wrapped values when `n` is
172
+ * passed, otherwise they return unwrapped values.
173
+ *
174
+ * @name _
175
+ * @constructor
176
+ * @category Chaining
177
+ * @param {Mixed} value The value to wrap in a `lodash` instance.
178
+ * @returns {Object} Returns a `lodash` instance.
179
+ */
180
+ function lodash(value) {
181
+ return (value instanceof lodash)
182
+ ? value
183
+ : new lodashWrapper(value);
184
+ }
185
+
186
+ /**
187
+ * An object used to flag environments features.
188
+ *
189
+ * @static
190
+ * @memberOf _
191
+ * @type Object
192
+ */
193
+ var support = {};
194
+
195
+ (function() {
196
+ var object = { '0': 1, 'length': 1 };
197
+
198
+ /**
199
+ * Detect if `arguments` objects are `Object` objects (all but Opera < 10.5).
200
+ *
201
+ * @memberOf _.support
202
+ * @type Boolean
203
+ */
204
+ support.argsObject = arguments.constructor == Object;
205
+
206
+ /**
207
+ * Detect if `Function#bind` exists and is inferred to be fast (all but V8).
208
+ *
209
+ * @memberOf _.support
210
+ * @type Boolean
211
+ */
212
+ support.fastBind = nativeBind && !isV8;
213
+
214
+ /**
215
+ * Detect if `Array#shift` and `Array#splice` augment array-like objects correctly.
216
+ *
217
+ * Firefox < 10, IE compatibility mode, and IE < 9 have buggy Array `shift()`
218
+ * and `splice()` functions that fail to remove the last element, `value[0]`,
219
+ * of array-like objects even though the `length` property is set to `0`.
220
+ * The `shift()` method is buggy in IE 8 compatibility mode, while `splice()`
221
+ * is buggy regardless of mode in IE < 9 and buggy in compatibility mode in IE 9.
222
+ *
223
+ * @memberOf _.support
224
+ * @type Boolean
225
+ */
226
+ support.spliceObjects = (arrayRef.splice.call(object, 0, 1), !object[0]);
227
+ }(1));
228
+
229
+ /**
230
+ * By default, the template delimiters used by Lo-Dash are similar to those in
231
+ * embedded Ruby (ERB). Change the following template settings to use alternative
232
+ * delimiters.
233
+ *
234
+ * @static
235
+ * @memberOf _
236
+ * @type Object
237
+ */
238
+ lodash.templateSettings = {
239
+
240
+ /**
241
+ * Used to detect `data` property values to be HTML-escaped.
242
+ *
243
+ * @memberOf _.templateSettings
244
+ * @type RegExp
245
+ */
246
+ 'escape': /<%-([\s\S]+?)%>/g,
247
+
248
+ /**
249
+ * Used to detect code to be evaluated.
250
+ *
251
+ * @memberOf _.templateSettings
252
+ * @type RegExp
253
+ */
254
+ 'evaluate': /<%([\s\S]+?)%>/g,
255
+
256
+ /**
257
+ * Used to detect `data` property values to inject.
258
+ *
259
+ * @memberOf _.templateSettings
260
+ * @type RegExp
261
+ */
262
+ 'interpolate': reInterpolate,
263
+
264
+ /**
265
+ * Used to reference the data object in the template text.
266
+ *
267
+ * @memberOf _.templateSettings
268
+ * @type String
269
+ */
270
+ 'variable': ''
271
+ };
272
+
273
+ /*--------------------------------------------------------------------------*/
274
+
275
+ /**
276
+ * Used by `_.max` and `_.min` as the default `callback` when a given
277
+ * `collection` is a string value.
278
+ *
279
+ * @private
280
+ * @param {String} value The character to inspect.
281
+ * @returns {Number} Returns the code unit of given character.
282
+ */
283
+ function charAtCallback(value) {
284
+ return value.charCodeAt(0);
285
+ }
286
+
287
+ /**
288
+ * Used by `sortBy` to compare transformed `collection` values, stable sorting
289
+ * them in ascending order.
290
+ *
291
+ * @private
292
+ * @param {Object} a The object to compare to `b`.
293
+ * @param {Object} b The object to compare to `a`.
294
+ * @returns {Number} Returns the sort order indicator of `1` or `-1`.
295
+ */
296
+ function compareAscending(a, b) {
297
+ var ai = a.index,
298
+ bi = b.index;
299
+
300
+ a = a.criteria;
301
+ b = b.criteria;
302
+
303
+ // ensure a stable sort in V8 and other engines
304
+ // http://code.google.com/p/v8/issues/detail?id=90
305
+ if (a !== b) {
306
+ if (a > b || typeof a == 'undefined') {
307
+ return 1;
308
+ }
309
+ if (a < b || typeof b == 'undefined') {
310
+ return -1;
311
+ }
312
+ }
313
+ return ai < bi ? -1 : 1;
314
+ }
315
+
316
+ /**
317
+ * Creates a function that, when called, invokes `func` with the `this` binding
318
+ * of `thisArg` and prepends any `partialArgs` to the arguments passed to the
319
+ * bound function.
320
+ *
321
+ * @private
322
+ * @param {Function|String} func The function to bind or the method name.
323
+ * @param {Mixed} [thisArg] The `this` binding of `func`.
324
+ * @param {Array} partialArgs An array of arguments to be partially applied.
325
+ * @param {Object} [idicator] Used to indicate binding by key or partially
326
+ * applying arguments from the right.
327
+ * @returns {Function} Returns the new bound function.
328
+ */
329
+ function createBound(func, thisArg, partialArgs, indicator) {
330
+ var isFunc = isFunction(func),
331
+ isPartial = !partialArgs,
332
+ key = thisArg;
333
+
334
+ // juggle arguments
335
+ if (isPartial) {
336
+ var rightIndicator = indicator;
337
+ partialArgs = thisArg;
338
+ }
339
+ else if (!isFunc) {
340
+ if (!indicator) {
341
+ throw new TypeError;
342
+ }
343
+ thisArg = func;
344
+ }
345
+
346
+ function bound() {
347
+ // `Function#bind` spec
348
+ // http://es5.github.com/#x15.3.4.5
349
+ var args = arguments,
350
+ thisBinding = isPartial ? this : thisArg;
351
+
352
+ if (!isFunc) {
353
+ func = thisArg[key];
354
+ }
355
+ if (partialArgs.length) {
356
+ args = args.length
357
+ ? (args = slice.call(args), rightIndicator ? args.concat(partialArgs) : partialArgs.concat(args))
358
+ : partialArgs;
359
+ }
360
+ if (this instanceof bound) {
361
+ // ensure `new bound` is an instance of `func`
362
+ noop.prototype = func.prototype;
363
+ thisBinding = new noop;
364
+ noop.prototype = null;
365
+
366
+ // mimic the constructor's `return` behavior
367
+ // http://es5.github.com/#x13.2.2
368
+ var result = func.apply(thisBinding, args);
369
+ return isObject(result) ? result : thisBinding;
370
+ }
371
+ return func.apply(thisBinding, args);
372
+ }
373
+ return bound;
374
+ }
375
+
376
+ /**
377
+ * Used by `template` to escape characters for inclusion in compiled
378
+ * string literals.
379
+ *
380
+ * @private
381
+ * @param {String} match The matched character to escape.
382
+ * @returns {String} Returns the escaped character.
383
+ */
384
+ function escapeStringChar(match) {
385
+ return '\\' + stringEscapes[match];
386
+ }
387
+
388
+ /**
389
+ * Used by `escape` to convert characters to HTML entities.
390
+ *
391
+ * @private
392
+ * @param {String} match The matched character to escape.
393
+ * @returns {String} Returns the escaped character.
394
+ */
395
+ function escapeHtmlChar(match) {
396
+ return htmlEscapes[match];
397
+ }
398
+
399
+ /**
400
+ * A fast path for creating `lodash` wrapper objects.
401
+ *
402
+ * @private
403
+ * @param {Mixed} value The value to wrap in a `lodash` instance.
404
+ * @returns {Object} Returns a `lodash` instance.
405
+ */
406
+ function lodashWrapper(value) {
407
+ this.__wrapped__ = value;
408
+ }
409
+ // ensure `new lodashWrapper` is an instance of `lodash`
410
+ lodashWrapper.prototype = lodash.prototype;
411
+
412
+ /**
413
+ * A no-operation function.
414
+ *
415
+ * @private
416
+ */
417
+ function noop() {
418
+ // no operation performed
419
+ }
420
+
421
+ /**
422
+ * Used by `unescape` to convert HTML entities to characters.
423
+ *
424
+ * @private
425
+ * @param {String} match The matched character to unescape.
426
+ * @returns {String} Returns the unescaped character.
427
+ */
428
+ function unescapeHtmlChar(match) {
429
+ return htmlUnescapes[match];
430
+ }
431
+
432
+ /*--------------------------------------------------------------------------*/
433
+
434
+ /**
435
+ * Checks if `value` is an `arguments` object.
436
+ *
437
+ * @static
438
+ * @memberOf _
439
+ * @category Objects
440
+ * @param {Mixed} value The value to check.
441
+ * @returns {Boolean} Returns `true`, if the `value` is an `arguments` object, else `false`.
442
+ * @example
443
+ *
444
+ * (function() { return _.isArguments(arguments); })(1, 2, 3);
445
+ * // => true
446
+ *
447
+ * _.isArguments([1, 2, 3]);
448
+ * // => false
449
+ */
450
+ function isArguments(value) {
451
+ return toString.call(value) == argsClass;
452
+ }
453
+ // fallback for browsers that can't detect `arguments` objects by [[Class]]
454
+ if (!isArguments(arguments)) {
455
+ isArguments = function(value) {
456
+ return value ? hasOwnProperty.call(value, 'callee') : false;
457
+ };
458
+ }
459
+
460
+ /**
461
+ * Checks if `value` is an array.
462
+ *
463
+ * @static
464
+ * @memberOf _
465
+ * @category Objects
466
+ * @param {Mixed} value The value to check.
467
+ * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`.
468
+ * @example
469
+ *
470
+ * (function() { return _.isArray(arguments); })();
471
+ * // => false
472
+ *
473
+ * _.isArray([1, 2, 3]);
474
+ * // => true
475
+ */
476
+ var isArray = nativeIsArray || function(value) {
477
+ // `instanceof` may cause a memory leak in IE 7 if `value` is a host object
478
+ // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
479
+ return (support.argsObject && value instanceof Array) || toString.call(value) == arrayClass;
480
+ };
481
+
482
+ /**
483
+ * A fallback implementation of `Object.keys` that produces an array of the
484
+ * given object's own enumerable property names.
485
+ *
486
+ * @private
487
+ * @type Function
488
+ * @param {Object} object The object to inspect.
489
+ * @returns {Array} Returns a new array of property names.
490
+ */
491
+ var shimKeys = function (object) {
492
+ var index, iterable = object, result = [];
493
+ if (!iterable) return result;
494
+ if (!(objectTypes[typeof object])) return result;
495
+
496
+ for (index in iterable) {
497
+ if (hasOwnProperty.call(iterable, index)) {
498
+ result.push(index);
499
+ }
500
+ }
501
+ return result
502
+ };
503
+
504
+ /**
505
+ * Creates an array composed of the own enumerable property names of `object`.
506
+ *
507
+ * @static
508
+ * @memberOf _
509
+ * @category Objects
510
+ * @param {Object} object The object to inspect.
511
+ * @returns {Array} Returns a new array of property names.
512
+ * @example
513
+ *
514
+ * _.keys({ 'one': 1, 'two': 2, 'three': 3 });
515
+ * // => ['one', 'two', 'three'] (order is not guaranteed)
516
+ */
517
+ var keys = !nativeKeys ? shimKeys : function(object) {
518
+ if (!isObject(object)) {
519
+ return [];
520
+ }
521
+ return nativeKeys(object);
522
+ };
523
+
524
+ /**
525
+ * Used to convert characters to HTML entities:
526
+ *
527
+ * Though the `>` character is escaped for symmetry, characters like `>` and `/`
528
+ * don't require escaping in HTML and have no special meaning unless they're part
529
+ * of a tag or an unquoted attribute value.
530
+ * http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact")
531
+ */
532
+ var htmlEscapes = {
533
+ '&': '&amp;',
534
+ '<': '&lt;',
535
+ '>': '&gt;',
536
+ '"': '&quot;',
537
+ "'": '&#39;'
538
+ };
539
+
540
+ /** Used to convert HTML entities to characters */
541
+ var htmlUnescapes = invert(htmlEscapes);
542
+
543
+ /*--------------------------------------------------------------------------*/
544
+
545
+ /**
546
+ * Assigns own enumerable properties of source object(s) to the destination
547
+ * object. Subsequent sources will overwrite property assignments of previous
548
+ * sources. If a `callback` function is passed, it will be executed to produce
549
+ * the assigned values. The `callback` is bound to `thisArg` and invoked with
550
+ * two arguments; (objectValue, sourceValue).
551
+ *
552
+ * @static
553
+ * @memberOf _
554
+ * @type Function
555
+ * @alias extend
556
+ * @category Objects
557
+ * @param {Object} object The destination object.
558
+ * @param {Object} [source1, source2, ...] The source objects.
559
+ * @param {Function} [callback] The function to customize assigning values.
560
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
561
+ * @returns {Object} Returns the destination object.
562
+ * @example
563
+ *
564
+ * _.assign({ 'name': 'moe' }, { 'age': 40 });
565
+ * // => { 'name': 'moe', 'age': 40 }
566
+ *
567
+ * var defaults = _.partialRight(_.assign, function(a, b) {
568
+ * return typeof a == 'undefined' ? b : a;
569
+ * });
570
+ *
571
+ * var food = { 'name': 'apple' };
572
+ * defaults(food, { 'name': 'banana', 'type': 'fruit' });
573
+ * // => { 'name': 'apple', 'type': 'fruit' }
574
+ */
575
+ function assign(object) {
576
+ if (!object) {
577
+ return object;
578
+ }
579
+ for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {
580
+ var iterable = arguments[argsIndex];
581
+ if (iterable) {
582
+ for (var key in iterable) {
583
+ object[key] = iterable[key];
584
+ }
585
+ }
586
+ }
587
+ return object;
588
+ }
589
+
590
+ /**
591
+ * Creates a clone of `value`. If `deep` is `true`, nested objects will also
592
+ * be cloned, otherwise they will be assigned by reference. If a `callback`
593
+ * function is passed, it will be executed to produce the cloned values. If
594
+ * `callback` returns `undefined`, cloning will be handled by the method instead.
595
+ * The `callback` is bound to `thisArg` and invoked with one argument; (value).
596
+ *
597
+ * @static
598
+ * @memberOf _
599
+ * @category Objects
600
+ * @param {Mixed} value The value to clone.
601
+ * @param {Boolean} [deep=false] A flag to indicate a deep clone.
602
+ * @param {Function} [callback] The function to customize cloning values.
603
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
604
+ * @param- {Array} [stackA=[]] Tracks traversed source objects.
605
+ * @param- {Array} [stackB=[]] Associates clones with source counterparts.
606
+ * @returns {Mixed} Returns the cloned `value`.
607
+ * @example
608
+ *
609
+ * var stooges = [
610
+ * { 'name': 'moe', 'age': 40 },
611
+ * { 'name': 'larry', 'age': 50 }
612
+ * ];
613
+ *
614
+ * var shallow = _.clone(stooges);
615
+ * shallow[0] === stooges[0];
616
+ * // => true
617
+ *
618
+ * var deep = _.clone(stooges, true);
619
+ * deep[0] === stooges[0];
620
+ * // => false
621
+ *
622
+ * _.mixin({
623
+ * 'clone': _.partialRight(_.clone, function(value) {
624
+ * return _.isElement(value) ? value.cloneNode(false) : undefined;
625
+ * })
626
+ * });
627
+ *
628
+ * var clone = _.clone(document.body);
629
+ * clone.childNodes.length;
630
+ * // => 0
631
+ */
632
+ function clone(value) {
633
+ return isObject(value)
634
+ ? (isArray(value) ? slice.call(value) : assign({}, value))
635
+ : value;
636
+ }
637
+
638
+ /**
639
+ * Assigns own enumerable properties of source object(s) to the destination
640
+ * object for all destination properties that resolve to `undefined`. Once a
641
+ * property is set, additional defaults of the same property will be ignored.
642
+ *
643
+ * @static
644
+ * @memberOf _
645
+ * @type Function
646
+ * @category Objects
647
+ * @param {Object} object The destination object.
648
+ * @param {Object} [source1, source2, ...] The source objects.
649
+ * @param- {Object} [guard] Allows working with `_.reduce` without using its
650
+ * callback's `key` and `object` arguments as sources.
651
+ * @returns {Object} Returns the destination object.
652
+ * @example
653
+ *
654
+ * var food = { 'name': 'apple' };
655
+ * _.defaults(food, { 'name': 'banana', 'type': 'fruit' });
656
+ * // => { 'name': 'apple', 'type': 'fruit' }
657
+ */
658
+ function defaults(object) {
659
+ if (!object) {
660
+ return object;
661
+ }
662
+ for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) {
663
+ var iterable = arguments[argsIndex];
664
+ if (iterable) {
665
+ for (var key in iterable) {
666
+ if (object[key] == null) {
667
+ object[key] = iterable[key];
668
+ }
669
+ }
670
+ }
671
+ }
672
+ return object;
673
+ }
674
+
675
+ /**
676
+ * Iterates over `object`'s own and inherited enumerable properties, executing
677
+ * the `callback` for each property. The `callback` is bound to `thisArg` and
678
+ * invoked with three arguments; (value, key, object). Callbacks may exit iteration
679
+ * early by explicitly returning `false`.
680
+ *
681
+ * @static
682
+ * @memberOf _
683
+ * @type Function
684
+ * @category Objects
685
+ * @param {Object} object The object to iterate over.
686
+ * @param {Function} [callback=identity] The function called per iteration.
687
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
688
+ * @returns {Object} Returns `object`.
689
+ * @example
690
+ *
691
+ * function Dog(name) {
692
+ * this.name = name;
693
+ * }
694
+ *
695
+ * Dog.prototype.bark = function() {
696
+ * alert('Woof, woof!');
697
+ * };
698
+ *
699
+ * _.forIn(new Dog('Dagny'), function(value, key) {
700
+ * alert(key);
701
+ * });
702
+ * // => alerts 'name' and 'bark' (order is not guaranteed)
703
+ */
704
+ var forIn = function (collection, callback) {
705
+ var index, iterable = collection, result = iterable;
706
+ if (!iterable) return result;
707
+ if (!objectTypes[typeof iterable]) return result;
708
+ callback || (callback = identity);
709
+
710
+ for (index in iterable) {
711
+ if (callback(iterable[index], index, collection) === indicatorObject) return result;
712
+ }
713
+ return result
714
+ };
715
+
716
+ /**
717
+ * Iterates over an object's own enumerable properties, executing the `callback`
718
+ * for each property. The `callback` is bound to `thisArg` and invoked with three
719
+ * arguments; (value, key, object). Callbacks may exit iteration early by explicitly
720
+ * returning `false`.
721
+ *
722
+ * @static
723
+ * @memberOf _
724
+ * @type Function
725
+ * @category Objects
726
+ * @param {Object} object The object to iterate over.
727
+ * @param {Function} [callback=identity] The function called per iteration.
728
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
729
+ * @returns {Object} Returns `object`.
730
+ * @example
731
+ *
732
+ * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
733
+ * alert(key);
734
+ * });
735
+ * // => alerts '0', '1', and 'length' (order is not guaranteed)
736
+ */
737
+ var forOwn = function (collection, callback) {
738
+ var index, iterable = collection, result = iterable;
739
+ if (!iterable) return result;
740
+ if (!objectTypes[typeof iterable]) return result;
741
+ callback || (callback = identity);
742
+
743
+ for (index in iterable) {
744
+ if (hasOwnProperty.call(iterable, index)) {
745
+ if (callback(iterable[index], index, collection) === indicatorObject) return result;
746
+ }
747
+ }
748
+ return result
749
+ };
750
+
751
+ /**
752
+ * Creates a sorted array of all enumerable properties, own and inherited,
753
+ * of `object` that have function values.
754
+ *
755
+ * @static
756
+ * @memberOf _
757
+ * @alias methods
758
+ * @category Objects
759
+ * @param {Object} object The object to inspect.
760
+ * @returns {Array} Returns a new array of property names that have function values.
761
+ * @example
762
+ *
763
+ * _.functions(_);
764
+ * // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...]
765
+ */
766
+ function functions(object) {
767
+ var result = [];
768
+ forIn(object, function(value, key) {
769
+ if (isFunction(value)) {
770
+ result.push(key);
771
+ }
772
+ });
773
+ return result.sort();
774
+ }
775
+
776
+ /**
777
+ * Checks if the specified object `property` exists and is a direct property,
778
+ * instead of an inherited property.
779
+ *
780
+ * @static
781
+ * @memberOf _
782
+ * @category Objects
783
+ * @param {Object} object The object to check.
784
+ * @param {String} property The property to check for.
785
+ * @returns {Boolean} Returns `true` if key is a direct property, else `false`.
786
+ * @example
787
+ *
788
+ * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
789
+ * // => true
790
+ */
791
+ function has(object, property) {
792
+ return object ? hasOwnProperty.call(object, property) : false;
793
+ }
794
+
795
+ /**
796
+ * Creates an object composed of the inverted keys and values of the given `object`.
797
+ *
798
+ * @static
799
+ * @memberOf _
800
+ * @category Objects
801
+ * @param {Object} object The object to invert.
802
+ * @returns {Object} Returns the created inverted object.
803
+ * @example
804
+ *
805
+ * _.invert({ 'first': 'moe', 'second': 'larry' });
806
+ * // => { 'moe': 'first', 'larry': 'second' }
807
+ */
808
+ function invert(object) {
809
+ var index = -1,
810
+ props = keys(object),
811
+ length = props.length,
812
+ result = {};
813
+
814
+ while (++index < length) {
815
+ var key = props[index];
816
+ result[object[key]] = key;
817
+ }
818
+ return result;
819
+ }
820
+
821
+ /**
822
+ * Checks if `value` is a boolean value.
823
+ *
824
+ * @static
825
+ * @memberOf _
826
+ * @category Objects
827
+ * @param {Mixed} value The value to check.
828
+ * @returns {Boolean} Returns `true`, if the `value` is a boolean value, else `false`.
829
+ * @example
830
+ *
831
+ * _.isBoolean(null);
832
+ * // => false
833
+ */
834
+ function isBoolean(value) {
835
+ return value === true || value === false || toString.call(value) == boolClass;
836
+ }
837
+
838
+ /**
839
+ * Checks if `value` is a date.
840
+ *
841
+ * @static
842
+ * @memberOf _
843
+ * @category Objects
844
+ * @param {Mixed} value The value to check.
845
+ * @returns {Boolean} Returns `true`, if the `value` is a date, else `false`.
846
+ * @example
847
+ *
848
+ * _.isDate(new Date);
849
+ * // => true
850
+ */
851
+ function isDate(value) {
852
+ return value instanceof Date || toString.call(value) == dateClass;
853
+ }
854
+
855
+ /**
856
+ * Checks if `value` is a DOM element.
857
+ *
858
+ * @static
859
+ * @memberOf _
860
+ * @category Objects
861
+ * @param {Mixed} value The value to check.
862
+ * @returns {Boolean} Returns `true`, if the `value` is a DOM element, else `false`.
863
+ * @example
864
+ *
865
+ * _.isElement(document.body);
866
+ * // => true
867
+ */
868
+ function isElement(value) {
869
+ return value ? value.nodeType === 1 : false;
870
+ }
871
+
872
+ /**
873
+ * Checks if `value` is empty. Arrays, strings, or `arguments` objects with a
874
+ * length of `0` and objects with no own enumerable properties are considered
875
+ * "empty".
876
+ *
877
+ * @static
878
+ * @memberOf _
879
+ * @category Objects
880
+ * @param {Array|Object|String} value The value to inspect.
881
+ * @returns {Boolean} Returns `true`, if the `value` is empty, else `false`.
882
+ * @example
883
+ *
884
+ * _.isEmpty([1, 2, 3]);
885
+ * // => false
886
+ *
887
+ * _.isEmpty({});
888
+ * // => true
889
+ *
890
+ * _.isEmpty('');
891
+ * // => true
892
+ */
893
+ function isEmpty(value) {
894
+ if (!value) {
895
+ return true;
896
+ }
897
+ if (isArray(value) || isString(value)) {
898
+ return !value.length;
899
+ }
900
+ for (var key in value) {
901
+ if (hasOwnProperty.call(value, key)) {
902
+ return false;
903
+ }
904
+ }
905
+ return true;
906
+ }
907
+
908
+ /**
909
+ * Performs a deep comparison between two values to determine if they are
910
+ * equivalent to each other. If `callback` is passed, it will be executed to
911
+ * compare values. If `callback` returns `undefined`, comparisons will be handled
912
+ * by the method instead. The `callback` is bound to `thisArg` and invoked with
913
+ * two arguments; (a, b).
914
+ *
915
+ * @static
916
+ * @memberOf _
917
+ * @category Objects
918
+ * @param {Mixed} a The value to compare.
919
+ * @param {Mixed} b The other value to compare.
920
+ * @param {Function} [callback] The function to customize comparing values.
921
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
922
+ * @param- {Array} [stackA=[]] Tracks traversed `a` objects.
923
+ * @param- {Array} [stackB=[]] Tracks traversed `b` objects.
924
+ * @returns {Boolean} Returns `true`, if the values are equivalent, else `false`.
925
+ * @example
926
+ *
927
+ * var moe = { 'name': 'moe', 'age': 40 };
928
+ * var copy = { 'name': 'moe', 'age': 40 };
929
+ *
930
+ * moe == copy;
931
+ * // => false
932
+ *
933
+ * _.isEqual(moe, copy);
934
+ * // => true
935
+ *
936
+ * var words = ['hello', 'goodbye'];
937
+ * var otherWords = ['hi', 'goodbye'];
938
+ *
939
+ * _.isEqual(words, otherWords, function(a, b) {
940
+ * var reGreet = /^(?:hello|hi)$/i,
941
+ * aGreet = _.isString(a) && reGreet.test(a),
942
+ * bGreet = _.isString(b) && reGreet.test(b);
943
+ *
944
+ * return (aGreet || bGreet) ? (aGreet == bGreet) : undefined;
945
+ * });
946
+ * // => true
947
+ */
948
+ function isEqual(a, b, stackA, stackB) {
949
+ if (a === b) {
950
+ return a !== 0 || (1 / a == 1 / b);
951
+ }
952
+ var type = typeof a,
953
+ otherType = typeof b;
954
+
955
+ if (a === a &&
956
+ (!a || (type != 'function' && type != 'object')) &&
957
+ (!b || (otherType != 'function' && otherType != 'object'))) {
958
+ return false;
959
+ }
960
+ if (a == null || b == null) {
961
+ return a === b;
962
+ }
963
+ var className = toString.call(a),
964
+ otherClass = toString.call(b);
965
+
966
+ if (className != otherClass) {
967
+ return false;
968
+ }
969
+ switch (className) {
970
+ case boolClass:
971
+ case dateClass:
972
+ return +a == +b;
973
+
974
+ case numberClass:
975
+ return a != +a
976
+ ? b != +b
977
+ : (a == 0 ? (1 / a == 1 / b) : a == +b);
978
+
979
+ case regexpClass:
980
+ case stringClass:
981
+ return a == String(b);
982
+ }
983
+ var isArr = className == arrayClass;
984
+ if (!isArr) {
985
+ if (a instanceof lodash || b instanceof lodash) {
986
+ return isEqual(a.__wrapped__ || a, b.__wrapped__ || b, stackA, stackB);
987
+ }
988
+ if (className != objectClass) {
989
+ return false;
990
+ }
991
+ var ctorA = a.constructor,
992
+ ctorB = b.constructor;
993
+
994
+ if (ctorA != ctorB && !(
995
+ isFunction(ctorA) && ctorA instanceof ctorA &&
996
+ isFunction(ctorB) && ctorB instanceof ctorB
997
+ )) {
998
+ return false;
999
+ }
1000
+ }
1001
+ stackA || (stackA = []);
1002
+ stackB || (stackB = []);
1003
+
1004
+ var length = stackA.length;
1005
+ while (length--) {
1006
+ if (stackA[length] == a) {
1007
+ return stackB[length] == b;
1008
+ }
1009
+ }
1010
+ var result = true,
1011
+ size = 0;
1012
+
1013
+ stackA.push(a);
1014
+ stackB.push(b);
1015
+
1016
+ if (isArr) {
1017
+ size = b.length;
1018
+ result = size == a.length;
1019
+
1020
+ if (result) {
1021
+ while (size--) {
1022
+ if (!(result = isEqual(a[size], b[size], stackA, stackB))) {
1023
+ break;
1024
+ }
1025
+ }
1026
+ }
1027
+ return result;
1028
+ }
1029
+ forIn(b, function(value, key, b) {
1030
+ if (hasOwnProperty.call(b, key)) {
1031
+ size++;
1032
+ return !(result = hasOwnProperty.call(a, key) && isEqual(a[key], value, stackA, stackB)) && indicatorObject;
1033
+ }
1034
+ });
1035
+
1036
+ if (result) {
1037
+ forIn(a, function(value, key, a) {
1038
+ if (hasOwnProperty.call(a, key)) {
1039
+ return !(result = --size > -1) && indicatorObject;
1040
+ }
1041
+ });
1042
+ }
1043
+ return result;
1044
+ }
1045
+
1046
+ /**
1047
+ * Checks if `value` is, or can be coerced to, a finite number.
1048
+ *
1049
+ * Note: This is not the same as native `isFinite`, which will return true for
1050
+ * booleans and empty strings. See http://es5.github.com/#x15.1.2.5.
1051
+ *
1052
+ * @static
1053
+ * @memberOf _
1054
+ * @category Objects
1055
+ * @param {Mixed} value The value to check.
1056
+ * @returns {Boolean} Returns `true`, if the `value` is finite, else `false`.
1057
+ * @example
1058
+ *
1059
+ * _.isFinite(-101);
1060
+ * // => true
1061
+ *
1062
+ * _.isFinite('10');
1063
+ * // => true
1064
+ *
1065
+ * _.isFinite(true);
1066
+ * // => false
1067
+ *
1068
+ * _.isFinite('');
1069
+ * // => false
1070
+ *
1071
+ * _.isFinite(Infinity);
1072
+ * // => false
1073
+ */
1074
+ function isFinite(value) {
1075
+ return nativeIsFinite(value) && !nativeIsNaN(parseFloat(value));
1076
+ }
1077
+
1078
+ /**
1079
+ * Checks if `value` is a function.
1080
+ *
1081
+ * @static
1082
+ * @memberOf _
1083
+ * @category Objects
1084
+ * @param {Mixed} value The value to check.
1085
+ * @returns {Boolean} Returns `true`, if the `value` is a function, else `false`.
1086
+ * @example
1087
+ *
1088
+ * _.isFunction(_);
1089
+ * // => true
1090
+ */
1091
+ function isFunction(value) {
1092
+ return typeof value == 'function';
1093
+ }
1094
+ // fallback for older versions of Chrome and Safari
1095
+ if (isFunction(/x/)) {
1096
+ isFunction = function(value) {
1097
+ return value instanceof Function || toString.call(value) == funcClass;
1098
+ };
1099
+ }
1100
+
1101
+ /**
1102
+ * Checks if `value` is the language type of Object.
1103
+ * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1104
+ *
1105
+ * @static
1106
+ * @memberOf _
1107
+ * @category Objects
1108
+ * @param {Mixed} value The value to check.
1109
+ * @returns {Boolean} Returns `true`, if the `value` is an object, else `false`.
1110
+ * @example
1111
+ *
1112
+ * _.isObject({});
1113
+ * // => true
1114
+ *
1115
+ * _.isObject([1, 2, 3]);
1116
+ * // => true
1117
+ *
1118
+ * _.isObject(1);
1119
+ * // => false
1120
+ */
1121
+ function isObject(value) {
1122
+ // check if the value is the ECMAScript language type of Object
1123
+ // http://es5.github.com/#x8
1124
+ // and avoid a V8 bug
1125
+ // http://code.google.com/p/v8/issues/detail?id=2291
1126
+ return value ? objectTypes[typeof value] : false;
1127
+ }
1128
+
1129
+ /**
1130
+ * Checks if `value` is `NaN`.
1131
+ *
1132
+ * Note: This is not the same as native `isNaN`, which will return `true` for
1133
+ * `undefined` and other values. See http://es5.github.com/#x15.1.2.4.
1134
+ *
1135
+ * @static
1136
+ * @memberOf _
1137
+ * @category Objects
1138
+ * @param {Mixed} value The value to check.
1139
+ * @returns {Boolean} Returns `true`, if the `value` is `NaN`, else `false`.
1140
+ * @example
1141
+ *
1142
+ * _.isNaN(NaN);
1143
+ * // => true
1144
+ *
1145
+ * _.isNaN(new Number(NaN));
1146
+ * // => true
1147
+ *
1148
+ * isNaN(undefined);
1149
+ * // => true
1150
+ *
1151
+ * _.isNaN(undefined);
1152
+ * // => false
1153
+ */
1154
+ function isNaN(value) {
1155
+ // `NaN` as a primitive is the only value that is not equal to itself
1156
+ // (perform the [[Class]] check first to avoid errors with some host objects in IE)
1157
+ return isNumber(value) && value != +value
1158
+ }
1159
+
1160
+ /**
1161
+ * Checks if `value` is `null`.
1162
+ *
1163
+ * @static
1164
+ * @memberOf _
1165
+ * @category Objects
1166
+ * @param {Mixed} value The value to check.
1167
+ * @returns {Boolean} Returns `true`, if the `value` is `null`, else `false`.
1168
+ * @example
1169
+ *
1170
+ * _.isNull(null);
1171
+ * // => true
1172
+ *
1173
+ * _.isNull(undefined);
1174
+ * // => false
1175
+ */
1176
+ function isNull(value) {
1177
+ return value === null;
1178
+ }
1179
+
1180
+ /**
1181
+ * Checks if `value` is a number.
1182
+ *
1183
+ * @static
1184
+ * @memberOf _
1185
+ * @category Objects
1186
+ * @param {Mixed} value The value to check.
1187
+ * @returns {Boolean} Returns `true`, if the `value` is a number, else `false`.
1188
+ * @example
1189
+ *
1190
+ * _.isNumber(8.4 * 5);
1191
+ * // => true
1192
+ */
1193
+ function isNumber(value) {
1194
+ return typeof value == 'number' || toString.call(value) == numberClass;
1195
+ }
1196
+
1197
+ /**
1198
+ * Checks if `value` is a regular expression.
1199
+ *
1200
+ * @static
1201
+ * @memberOf _
1202
+ * @category Objects
1203
+ * @param {Mixed} value The value to check.
1204
+ * @returns {Boolean} Returns `true`, if the `value` is a regular expression, else `false`.
1205
+ * @example
1206
+ *
1207
+ * _.isRegExp(/moe/);
1208
+ * // => true
1209
+ */
1210
+ function isRegExp(value) {
1211
+ return value instanceof RegExp || toString.call(value) == regexpClass;
1212
+ }
1213
+
1214
+ /**
1215
+ * Checks if `value` is a string.
1216
+ *
1217
+ * @static
1218
+ * @memberOf _
1219
+ * @category Objects
1220
+ * @param {Mixed} value The value to check.
1221
+ * @returns {Boolean} Returns `true`, if the `value` is a string, else `false`.
1222
+ * @example
1223
+ *
1224
+ * _.isString('moe');
1225
+ * // => true
1226
+ */
1227
+ function isString(value) {
1228
+ return typeof value == 'string' || toString.call(value) == stringClass;
1229
+ }
1230
+
1231
+ /**
1232
+ * Checks if `value` is `undefined`.
1233
+ *
1234
+ * @static
1235
+ * @memberOf _
1236
+ * @category Objects
1237
+ * @param {Mixed} value The value to check.
1238
+ * @returns {Boolean} Returns `true`, if the `value` is `undefined`, else `false`.
1239
+ * @example
1240
+ *
1241
+ * _.isUndefined(void 0);
1242
+ * // => true
1243
+ */
1244
+ function isUndefined(value) {
1245
+ return typeof value == 'undefined';
1246
+ }
1247
+
1248
+ /**
1249
+ * Creates a shallow clone of `object` excluding the specified properties.
1250
+ * Property names may be specified as individual arguments or as arrays of
1251
+ * property names. If a `callback` function is passed, it will be executed
1252
+ * for each property in the `object`, omitting the properties `callback`
1253
+ * returns truthy for. The `callback` is bound to `thisArg` and invoked
1254
+ * with three arguments; (value, key, object).
1255
+ *
1256
+ * @static
1257
+ * @memberOf _
1258
+ * @category Objects
1259
+ * @param {Object} object The source object.
1260
+ * @param {Function|String} callback|[prop1, prop2, ...] The properties to omit
1261
+ * or the function called per iteration.
1262
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1263
+ * @returns {Object} Returns an object without the omitted properties.
1264
+ * @example
1265
+ *
1266
+ * _.omit({ 'name': 'moe', 'age': 40 }, 'age');
1267
+ * // => { 'name': 'moe' }
1268
+ *
1269
+ * _.omit({ 'name': 'moe', 'age': 40 }, function(value) {
1270
+ * return typeof value == 'number';
1271
+ * });
1272
+ * // => { 'name': 'moe' }
1273
+ */
1274
+ function omit(object) {
1275
+ var props = concat.apply(arrayRef, arguments),
1276
+ result = {};
1277
+
1278
+ forIn(object, function(value, key) {
1279
+ if (indexOf(props, key, 1) < 0) {
1280
+ result[key] = value;
1281
+ }
1282
+ });
1283
+ return result;
1284
+ }
1285
+
1286
+ /**
1287
+ * Creates a two dimensional array of the given object's key-value pairs,
1288
+ * i.e. `[[key1, value1], [key2, value2]]`.
1289
+ *
1290
+ * @static
1291
+ * @memberOf _
1292
+ * @category Objects
1293
+ * @param {Object} object The object to inspect.
1294
+ * @returns {Array} Returns new array of key-value pairs.
1295
+ * @example
1296
+ *
1297
+ * _.pairs({ 'moe': 30, 'larry': 40 });
1298
+ * // => [['moe', 30], ['larry', 40]] (order is not guaranteed)
1299
+ */
1300
+ function pairs(object) {
1301
+ var index = -1,
1302
+ props = keys(object),
1303
+ length = props.length,
1304
+ result = Array(length);
1305
+
1306
+ while (++index < length) {
1307
+ var key = props[index];
1308
+ result[index] = [key, object[key]];
1309
+ }
1310
+ return result;
1311
+ }
1312
+
1313
+ /**
1314
+ * Creates a shallow clone of `object` composed of the specified properties.
1315
+ * Property names may be specified as individual arguments or as arrays of property
1316
+ * names. If `callback` is passed, it will be executed for each property in the
1317
+ * `object`, picking the properties `callback` returns truthy for. The `callback`
1318
+ * is bound to `thisArg` and invoked with three arguments; (value, key, object).
1319
+ *
1320
+ * @static
1321
+ * @memberOf _
1322
+ * @category Objects
1323
+ * @param {Object} object The source object.
1324
+ * @param {Array|Function|String} callback|[prop1, prop2, ...] The function called
1325
+ * per iteration or properties to pick, either as individual arguments or arrays.
1326
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1327
+ * @returns {Object} Returns an object composed of the picked properties.
1328
+ * @example
1329
+ *
1330
+ * _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name');
1331
+ * // => { 'name': 'moe' }
1332
+ *
1333
+ * _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) {
1334
+ * return key.charAt(0) != '_';
1335
+ * });
1336
+ * // => { 'name': 'moe' }
1337
+ */
1338
+ function pick(object) {
1339
+ var index = 0,
1340
+ props = concat.apply(arrayRef, arguments),
1341
+ length = props.length,
1342
+ result = {};
1343
+
1344
+ while (++index < length) {
1345
+ var prop = props[index];
1346
+ if (prop in object) {
1347
+ result[prop] = object[prop];
1348
+ }
1349
+ }
1350
+ return result;
1351
+ }
1352
+
1353
+ /**
1354
+ * Creates an array composed of the own enumerable property values of `object`.
1355
+ *
1356
+ * @static
1357
+ * @memberOf _
1358
+ * @category Objects
1359
+ * @param {Object} object The object to inspect.
1360
+ * @returns {Array} Returns a new array of property values.
1361
+ * @example
1362
+ *
1363
+ * _.values({ 'one': 1, 'two': 2, 'three': 3 });
1364
+ * // => [1, 2, 3] (order is not guaranteed)
1365
+ */
1366
+ function values(object) {
1367
+ var index = -1,
1368
+ props = keys(object),
1369
+ length = props.length,
1370
+ result = Array(length);
1371
+
1372
+ while (++index < length) {
1373
+ result[index] = object[props[index]];
1374
+ }
1375
+ return result;
1376
+ }
1377
+
1378
+ /*--------------------------------------------------------------------------*/
1379
+
1380
+ /**
1381
+ * Checks if a given `target` element is present in a `collection` using strict
1382
+ * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used
1383
+ * as the offset from the end of the collection.
1384
+ *
1385
+ * @static
1386
+ * @memberOf _
1387
+ * @alias include
1388
+ * @category Collections
1389
+ * @param {Array|Object|String} collection The collection to iterate over.
1390
+ * @param {Mixed} target The value to check for.
1391
+ * @param {Number} [fromIndex=0] The index to search from.
1392
+ * @returns {Boolean} Returns `true` if the `target` element is found, else `false`.
1393
+ * @example
1394
+ *
1395
+ * _.contains([1, 2, 3], 1);
1396
+ * // => true
1397
+ *
1398
+ * _.contains([1, 2, 3], 1, 2);
1399
+ * // => false
1400
+ *
1401
+ * _.contains({ 'name': 'moe', 'age': 40 }, 'moe');
1402
+ * // => true
1403
+ *
1404
+ * _.contains('curly', 'ur');
1405
+ * // => true
1406
+ */
1407
+ function contains(collection, target) {
1408
+ var length = collection ? collection.length : 0,
1409
+ result = false;
1410
+ if (typeof length == 'number') {
1411
+ result = indexOf(collection, target) > -1;
1412
+ } else {
1413
+ forOwn(collection, function(value) {
1414
+ return (result = value === target) && indicatorObject;
1415
+ });
1416
+ }
1417
+ return result;
1418
+ }
1419
+
1420
+ /**
1421
+ * Creates an object composed of keys returned from running each element of the
1422
+ * `collection` through the given `callback`. The corresponding value of each key
1423
+ * is the number of times the key was returned by the `callback`. The `callback`
1424
+ * is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).
1425
+ *
1426
+ * If a property name is passed for `callback`, the created "_.pluck" style
1427
+ * callback will return the property value of the given element.
1428
+ *
1429
+ * If an object is passed for `callback`, the created "_.where" style callback
1430
+ * will return `true` for elements that have the properties of the given object,
1431
+ * else `false`.
1432
+ *
1433
+ * @static
1434
+ * @memberOf _
1435
+ * @category Collections
1436
+ * @param {Array|Object|String} collection The collection to iterate over.
1437
+ * @param {Function|Object|String} [callback=identity] The function called per
1438
+ * iteration. If a property name or object is passed, it will be used to create
1439
+ * a "_.pluck" or "_.where" style callback, respectively.
1440
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1441
+ * @returns {Object} Returns the composed aggregate object.
1442
+ * @example
1443
+ *
1444
+ * _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
1445
+ * // => { '4': 1, '6': 2 }
1446
+ *
1447
+ * _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
1448
+ * // => { '4': 1, '6': 2 }
1449
+ *
1450
+ * _.countBy(['one', 'two', 'three'], 'length');
1451
+ * // => { '3': 2, '5': 1 }
1452
+ */
1453
+ function countBy(collection, callback, thisArg) {
1454
+ var result = {};
1455
+ callback = createCallback(callback, thisArg);
1456
+
1457
+ forEach(collection, function(value, key, collection) {
1458
+ key = String(callback(value, key, collection));
1459
+ (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1);
1460
+ });
1461
+ return result;
1462
+ }
1463
+
1464
+ /**
1465
+ * Checks if the `callback` returns a truthy value for **all** elements of a
1466
+ * `collection`. The `callback` is bound to `thisArg` and invoked with three
1467
+ * arguments; (value, index|key, collection).
1468
+ *
1469
+ * If a property name is passed for `callback`, the created "_.pluck" style
1470
+ * callback will return the property value of the given element.
1471
+ *
1472
+ * If an object is passed for `callback`, the created "_.where" style callback
1473
+ * will return `true` for elements that have the properties of the given object,
1474
+ * else `false`.
1475
+ *
1476
+ * @static
1477
+ * @memberOf _
1478
+ * @alias all
1479
+ * @category Collections
1480
+ * @param {Array|Object|String} collection The collection to iterate over.
1481
+ * @param {Function|Object|String} [callback=identity] The function called per
1482
+ * iteration. If a property name or object is passed, it will be used to create
1483
+ * a "_.pluck" or "_.where" style callback, respectively.
1484
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1485
+ * @returns {Boolean} Returns `true` if all elements pass the callback check,
1486
+ * else `false`.
1487
+ * @example
1488
+ *
1489
+ * _.every([true, 1, null, 'yes'], Boolean);
1490
+ * // => false
1491
+ *
1492
+ * var stooges = [
1493
+ * { 'name': 'moe', 'age': 40 },
1494
+ * { 'name': 'larry', 'age': 50 }
1495
+ * ];
1496
+ *
1497
+ * // using "_.pluck" callback shorthand
1498
+ * _.every(stooges, 'age');
1499
+ * // => true
1500
+ *
1501
+ * // using "_.where" callback shorthand
1502
+ * _.every(stooges, { 'age': 50 });
1503
+ * // => false
1504
+ */
1505
+ function every(collection, callback, thisArg) {
1506
+ var result = true;
1507
+ callback = createCallback(callback, thisArg);
1508
+
1509
+ var index = -1,
1510
+ length = collection ? collection.length : 0;
1511
+
1512
+ if (typeof length == 'number') {
1513
+ while (++index < length) {
1514
+ if (!(result = !!callback(collection[index], index, collection))) {
1515
+ break;
1516
+ }
1517
+ }
1518
+ } else {
1519
+ forOwn(collection, function(value, index, collection) {
1520
+ return !(result = !!callback(value, index, collection)) && indicatorObject;
1521
+ });
1522
+ }
1523
+ return result;
1524
+ }
1525
+
1526
+ /**
1527
+ * Examines each element in a `collection`, returning an array of all elements
1528
+ * the `callback` returns truthy for. The `callback` is bound to `thisArg` and
1529
+ * invoked with three arguments; (value, index|key, collection).
1530
+ *
1531
+ * If a property name is passed for `callback`, the created "_.pluck" style
1532
+ * callback will return the property value of the given element.
1533
+ *
1534
+ * If an object is passed for `callback`, the created "_.where" style callback
1535
+ * will return `true` for elements that have the properties of the given object,
1536
+ * else `false`.
1537
+ *
1538
+ * @static
1539
+ * @memberOf _
1540
+ * @alias select
1541
+ * @category Collections
1542
+ * @param {Array|Object|String} collection The collection to iterate over.
1543
+ * @param {Function|Object|String} [callback=identity] The function called per
1544
+ * iteration. If a property name or object is passed, it will be used to create
1545
+ * a "_.pluck" or "_.where" style callback, respectively.
1546
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1547
+ * @returns {Array} Returns a new array of elements that passed the callback check.
1548
+ * @example
1549
+ *
1550
+ * var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
1551
+ * // => [2, 4, 6]
1552
+ *
1553
+ * var food = [
1554
+ * { 'name': 'apple', 'organic': false, 'type': 'fruit' },
1555
+ * { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
1556
+ * ];
1557
+ *
1558
+ * // using "_.pluck" callback shorthand
1559
+ * _.filter(food, 'organic');
1560
+ * // => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }]
1561
+ *
1562
+ * // using "_.where" callback shorthand
1563
+ * _.filter(food, { 'type': 'fruit' });
1564
+ * // => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }]
1565
+ */
1566
+ function filter(collection, callback, thisArg) {
1567
+ var result = [];
1568
+ callback = createCallback(callback, thisArg);
1569
+
1570
+ var index = -1,
1571
+ length = collection ? collection.length : 0;
1572
+
1573
+ if (typeof length == 'number') {
1574
+ while (++index < length) {
1575
+ var value = collection[index];
1576
+ if (callback(value, index, collection)) {
1577
+ result.push(value);
1578
+ }
1579
+ }
1580
+ } else {
1581
+ forOwn(collection, function(value, index, collection) {
1582
+ if (callback(value, index, collection)) {
1583
+ result.push(value);
1584
+ }
1585
+ });
1586
+ }
1587
+ return result;
1588
+ }
1589
+
1590
+ /**
1591
+ * Examines each element in a `collection`, returning the first that the `callback`
1592
+ * returns truthy for. The `callback` is bound to `thisArg` and invoked with three
1593
+ * arguments; (value, index|key, collection).
1594
+ *
1595
+ * If a property name is passed for `callback`, the created "_.pluck" style
1596
+ * callback will return the property value of the given element.
1597
+ *
1598
+ * If an object is passed for `callback`, the created "_.where" style callback
1599
+ * will return `true` for elements that have the properties of the given object,
1600
+ * else `false`.
1601
+ *
1602
+ * @static
1603
+ * @memberOf _
1604
+ * @alias detect
1605
+ * @category Collections
1606
+ * @param {Array|Object|String} collection The collection to iterate over.
1607
+ * @param {Function|Object|String} [callback=identity] The function called per
1608
+ * iteration. If a property name or object is passed, it will be used to create
1609
+ * a "_.pluck" or "_.where" style callback, respectively.
1610
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1611
+ * @returns {Mixed} Returns the found element, else `undefined`.
1612
+ * @example
1613
+ *
1614
+ * _.find([1, 2, 3, 4], function(num) { return num % 2 == 0; });
1615
+ * // => 2
1616
+ *
1617
+ * var food = [
1618
+ * { 'name': 'apple', 'organic': false, 'type': 'fruit' },
1619
+ * { 'name': 'banana', 'organic': true, 'type': 'fruit' },
1620
+ * { 'name': 'beet', 'organic': false, 'type': 'vegetable' }
1621
+ * ];
1622
+ *
1623
+ * // using "_.where" callback shorthand
1624
+ * _.find(food, { 'type': 'vegetable' });
1625
+ * // => { 'name': 'beet', 'organic': false, 'type': 'vegetable' }
1626
+ *
1627
+ * // using "_.pluck" callback shorthand
1628
+ * _.find(food, 'organic');
1629
+ * // => { 'name': 'banana', 'organic': true, 'type': 'fruit' }
1630
+ */
1631
+ function find(collection, callback, thisArg) {
1632
+ callback = createCallback(callback, thisArg);
1633
+
1634
+ var index = -1,
1635
+ length = collection ? collection.length : 0;
1636
+
1637
+ if (typeof length == 'number') {
1638
+ while (++index < length) {
1639
+ var value = collection[index];
1640
+ if (callback(value, index, collection)) {
1641
+ return value;
1642
+ }
1643
+ }
1644
+ } else {
1645
+ var result;
1646
+ forOwn(collection, function(value, index, collection) {
1647
+ if (callback(value, index, collection)) {
1648
+ result = value;
1649
+ return indicatorObject;
1650
+ }
1651
+ });
1652
+ return result;
1653
+ }
1654
+ }
1655
+
1656
+ function findWhere(object, properties) {
1657
+ return where(object, properties, true);
1658
+ }
1659
+
1660
+ /**
1661
+ * Iterates over a `collection`, executing the `callback` for each element in
1662
+ * the `collection`. The `callback` is bound to `thisArg` and invoked with three
1663
+ * arguments; (value, index|key, collection). Callbacks may exit iteration early
1664
+ * by explicitly returning `false`.
1665
+ *
1666
+ * @static
1667
+ * @memberOf _
1668
+ * @alias each
1669
+ * @category Collections
1670
+ * @param {Array|Object|String} collection The collection to iterate over.
1671
+ * @param {Function} [callback=identity] The function called per iteration.
1672
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1673
+ * @returns {Array|Object|String} Returns `collection`.
1674
+ * @example
1675
+ *
1676
+ * _([1, 2, 3]).forEach(alert).join(',');
1677
+ * // => alerts each number and returns '1,2,3'
1678
+ *
1679
+ * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert);
1680
+ * // => alerts each number value (order is not guaranteed)
1681
+ */
1682
+ function forEach(collection, callback, thisArg) {
1683
+ var index = -1,
1684
+ length = collection ? collection.length : 0;
1685
+
1686
+ if (typeof length == 'number') {
1687
+ callback = callback && typeof thisArg == 'undefined' ? callback : createCallback(callback, thisArg);
1688
+ while (++index < length) {
1689
+ if (callback(collection[index], index, collection) === indicatorObject) {
1690
+ break;
1691
+ }
1692
+ }
1693
+ } else {
1694
+ forOwn(collection, callback, thisArg);
1695
+ };
1696
+ }
1697
+
1698
+ /**
1699
+ * Creates an object composed of keys returned from running each element of the
1700
+ * `collection` through the `callback`. The corresponding value of each key is
1701
+ * an array of elements passed to `callback` that returned the key. The `callback`
1702
+ * is bound to `thisArg` and invoked with three arguments; (value, index|key, collection).
1703
+ *
1704
+ * If a property name is passed for `callback`, the created "_.pluck" style
1705
+ * callback will return the property value of the given element.
1706
+ *
1707
+ * If an object is passed for `callback`, the created "_.where" style callback
1708
+ * will return `true` for elements that have the properties of the given object,
1709
+ * else `false`
1710
+ *
1711
+ * @static
1712
+ * @memberOf _
1713
+ * @category Collections
1714
+ * @param {Array|Object|String} collection The collection to iterate over.
1715
+ * @param {Function|Object|String} [callback=identity] The function called per
1716
+ * iteration. If a property name or object is passed, it will be used to create
1717
+ * a "_.pluck" or "_.where" style callback, respectively.
1718
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1719
+ * @returns {Object} Returns the composed aggregate object.
1720
+ * @example
1721
+ *
1722
+ * _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
1723
+ * // => { '4': [4.2], '6': [6.1, 6.4] }
1724
+ *
1725
+ * _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
1726
+ * // => { '4': [4.2], '6': [6.1, 6.4] }
1727
+ *
1728
+ * // using "_.pluck" callback shorthand
1729
+ * _.groupBy(['one', 'two', 'three'], 'length');
1730
+ * // => { '3': ['one', 'two'], '5': ['three'] }
1731
+ */
1732
+ function groupBy(collection, callback, thisArg) {
1733
+ var result = {};
1734
+ callback = createCallback(callback, thisArg);
1735
+
1736
+ forEach(collection, function(value, key, collection) {
1737
+ key = String(callback(value, key, collection));
1738
+ (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value);
1739
+ });
1740
+ return result;
1741
+ }
1742
+
1743
+ /**
1744
+ * Invokes the method named by `methodName` on each element in the `collection`,
1745
+ * returning an array of the results of each invoked method. Additional arguments
1746
+ * will be passed to each invoked method. If `methodName` is a function, it will
1747
+ * be invoked for, and `this` bound to, each element in the `collection`.
1748
+ *
1749
+ * @static
1750
+ * @memberOf _
1751
+ * @category Collections
1752
+ * @param {Array|Object|String} collection The collection to iterate over.
1753
+ * @param {Function|String} methodName The name of the method to invoke or
1754
+ * the function invoked per iteration.
1755
+ * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the method with.
1756
+ * @returns {Array} Returns a new array of the results of each invoked method.
1757
+ * @example
1758
+ *
1759
+ * _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
1760
+ * // => [[1, 5, 7], [1, 2, 3]]
1761
+ *
1762
+ * _.invoke([123, 456], String.prototype.split, '');
1763
+ * // => [['1', '2', '3'], ['4', '5', '6']]
1764
+ */
1765
+ function invoke(collection, methodName) {
1766
+ var args = slice.call(arguments, 2),
1767
+ index = -1,
1768
+ isFunc = typeof methodName == 'function',
1769
+ length = collection ? collection.length : 0,
1770
+ result = Array(typeof length == 'number' ? length : 0);
1771
+
1772
+ forEach(collection, function(value) {
1773
+ result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args);
1774
+ });
1775
+ return result;
1776
+ }
1777
+
1778
+ /**
1779
+ * Creates an array of values by running each element in the `collection`
1780
+ * through the `callback`. The `callback` is bound to `thisArg` and invoked with
1781
+ * three arguments; (value, index|key, collection).
1782
+ *
1783
+ * If a property name is passed for `callback`, the created "_.pluck" style
1784
+ * callback will return the property value of the given element.
1785
+ *
1786
+ * If an object is passed for `callback`, the created "_.where" style callback
1787
+ * will return `true` for elements that have the properties of the given object,
1788
+ * else `false`.
1789
+ *
1790
+ * @static
1791
+ * @memberOf _
1792
+ * @alias collect
1793
+ * @category Collections
1794
+ * @param {Array|Object|String} collection The collection to iterate over.
1795
+ * @param {Function|Object|String} [callback=identity] The function called per
1796
+ * iteration. If a property name or object is passed, it will be used to create
1797
+ * a "_.pluck" or "_.where" style callback, respectively.
1798
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1799
+ * @returns {Array} Returns a new array of the results of each `callback` execution.
1800
+ * @example
1801
+ *
1802
+ * _.map([1, 2, 3], function(num) { return num * 3; });
1803
+ * // => [3, 6, 9]
1804
+ *
1805
+ * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
1806
+ * // => [3, 6, 9] (order is not guaranteed)
1807
+ *
1808
+ * var stooges = [
1809
+ * { 'name': 'moe', 'age': 40 },
1810
+ * { 'name': 'larry', 'age': 50 }
1811
+ * ];
1812
+ *
1813
+ * // using "_.pluck" callback shorthand
1814
+ * _.map(stooges, 'name');
1815
+ * // => ['moe', 'larry']
1816
+ */
1817
+ function map(collection, callback, thisArg) {
1818
+ var index = -1,
1819
+ length = collection ? collection.length : 0;
1820
+
1821
+ callback = createCallback(callback, thisArg);
1822
+ if (typeof length == 'number') {
1823
+ var result = Array(length);
1824
+ while (++index < length) {
1825
+ result[index] = callback(collection[index], index, collection);
1826
+ }
1827
+ } else {
1828
+ result = [];
1829
+ forOwn(collection, function(value, key, collection) {
1830
+ result[++index] = callback(value, key, collection);
1831
+ });
1832
+ }
1833
+ return result;
1834
+ }
1835
+
1836
+ /**
1837
+ * Retrieves the maximum value of an `array`. If `callback` is passed,
1838
+ * it will be executed for each value in the `array` to generate the
1839
+ * criterion by which the value is ranked. The `callback` is bound to
1840
+ * `thisArg` and invoked with three arguments; (value, index, collection).
1841
+ *
1842
+ * If a property name is passed for `callback`, the created "_.pluck" style
1843
+ * callback will return the property value of the given element.
1844
+ *
1845
+ * If an object is passed for `callback`, the created "_.where" style callback
1846
+ * will return `true` for elements that have the properties of the given object,
1847
+ * else `false`.
1848
+ *
1849
+ * @static
1850
+ * @memberOf _
1851
+ * @category Collections
1852
+ * @param {Array|Object|String} collection The collection to iterate over.
1853
+ * @param {Function|Object|String} [callback=identity] The function called per
1854
+ * iteration. If a property name or object is passed, it will be used to create
1855
+ * a "_.pluck" or "_.where" style callback, respectively.
1856
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1857
+ * @returns {Mixed} Returns the maximum value.
1858
+ * @example
1859
+ *
1860
+ * _.max([4, 2, 8, 6]);
1861
+ * // => 8
1862
+ *
1863
+ * var stooges = [
1864
+ * { 'name': 'moe', 'age': 40 },
1865
+ * { 'name': 'larry', 'age': 50 }
1866
+ * ];
1867
+ *
1868
+ * _.max(stooges, function(stooge) { return stooge.age; });
1869
+ * // => { 'name': 'larry', 'age': 50 };
1870
+ *
1871
+ * // using "_.pluck" callback shorthand
1872
+ * _.max(stooges, 'age');
1873
+ * // => { 'name': 'larry', 'age': 50 };
1874
+ */
1875
+ function max(collection, callback, thisArg) {
1876
+ var computed = -Infinity,
1877
+ result = computed;
1878
+
1879
+ var index = -1,
1880
+ length = collection ? collection.length : 0;
1881
+
1882
+ if (!callback && typeof length == 'number') {
1883
+ while (++index < length) {
1884
+ var value = collection[index];
1885
+ if (value > result) {
1886
+ result = value;
1887
+ }
1888
+ }
1889
+ } else {
1890
+ callback = createCallback(callback, thisArg);
1891
+
1892
+ forEach(collection, function(value, index, collection) {
1893
+ var current = callback(value, index, collection);
1894
+ if (current > computed) {
1895
+ computed = current;
1896
+ result = value;
1897
+ }
1898
+ });
1899
+ }
1900
+ return result;
1901
+ }
1902
+
1903
+ /**
1904
+ * Retrieves the minimum value of an `array`. If `callback` is passed,
1905
+ * it will be executed for each value in the `array` to generate the
1906
+ * criterion by which the value is ranked. The `callback` is bound to `thisArg`
1907
+ * and invoked with three arguments; (value, index, collection).
1908
+ *
1909
+ * If a property name is passed for `callback`, the created "_.pluck" style
1910
+ * callback will return the property value of the given element.
1911
+ *
1912
+ * If an object is passed for `callback`, the created "_.where" style callback
1913
+ * will return `true` for elements that have the properties of the given object,
1914
+ * else `false`.
1915
+ *
1916
+ * @static
1917
+ * @memberOf _
1918
+ * @category Collections
1919
+ * @param {Array|Object|String} collection The collection to iterate over.
1920
+ * @param {Function|Object|String} [callback=identity] The function called per
1921
+ * iteration. If a property name or object is passed, it will be used to create
1922
+ * a "_.pluck" or "_.where" style callback, respectively.
1923
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
1924
+ * @returns {Mixed} Returns the minimum value.
1925
+ * @example
1926
+ *
1927
+ * _.min([4, 2, 8, 6]);
1928
+ * // => 2
1929
+ *
1930
+ * var stooges = [
1931
+ * { 'name': 'moe', 'age': 40 },
1932
+ * { 'name': 'larry', 'age': 50 }
1933
+ * ];
1934
+ *
1935
+ * _.min(stooges, function(stooge) { return stooge.age; });
1936
+ * // => { 'name': 'moe', 'age': 40 };
1937
+ *
1938
+ * // using "_.pluck" callback shorthand
1939
+ * _.min(stooges, 'age');
1940
+ * // => { 'name': 'moe', 'age': 40 };
1941
+ */
1942
+ function min(collection, callback, thisArg) {
1943
+ var computed = Infinity,
1944
+ result = computed;
1945
+
1946
+ var index = -1,
1947
+ length = collection ? collection.length : 0;
1948
+
1949
+ if (!callback && typeof length == 'number') {
1950
+ while (++index < length) {
1951
+ var value = collection[index];
1952
+ if (value < result) {
1953
+ result = value;
1954
+ }
1955
+ }
1956
+ } else {
1957
+ callback = createCallback(callback, thisArg);
1958
+
1959
+ forEach(collection, function(value, index, collection) {
1960
+ var current = callback(value, index, collection);
1961
+ if (current < computed) {
1962
+ computed = current;
1963
+ result = value;
1964
+ }
1965
+ });
1966
+ }
1967
+ return result;
1968
+ }
1969
+
1970
+ /**
1971
+ * Retrieves the value of a specified property from all elements in the `collection`.
1972
+ *
1973
+ * @static
1974
+ * @memberOf _
1975
+ * @type Function
1976
+ * @category Collections
1977
+ * @param {Array|Object|String} collection The collection to iterate over.
1978
+ * @param {String} property The property to pluck.
1979
+ * @returns {Array} Returns a new array of property values.
1980
+ * @example
1981
+ *
1982
+ * var stooges = [
1983
+ * { 'name': 'moe', 'age': 40 },
1984
+ * { 'name': 'larry', 'age': 50 }
1985
+ * ];
1986
+ *
1987
+ * _.pluck(stooges, 'name');
1988
+ * // => ['moe', 'larry']
1989
+ */
1990
+ function pluck(collection, property) {
1991
+ var index = -1,
1992
+ length = collection ? collection.length : 0;
1993
+
1994
+ if (typeof length == 'number') {
1995
+ var result = Array(length);
1996
+ while (++index < length) {
1997
+ result[index] = collection[index][property];
1998
+ }
1999
+ }
2000
+ return result || map(collection, property);
2001
+ }
2002
+
2003
+ /**
2004
+ * Reduces a `collection` to a value that is the accumulated result of running
2005
+ * each element in the `collection` through the `callback`, where each successive
2006
+ * `callback` execution consumes the return value of the previous execution.
2007
+ * If `accumulator` is not passed, the first element of the `collection` will be
2008
+ * used as the initial `accumulator` value. The `callback` is bound to `thisArg`
2009
+ * and invoked with four arguments; (accumulator, value, index|key, collection).
2010
+ *
2011
+ * @static
2012
+ * @memberOf _
2013
+ * @alias foldl, inject
2014
+ * @category Collections
2015
+ * @param {Array|Object|String} collection The collection to iterate over.
2016
+ * @param {Function} [callback=identity] The function called per iteration.
2017
+ * @param {Mixed} [accumulator] Initial value of the accumulator.
2018
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2019
+ * @returns {Mixed} Returns the accumulated value.
2020
+ * @example
2021
+ *
2022
+ * var sum = _.reduce([1, 2, 3], function(sum, num) {
2023
+ * return sum + num;
2024
+ * });
2025
+ * // => 6
2026
+ *
2027
+ * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
2028
+ * result[key] = num * 3;
2029
+ * return result;
2030
+ * }, {});
2031
+ * // => { 'a': 3, 'b': 6, 'c': 9 }
2032
+ */
2033
+ function reduce(collection, callback, accumulator, thisArg) {
2034
+ if (!collection) return accumulator;
2035
+ var noaccum = arguments.length < 3;
2036
+ callback = createCallback(callback, thisArg, 4);
2037
+
2038
+ var index = -1,
2039
+ length = collection.length;
2040
+
2041
+ if (typeof length == 'number') {
2042
+ if (noaccum) {
2043
+ accumulator = collection[++index];
2044
+ }
2045
+ while (++index < length) {
2046
+ accumulator = callback(accumulator, collection[index], index, collection);
2047
+ }
2048
+ } else {
2049
+ forOwn(collection, function(value, index, collection) {
2050
+ accumulator = noaccum
2051
+ ? (noaccum = false, value)
2052
+ : callback(accumulator, value, index, collection)
2053
+ });
2054
+ }
2055
+ return accumulator;
2056
+ }
2057
+
2058
+ /**
2059
+ * This method is similar to `_.reduce`, except that it iterates over a
2060
+ * `collection` from right to left.
2061
+ *
2062
+ * @static
2063
+ * @memberOf _
2064
+ * @alias foldr
2065
+ * @category Collections
2066
+ * @param {Array|Object|String} collection The collection to iterate over.
2067
+ * @param {Function} [callback=identity] The function called per iteration.
2068
+ * @param {Mixed} [accumulator] Initial value of the accumulator.
2069
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2070
+ * @returns {Mixed} Returns the accumulated value.
2071
+ * @example
2072
+ *
2073
+ * var list = [[0, 1], [2, 3], [4, 5]];
2074
+ * var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
2075
+ * // => [4, 5, 2, 3, 0, 1]
2076
+ */
2077
+ function reduceRight(collection, callback, accumulator, thisArg) {
2078
+ var iterable = collection,
2079
+ length = collection ? collection.length : 0,
2080
+ noaccum = arguments.length < 3;
2081
+
2082
+ if (typeof length != 'number') {
2083
+ var props = keys(collection);
2084
+ length = props.length;
2085
+ }
2086
+ callback = createCallback(callback, thisArg, 4);
2087
+ forEach(collection, function(value, index, collection) {
2088
+ index = props ? props[--length] : --length;
2089
+ accumulator = noaccum
2090
+ ? (noaccum = false, iterable[index])
2091
+ : callback(accumulator, iterable[index], index, collection);
2092
+ });
2093
+ return accumulator;
2094
+ }
2095
+
2096
+ /**
2097
+ * The opposite of `_.filter`, this method returns the elements of a
2098
+ * `collection` that `callback` does **not** return truthy for.
2099
+ *
2100
+ * If a property name is passed for `callback`, the created "_.pluck" style
2101
+ * callback will return the property value of the given element.
2102
+ *
2103
+ * If an object is passed for `callback`, the created "_.where" style callback
2104
+ * will return `true` for elements that have the properties of the given object,
2105
+ * else `false`.
2106
+ *
2107
+ * @static
2108
+ * @memberOf _
2109
+ * @category Collections
2110
+ * @param {Array|Object|String} collection The collection to iterate over.
2111
+ * @param {Function|Object|String} [callback=identity] The function called per
2112
+ * iteration. If a property name or object is passed, it will be used to create
2113
+ * a "_.pluck" or "_.where" style callback, respectively.
2114
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2115
+ * @returns {Array} Returns a new array of elements that did **not** pass the
2116
+ * callback check.
2117
+ * @example
2118
+ *
2119
+ * var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
2120
+ * // => [1, 3, 5]
2121
+ *
2122
+ * var food = [
2123
+ * { 'name': 'apple', 'organic': false, 'type': 'fruit' },
2124
+ * { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
2125
+ * ];
2126
+ *
2127
+ * // using "_.pluck" callback shorthand
2128
+ * _.reject(food, 'organic');
2129
+ * // => [{ 'name': 'apple', 'organic': false, 'type': 'fruit' }]
2130
+ *
2131
+ * // using "_.where" callback shorthand
2132
+ * _.reject(food, { 'type': 'fruit' });
2133
+ * // => [{ 'name': 'carrot', 'organic': true, 'type': 'vegetable' }]
2134
+ */
2135
+ function reject(collection, callback, thisArg) {
2136
+ callback = createCallback(callback, thisArg);
2137
+ return filter(collection, function(value, index, collection) {
2138
+ return !callback(value, index, collection);
2139
+ });
2140
+ }
2141
+
2142
+ /**
2143
+ * Creates an array of shuffled `array` values, using a version of the
2144
+ * Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
2145
+ *
2146
+ * @static
2147
+ * @memberOf _
2148
+ * @category Collections
2149
+ * @param {Array|Object|String} collection The collection to shuffle.
2150
+ * @returns {Array} Returns a new shuffled collection.
2151
+ * @example
2152
+ *
2153
+ * _.shuffle([1, 2, 3, 4, 5, 6]);
2154
+ * // => [4, 1, 6, 3, 5, 2]
2155
+ */
2156
+ function shuffle(collection) {
2157
+ var index = -1,
2158
+ length = collection ? collection.length : 0,
2159
+ result = Array(typeof length == 'number' ? length : 0);
2160
+
2161
+ forEach(collection, function(value) {
2162
+ var rand = floor(nativeRandom() * (++index + 1));
2163
+ result[index] = result[rand];
2164
+ result[rand] = value;
2165
+ });
2166
+ return result;
2167
+ }
2168
+
2169
+ /**
2170
+ * Gets the size of the `collection` by returning `collection.length` for arrays
2171
+ * and array-like objects or the number of own enumerable properties for objects.
2172
+ *
2173
+ * @static
2174
+ * @memberOf _
2175
+ * @category Collections
2176
+ * @param {Array|Object|String} collection The collection to inspect.
2177
+ * @returns {Number} Returns `collection.length` or number of own enumerable properties.
2178
+ * @example
2179
+ *
2180
+ * _.size([1, 2]);
2181
+ * // => 2
2182
+ *
2183
+ * _.size({ 'one': 1, 'two': 2, 'three': 3 });
2184
+ * // => 3
2185
+ *
2186
+ * _.size('curly');
2187
+ * // => 5
2188
+ */
2189
+ function size(collection) {
2190
+ var length = collection ? collection.length : 0;
2191
+ return typeof length == 'number' ? length : keys(collection).length;
2192
+ }
2193
+
2194
+ /**
2195
+ * Checks if the `callback` returns a truthy value for **any** element of a
2196
+ * `collection`. The function returns as soon as it finds passing value, and
2197
+ * does not iterate over the entire `collection`. The `callback` is bound to
2198
+ * `thisArg` and invoked with three arguments; (value, index|key, collection).
2199
+ *
2200
+ * If a property name is passed for `callback`, the created "_.pluck" style
2201
+ * callback will return the property value of the given element.
2202
+ *
2203
+ * If an object is passed for `callback`, the created "_.where" style callback
2204
+ * will return `true` for elements that have the properties of the given object,
2205
+ * else `false`.
2206
+ *
2207
+ * @static
2208
+ * @memberOf _
2209
+ * @alias any
2210
+ * @category Collections
2211
+ * @param {Array|Object|String} collection The collection to iterate over.
2212
+ * @param {Function|Object|String} [callback=identity] The function called per
2213
+ * iteration. If a property name or object is passed, it will be used to create
2214
+ * a "_.pluck" or "_.where" style callback, respectively.
2215
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2216
+ * @returns {Boolean} Returns `true` if any element passes the callback check,
2217
+ * else `false`.
2218
+ * @example
2219
+ *
2220
+ * _.some([null, 0, 'yes', false], Boolean);
2221
+ * // => true
2222
+ *
2223
+ * var food = [
2224
+ * { 'name': 'apple', 'organic': false, 'type': 'fruit' },
2225
+ * { 'name': 'carrot', 'organic': true, 'type': 'vegetable' }
2226
+ * ];
2227
+ *
2228
+ * // using "_.pluck" callback shorthand
2229
+ * _.some(food, 'organic');
2230
+ * // => true
2231
+ *
2232
+ * // using "_.where" callback shorthand
2233
+ * _.some(food, { 'type': 'meat' });
2234
+ * // => false
2235
+ */
2236
+ function some(collection, callback, thisArg) {
2237
+ var result;
2238
+ callback = createCallback(callback, thisArg);
2239
+
2240
+ var index = -1,
2241
+ length = collection ? collection.length : 0;
2242
+
2243
+ if (typeof length == 'number') {
2244
+ while (++index < length) {
2245
+ if ((result = callback(collection[index], index, collection))) {
2246
+ break;
2247
+ }
2248
+ }
2249
+ } else {
2250
+ forOwn(collection, function(value, index, collection) {
2251
+ return (result = callback(value, index, collection)) && indicatorObject;
2252
+ });
2253
+ }
2254
+ return !!result;
2255
+ }
2256
+
2257
+ /**
2258
+ * Creates an array of elements, sorted in ascending order by the results of
2259
+ * running each element in the `collection` through the `callback`. This method
2260
+ * performs a stable sort, that is, it will preserve the original sort order of
2261
+ * equal elements. The `callback` is bound to `thisArg` and invoked with three
2262
+ * arguments; (value, index|key, collection).
2263
+ *
2264
+ * If a property name is passed for `callback`, the created "_.pluck" style
2265
+ * callback will return the property value of the given element.
2266
+ *
2267
+ * If an object is passed for `callback`, the created "_.where" style callback
2268
+ * will return `true` for elements that have the properties of the given object,
2269
+ * else `false`.
2270
+ *
2271
+ * @static
2272
+ * @memberOf _
2273
+ * @category Collections
2274
+ * @param {Array|Object|String} collection The collection to iterate over.
2275
+ * @param {Function|Object|String} [callback=identity] The function called per
2276
+ * iteration. If a property name or object is passed, it will be used to create
2277
+ * a "_.pluck" or "_.where" style callback, respectively.
2278
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2279
+ * @returns {Array} Returns a new array of sorted elements.
2280
+ * @example
2281
+ *
2282
+ * _.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
2283
+ * // => [3, 1, 2]
2284
+ *
2285
+ * _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
2286
+ * // => [3, 1, 2]
2287
+ *
2288
+ * // using "_.pluck" callback shorthand
2289
+ * _.sortBy(['banana', 'strawberry', 'apple'], 'length');
2290
+ * // => ['apple', 'banana', 'strawberry']
2291
+ */
2292
+ function sortBy(collection, callback, thisArg) {
2293
+ var index = -1,
2294
+ length = collection ? collection.length : 0,
2295
+ result = Array(typeof length == 'number' ? length : 0);
2296
+
2297
+ callback = createCallback(callback, thisArg);
2298
+ forEach(collection, function(value, key, collection) {
2299
+ result[++index] = {
2300
+ 'criteria': callback(value, key, collection),
2301
+ 'index': index,
2302
+ 'value': value
2303
+ };
2304
+ });
2305
+
2306
+ length = result.length;
2307
+ result.sort(compareAscending);
2308
+ while (length--) {
2309
+ result[length] = result[length].value;
2310
+ }
2311
+ return result;
2312
+ }
2313
+
2314
+ /**
2315
+ * Converts the `collection` to an array.
2316
+ *
2317
+ * @static
2318
+ * @memberOf _
2319
+ * @category Collections
2320
+ * @param {Array|Object|String} collection The collection to convert.
2321
+ * @returns {Array} Returns the new converted array.
2322
+ * @example
2323
+ *
2324
+ * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
2325
+ * // => [2, 3, 4]
2326
+ */
2327
+ function toArray(collection) {
2328
+ if (isArray(collection)) {
2329
+ return slice.call(collection);
2330
+ }
2331
+ if (collection && typeof collection.length == 'number') {
2332
+ return map(collection);
2333
+ }
2334
+ return values(collection);
2335
+ }
2336
+
2337
+ /**
2338
+ * Examines each element in a `collection`, returning an array of all elements
2339
+ * that have the given `properties`. When checking `properties`, this method
2340
+ * performs a deep comparison between values to determine if they are equivalent
2341
+ * to each other.
2342
+ *
2343
+ * @static
2344
+ * @memberOf _
2345
+ * @type Function
2346
+ * @category Collections
2347
+ * @param {Array|Object|String} collection The collection to iterate over.
2348
+ * @param {Object} properties The object of property values to filter by.
2349
+ * @returns {Array} Returns a new array of elements that have the given `properties`.
2350
+ * @example
2351
+ *
2352
+ * var stooges = [
2353
+ * { 'name': 'moe', 'age': 40 },
2354
+ * { 'name': 'larry', 'age': 50 }
2355
+ * ];
2356
+ *
2357
+ * _.where(stooges, { 'age': 40 });
2358
+ * // => [{ 'name': 'moe', 'age': 40 }]
2359
+ */
2360
+ function where(collection, properties, first) {
2361
+ return (first && isEmpty(properties))
2362
+ ? null
2363
+ : (first ? find : filter)(collection, properties);
2364
+ }
2365
+
2366
+ /*--------------------------------------------------------------------------*/
2367
+
2368
+ /**
2369
+ * Creates an array with all falsey values of `array` removed. The values
2370
+ * `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey.
2371
+ *
2372
+ * @static
2373
+ * @memberOf _
2374
+ * @category Arrays
2375
+ * @param {Array} array The array to compact.
2376
+ * @returns {Array} Returns a new filtered array.
2377
+ * @example
2378
+ *
2379
+ * _.compact([0, 1, false, 2, '', 3]);
2380
+ * // => [1, 2, 3]
2381
+ */
2382
+ function compact(array) {
2383
+ var index = -1,
2384
+ length = array ? array.length : 0,
2385
+ result = [];
2386
+
2387
+ while (++index < length) {
2388
+ var value = array[index];
2389
+ if (value) {
2390
+ result.push(value);
2391
+ }
2392
+ }
2393
+ return result;
2394
+ }
2395
+
2396
+ /**
2397
+ * Creates an array of `array` elements not present in the other arrays
2398
+ * using strict equality for comparisons, i.e. `===`.
2399
+ *
2400
+ * @static
2401
+ * @memberOf _
2402
+ * @category Arrays
2403
+ * @param {Array} array The array to process.
2404
+ * @param {Array} [array1, array2, ...] Arrays to check.
2405
+ * @returns {Array} Returns a new array of `array` elements not present in the
2406
+ * other arrays.
2407
+ * @example
2408
+ *
2409
+ * _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
2410
+ * // => [1, 3, 4]
2411
+ */
2412
+ function difference(array) {
2413
+ var index = -1,
2414
+ length = array.length,
2415
+ flattened = concat.apply(arrayRef, arguments),
2416
+ result = [];
2417
+
2418
+ while (++index < length) {
2419
+ var value = array[index];
2420
+ if (indexOf(flattened, value, length) < 0) {
2421
+ result.push(value);
2422
+ }
2423
+ }
2424
+ return result;
2425
+ }
2426
+
2427
+ /**
2428
+ * Gets the first element of the `array`. If a number `n` is passed, the first
2429
+ * `n` elements of the `array` are returned. If a `callback` function is passed,
2430
+ * elements at the beginning of the array are returned as long as the `callback`
2431
+ * returns truthy. The `callback` is bound to `thisArg` and invoked with three
2432
+ * arguments; (value, index, array).
2433
+ *
2434
+ * If a property name is passed for `callback`, the created "_.pluck" style
2435
+ * callback will return the property value of the given element.
2436
+ *
2437
+ * If an object is passed for `callback`, the created "_.where" style callback
2438
+ * will return `true` for elements that have the properties of the given object,
2439
+ * else `false`.
2440
+ *
2441
+ * @static
2442
+ * @memberOf _
2443
+ * @alias head, take
2444
+ * @category Arrays
2445
+ * @param {Array} array The array to query.
2446
+ * @param {Function|Object|Number|String} [callback|n] The function called
2447
+ * per element or the number of elements to return. If a property name or
2448
+ * object is passed, it will be used to create a "_.pluck" or "_.where"
2449
+ * style callback, respectively.
2450
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2451
+ * @returns {Mixed} Returns the first element(s) of `array`.
2452
+ * @example
2453
+ *
2454
+ * _.first([1, 2, 3]);
2455
+ * // => 1
2456
+ *
2457
+ * _.first([1, 2, 3], 2);
2458
+ * // => [1, 2]
2459
+ *
2460
+ * _.first([1, 2, 3], function(num) {
2461
+ * return num < 3;
2462
+ * });
2463
+ * // => [1, 2]
2464
+ *
2465
+ * var food = [
2466
+ * { 'name': 'banana', 'organic': true },
2467
+ * { 'name': 'beet', 'organic': false },
2468
+ * ];
2469
+ *
2470
+ * // using "_.pluck" callback shorthand
2471
+ * _.first(food, 'organic');
2472
+ * // => [{ 'name': 'banana', 'organic': true }]
2473
+ *
2474
+ * var food = [
2475
+ * { 'name': 'apple', 'type': 'fruit' },
2476
+ * { 'name': 'banana', 'type': 'fruit' },
2477
+ * { 'name': 'beet', 'type': 'vegetable' }
2478
+ * ];
2479
+ *
2480
+ * // using "_.where" callback shorthand
2481
+ * _.first(food, { 'type': 'fruit' });
2482
+ * // => [{ 'name': 'apple', 'type': 'fruit' }, { 'name': 'banana', 'type': 'fruit' }]
2483
+ */
2484
+ function first(array, callback, thisArg) {
2485
+ if (array) {
2486
+ var n = 0,
2487
+ length = array.length;
2488
+
2489
+ if (typeof callback != 'number' && callback != null) {
2490
+ var index = -1;
2491
+ callback = createCallback(callback, thisArg);
2492
+ while (++index < length && callback(array[index], index, array)) {
2493
+ n++;
2494
+ }
2495
+ } else {
2496
+ n = callback;
2497
+ if (n == null || thisArg) {
2498
+ return array[0];
2499
+ }
2500
+ }
2501
+ return slice.call(array, 0, nativeMin(nativeMax(0, n), length));
2502
+ }
2503
+ }
2504
+
2505
+ /**
2506
+ * Flattens a nested array (the nesting can be to any depth). If `isShallow`
2507
+ * is truthy, `array` will only be flattened a single level. If `callback`
2508
+ * is passed, each element of `array` is passed through a callback` before
2509
+ * flattening. The `callback` is bound to `thisArg` and invoked with three
2510
+ * arguments; (value, index, array).
2511
+ *
2512
+ * If a property name is passed for `callback`, the created "_.pluck" style
2513
+ * callback will return the property value of the given element.
2514
+ *
2515
+ * If an object is passed for `callback`, the created "_.where" style callback
2516
+ * will return `true` for elements that have the properties of the given object,
2517
+ * else `false`.
2518
+ *
2519
+ * @static
2520
+ * @memberOf _
2521
+ * @category Arrays
2522
+ * @param {Array} array The array to compact.
2523
+ * @param {Boolean} [isShallow=false] A flag to indicate only flattening a single level.
2524
+ * @param {Function|Object|String} [callback=identity] The function called per
2525
+ * iteration. If a property name or object is passed, it will be used to create
2526
+ * a "_.pluck" or "_.where" style callback, respectively.
2527
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2528
+ * @returns {Array} Returns a new flattened array.
2529
+ * @example
2530
+ *
2531
+ * _.flatten([1, [2], [3, [[4]]]]);
2532
+ * // => [1, 2, 3, 4];
2533
+ *
2534
+ * _.flatten([1, [2], [3, [[4]]]], true);
2535
+ * // => [1, 2, 3, [[4]]];
2536
+ *
2537
+ * var stooges = [
2538
+ * { 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] },
2539
+ * { 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] }
2540
+ * ];
2541
+ *
2542
+ * // using "_.pluck" callback shorthand
2543
+ * _.flatten(stooges, 'quotes');
2544
+ * // => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!']
2545
+ */
2546
+ function flatten(array, isShallow) {
2547
+ var index = -1,
2548
+ length = array ? array.length : 0,
2549
+ result = [];
2550
+
2551
+ while (++index < length) {
2552
+ var value = array[index];
2553
+ if (isArray(value)) {
2554
+ push.apply(result, isShallow ? value : flatten(value));
2555
+ } else {
2556
+ result.push(value);
2557
+ }
2558
+ }
2559
+ return result;
2560
+ }
2561
+
2562
+ /**
2563
+ * Gets the index at which the first occurrence of `value` is found using
2564
+ * strict equality for comparisons, i.e. `===`. If the `array` is already
2565
+ * sorted, passing `true` for `fromIndex` will run a faster binary search.
2566
+ *
2567
+ * @static
2568
+ * @memberOf _
2569
+ * @category Arrays
2570
+ * @param {Array} array The array to search.
2571
+ * @param {Mixed} value The value to search for.
2572
+ * @param {Boolean|Number} [fromIndex=0] The index to search from or `true` to
2573
+ * perform a binary search on a sorted `array`.
2574
+ * @returns {Number} Returns the index of the matched value or `-1`.
2575
+ * @example
2576
+ *
2577
+ * _.indexOf([1, 2, 3, 1, 2, 3], 2);
2578
+ * // => 1
2579
+ *
2580
+ * _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
2581
+ * // => 4
2582
+ *
2583
+ * _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
2584
+ * // => 2
2585
+ */
2586
+ function indexOf(array, value, fromIndex) {
2587
+ var index = -1,
2588
+ length = array ? array.length : 0;
2589
+
2590
+ if (typeof fromIndex == 'number') {
2591
+ index = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0) - 1;
2592
+ } else if (fromIndex) {
2593
+ index = sortedIndex(array, value);
2594
+ return array[index] === value ? index : -1;
2595
+ }
2596
+ while (++index < length) {
2597
+ if (array[index] === value) {
2598
+ return index;
2599
+ }
2600
+ }
2601
+ return -1;
2602
+ }
2603
+
2604
+ /**
2605
+ * Gets all but the last element of `array`. If a number `n` is passed, the
2606
+ * last `n` elements are excluded from the result. If a `callback` function
2607
+ * is passed, elements at the end of the array are excluded from the result
2608
+ * as long as the `callback` returns truthy. The `callback` is bound to
2609
+ * `thisArg` and invoked with three arguments; (value, index, array).
2610
+ *
2611
+ * If a property name is passed for `callback`, the created "_.pluck" style
2612
+ * callback will return the property value of the given element.
2613
+ *
2614
+ * If an object is passed for `callback`, the created "_.where" style callback
2615
+ * will return `true` for elements that have the properties of the given object,
2616
+ * else `false`.
2617
+ *
2618
+ * @static
2619
+ * @memberOf _
2620
+ * @category Arrays
2621
+ * @param {Array} array The array to query.
2622
+ * @param {Function|Object|Number|String} [callback|n=1] The function called
2623
+ * per element or the number of elements to exclude. If a property name or
2624
+ * object is passed, it will be used to create a "_.pluck" or "_.where"
2625
+ * style callback, respectively.
2626
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2627
+ * @returns {Array} Returns a slice of `array`.
2628
+ * @example
2629
+ *
2630
+ * _.initial([1, 2, 3]);
2631
+ * // => [1, 2]
2632
+ *
2633
+ * _.initial([1, 2, 3], 2);
2634
+ * // => [1]
2635
+ *
2636
+ * _.initial([1, 2, 3], function(num) {
2637
+ * return num > 1;
2638
+ * });
2639
+ * // => [1]
2640
+ *
2641
+ * var food = [
2642
+ * { 'name': 'beet', 'organic': false },
2643
+ * { 'name': 'carrot', 'organic': true }
2644
+ * ];
2645
+ *
2646
+ * // using "_.pluck" callback shorthand
2647
+ * _.initial(food, 'organic');
2648
+ * // => [{ 'name': 'beet', 'organic': false }]
2649
+ *
2650
+ * var food = [
2651
+ * { 'name': 'banana', 'type': 'fruit' },
2652
+ * { 'name': 'beet', 'type': 'vegetable' },
2653
+ * { 'name': 'carrot', 'type': 'vegetable' }
2654
+ * ];
2655
+ *
2656
+ * // using "_.where" callback shorthand
2657
+ * _.initial(food, { 'type': 'vegetable' });
2658
+ * // => [{ 'name': 'banana', 'type': 'fruit' }]
2659
+ */
2660
+ function initial(array, callback, thisArg) {
2661
+ if (!array) {
2662
+ return [];
2663
+ }
2664
+ var n = 0,
2665
+ length = array.length;
2666
+
2667
+ if (typeof callback != 'number' && callback != null) {
2668
+ var index = length;
2669
+ callback = createCallback(callback, thisArg);
2670
+ while (index-- && callback(array[index], index, array)) {
2671
+ n++;
2672
+ }
2673
+ } else {
2674
+ n = (callback == null || thisArg) ? 1 : callback || n;
2675
+ }
2676
+ return slice.call(array, 0, nativeMin(nativeMax(0, length - n), length));
2677
+ }
2678
+
2679
+ /**
2680
+ * Computes the intersection of all the passed-in arrays using strict equality
2681
+ * for comparisons, i.e. `===`.
2682
+ *
2683
+ * @static
2684
+ * @memberOf _
2685
+ * @category Arrays
2686
+ * @param {Array} [array1, array2, ...] Arrays to process.
2687
+ * @returns {Array} Returns a new array of unique elements that are present
2688
+ * in **all** of the arrays.
2689
+ * @example
2690
+ *
2691
+ * _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]);
2692
+ * // => [1, 2]
2693
+ */
2694
+ function intersection(array) {
2695
+ var args = arguments,
2696
+ argsLength = args.length,
2697
+ index = -1,
2698
+ length = array ? array.length : 0,
2699
+ result = [];
2700
+
2701
+ outer:
2702
+ while (++index < length) {
2703
+ var value = array[index];
2704
+ if (indexOf(result, value) < 0) {
2705
+ var argsIndex = argsLength;
2706
+ while (--argsIndex) {
2707
+ if (indexOf(args[argsIndex], value) < 0) {
2708
+ continue outer;
2709
+ }
2710
+ }
2711
+ result.push(value);
2712
+ }
2713
+ }
2714
+ return result;
2715
+ }
2716
+
2717
+ /**
2718
+ * Gets the last element of the `array`. If a number `n` is passed, the
2719
+ * last `n` elements of the `array` are returned. If a `callback` function
2720
+ * is passed, elements at the end of the array are returned as long as the
2721
+ * `callback` returns truthy. The `callback` is bound to `thisArg` and
2722
+ * invoked with three arguments;(value, index, array).
2723
+ *
2724
+ *
2725
+ * If a property name is passed for `callback`, the created "_.pluck" style
2726
+ * callback will return the property value of the given element.
2727
+ *
2728
+ * If an object is passed for `callback`, the created "_.where" style callback
2729
+ * will return `true` for elements that have the properties of the given object,
2730
+ * else `false`.
2731
+ *
2732
+ * @static
2733
+ * @memberOf _
2734
+ * @category Arrays
2735
+ * @param {Array} array The array to query.
2736
+ * @param {Function|Object|Number|String} [callback|n] The function called
2737
+ * per element or the number of elements to return. If a property name or
2738
+ * object is passed, it will be used to create a "_.pluck" or "_.where"
2739
+ * style callback, respectively.
2740
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2741
+ * @returns {Mixed} Returns the last element(s) of `array`.
2742
+ * @example
2743
+ *
2744
+ * _.last([1, 2, 3]);
2745
+ * // => 3
2746
+ *
2747
+ * _.last([1, 2, 3], 2);
2748
+ * // => [2, 3]
2749
+ *
2750
+ * _.last([1, 2, 3], function(num) {
2751
+ * return num > 1;
2752
+ * });
2753
+ * // => [2, 3]
2754
+ *
2755
+ * var food = [
2756
+ * { 'name': 'beet', 'organic': false },
2757
+ * { 'name': 'carrot', 'organic': true }
2758
+ * ];
2759
+ *
2760
+ * // using "_.pluck" callback shorthand
2761
+ * _.last(food, 'organic');
2762
+ * // => [{ 'name': 'carrot', 'organic': true }]
2763
+ *
2764
+ * var food = [
2765
+ * { 'name': 'banana', 'type': 'fruit' },
2766
+ * { 'name': 'beet', 'type': 'vegetable' },
2767
+ * { 'name': 'carrot', 'type': 'vegetable' }
2768
+ * ];
2769
+ *
2770
+ * // using "_.where" callback shorthand
2771
+ * _.last(food, { 'type': 'vegetable' });
2772
+ * // => [{ 'name': 'beet', 'type': 'vegetable' }, { 'name': 'carrot', 'type': 'vegetable' }]
2773
+ */
2774
+ function last(array, callback, thisArg) {
2775
+ if (array) {
2776
+ var n = 0,
2777
+ length = array.length;
2778
+
2779
+ if (typeof callback != 'number' && callback != null) {
2780
+ var index = length;
2781
+ callback = createCallback(callback, thisArg);
2782
+ while (index-- && callback(array[index], index, array)) {
2783
+ n++;
2784
+ }
2785
+ } else {
2786
+ n = callback;
2787
+ if (n == null || thisArg) {
2788
+ return array[length - 1];
2789
+ }
2790
+ }
2791
+ return slice.call(array, nativeMax(0, length - n));
2792
+ }
2793
+ }
2794
+
2795
+ /**
2796
+ * Gets the index at which the last occurrence of `value` is found using strict
2797
+ * equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used
2798
+ * as the offset from the end of the collection.
2799
+ *
2800
+ * @static
2801
+ * @memberOf _
2802
+ * @category Arrays
2803
+ * @param {Array} array The array to search.
2804
+ * @param {Mixed} value The value to search for.
2805
+ * @param {Number} [fromIndex=array.length-1] The index to search from.
2806
+ * @returns {Number} Returns the index of the matched value or `-1`.
2807
+ * @example
2808
+ *
2809
+ * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
2810
+ * // => 4
2811
+ *
2812
+ * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
2813
+ * // => 1
2814
+ */
2815
+ function lastIndexOf(array, value, fromIndex) {
2816
+ var index = array ? array.length : 0;
2817
+ if (typeof fromIndex == 'number') {
2818
+ index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1;
2819
+ }
2820
+ while (index--) {
2821
+ if (array[index] === value) {
2822
+ return index;
2823
+ }
2824
+ }
2825
+ return -1;
2826
+ }
2827
+
2828
+ /**
2829
+ * Creates an array of numbers (positive and/or negative) progressing from
2830
+ * `start` up to but not including `end`.
2831
+ *
2832
+ * @static
2833
+ * @memberOf _
2834
+ * @category Arrays
2835
+ * @param {Number} [start=0] The start of the range.
2836
+ * @param {Number} end The end of the range.
2837
+ * @param {Number} [step=1] The value to increment or decrement by.
2838
+ * @returns {Array} Returns a new range array.
2839
+ * @example
2840
+ *
2841
+ * _.range(10);
2842
+ * // => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2843
+ *
2844
+ * _.range(1, 11);
2845
+ * // => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
2846
+ *
2847
+ * _.range(0, 30, 5);
2848
+ * // => [0, 5, 10, 15, 20, 25]
2849
+ *
2850
+ * _.range(0, -10, -1);
2851
+ * // => [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
2852
+ *
2853
+ * _.range(0);
2854
+ * // => []
2855
+ */
2856
+ function range(start, end, step) {
2857
+ start = +start || 0;
2858
+ step = +step || 1;
2859
+
2860
+ if (end == null) {
2861
+ end = start;
2862
+ start = 0;
2863
+ }
2864
+ // use `Array(length)` so V8 will avoid the slower "dictionary" mode
2865
+ // http://youtu.be/XAqIpGU8ZZk#t=17m25s
2866
+ var index = -1,
2867
+ length = nativeMax(0, ceil((end - start) / step)),
2868
+ result = Array(length);
2869
+
2870
+ while (++index < length) {
2871
+ result[index] = start;
2872
+ start += step;
2873
+ }
2874
+ return result;
2875
+ }
2876
+
2877
+ /**
2878
+ * The opposite of `_.initial`, this method gets all but the first value of
2879
+ * `array`. If a number `n` is passed, the first `n` values are excluded from
2880
+ * the result. If a `callback` function is passed, elements at the beginning
2881
+ * of the array are excluded from the result as long as the `callback` returns
2882
+ * truthy. The `callback` is bound to `thisArg` and invoked with three
2883
+ * arguments; (value, index, array).
2884
+ *
2885
+ * If a property name is passed for `callback`, the created "_.pluck" style
2886
+ * callback will return the property value of the given element.
2887
+ *
2888
+ * If an object is passed for `callback`, the created "_.where" style callback
2889
+ * will return `true` for elements that have the properties of the given object,
2890
+ * else `false`.
2891
+ *
2892
+ * @static
2893
+ * @memberOf _
2894
+ * @alias drop, tail
2895
+ * @category Arrays
2896
+ * @param {Array} array The array to query.
2897
+ * @param {Function|Object|Number|String} [callback|n=1] The function called
2898
+ * per element or the number of elements to exclude. If a property name or
2899
+ * object is passed, it will be used to create a "_.pluck" or "_.where"
2900
+ * style callback, respectively.
2901
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2902
+ * @returns {Array} Returns a slice of `array`.
2903
+ * @example
2904
+ *
2905
+ * _.rest([1, 2, 3]);
2906
+ * // => [2, 3]
2907
+ *
2908
+ * _.rest([1, 2, 3], 2);
2909
+ * // => [3]
2910
+ *
2911
+ * _.rest([1, 2, 3], function(num) {
2912
+ * return num < 3;
2913
+ * });
2914
+ * // => [3]
2915
+ *
2916
+ * var food = [
2917
+ * { 'name': 'banana', 'organic': true },
2918
+ * { 'name': 'beet', 'organic': false },
2919
+ * ];
2920
+ *
2921
+ * // using "_.pluck" callback shorthand
2922
+ * _.rest(food, 'organic');
2923
+ * // => [{ 'name': 'beet', 'organic': false }]
2924
+ *
2925
+ * var food = [
2926
+ * { 'name': 'apple', 'type': 'fruit' },
2927
+ * { 'name': 'banana', 'type': 'fruit' },
2928
+ * { 'name': 'beet', 'type': 'vegetable' }
2929
+ * ];
2930
+ *
2931
+ * // using "_.where" callback shorthand
2932
+ * _.rest(food, { 'type': 'fruit' });
2933
+ * // => [{ 'name': 'beet', 'type': 'vegetable' }]
2934
+ */
2935
+ function rest(array, callback, thisArg) {
2936
+ if (typeof callback != 'number' && callback != null) {
2937
+ var n = 0,
2938
+ index = -1,
2939
+ length = array ? array.length : 0;
2940
+
2941
+ callback = createCallback(callback, thisArg);
2942
+ while (++index < length && callback(array[index], index, array)) {
2943
+ n++;
2944
+ }
2945
+ } else {
2946
+ n = (callback == null || thisArg) ? 1 : nativeMax(0, callback);
2947
+ }
2948
+ return slice.call(array, n);
2949
+ }
2950
+
2951
+ /**
2952
+ * Uses a binary search to determine the smallest index at which the `value`
2953
+ * should be inserted into `array` in order to maintain the sort order of the
2954
+ * sorted `array`. If `callback` is passed, it will be executed for `value` and
2955
+ * each element in `array` to compute their sort ranking. The `callback` is
2956
+ * bound to `thisArg` and invoked with one argument; (value).
2957
+ *
2958
+ * If a property name is passed for `callback`, the created "_.pluck" style
2959
+ * callback will return the property value of the given element.
2960
+ *
2961
+ * If an object is passed for `callback`, the created "_.where" style callback
2962
+ * will return `true` for elements that have the properties of the given object,
2963
+ * else `false`.
2964
+ *
2965
+ * @static
2966
+ * @memberOf _
2967
+ * @category Arrays
2968
+ * @param {Array} array The array to iterate over.
2969
+ * @param {Mixed} value The value to evaluate.
2970
+ * @param {Function|Object|String} [callback=identity] The function called per
2971
+ * iteration. If a property name or object is passed, it will be used to create
2972
+ * a "_.pluck" or "_.where" style callback, respectively.
2973
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
2974
+ * @returns {Number} Returns the index at which the value should be inserted
2975
+ * into `array`.
2976
+ * @example
2977
+ *
2978
+ * _.sortedIndex([20, 30, 50], 40);
2979
+ * // => 2
2980
+ *
2981
+ * // using "_.pluck" callback shorthand
2982
+ * _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
2983
+ * // => 2
2984
+ *
2985
+ * var dict = {
2986
+ * 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 }
2987
+ * };
2988
+ *
2989
+ * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
2990
+ * return dict.wordToNumber[word];
2991
+ * });
2992
+ * // => 2
2993
+ *
2994
+ * _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
2995
+ * return this.wordToNumber[word];
2996
+ * }, dict);
2997
+ * // => 2
2998
+ */
2999
+ function sortedIndex(array, value, callback, thisArg) {
3000
+ var low = 0,
3001
+ high = array ? array.length : low;
3002
+
3003
+ // explicitly reference `identity` for better inlining in Firefox
3004
+ callback = callback ? createCallback(callback, thisArg, 1) : identity;
3005
+ value = callback(value);
3006
+
3007
+ while (low < high) {
3008
+ var mid = (low + high) >>> 1;
3009
+ (callback(array[mid]) < value)
3010
+ ? low = mid + 1
3011
+ : high = mid;
3012
+ }
3013
+ return low;
3014
+ }
3015
+
3016
+ /**
3017
+ * Computes the union of the passed-in arrays using strict equality for
3018
+ * comparisons, i.e. `===`.
3019
+ *
3020
+ * @static
3021
+ * @memberOf _
3022
+ * @category Arrays
3023
+ * @param {Array} [array1, array2, ...] Arrays to process.
3024
+ * @returns {Array} Returns a new array of unique values, in order, that are
3025
+ * present in one or more of the arrays.
3026
+ * @example
3027
+ *
3028
+ * _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]);
3029
+ * // => [1, 2, 3, 101, 10]
3030
+ */
3031
+ function union() {
3032
+ return uniq(concat.apply(arrayRef, arguments));
3033
+ }
3034
+
3035
+ /**
3036
+ * Creates a duplicate-value-free version of the `array` using strict equality
3037
+ * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true`
3038
+ * for `isSorted` will run a faster algorithm. If `callback` is passed, each
3039
+ * element of `array` is passed through a callback` before uniqueness is computed.
3040
+ * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array).
3041
+ *
3042
+ * If a property name is passed for `callback`, the created "_.pluck" style
3043
+ * callback will return the property value of the given element.
3044
+ *
3045
+ * If an object is passed for `callback`, the created "_.where" style callback
3046
+ * will return `true` for elements that have the properties of the given object,
3047
+ * else `false`.
3048
+ *
3049
+ * @static
3050
+ * @memberOf _
3051
+ * @alias unique
3052
+ * @category Arrays
3053
+ * @param {Array} array The array to process.
3054
+ * @param {Boolean} [isSorted=false] A flag to indicate that the `array` is already sorted.
3055
+ * @param {Function|Object|String} [callback=identity] The function called per
3056
+ * iteration. If a property name or object is passed, it will be used to create
3057
+ * a "_.pluck" or "_.where" style callback, respectively.
3058
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
3059
+ * @returns {Array} Returns a duplicate-value-free array.
3060
+ * @example
3061
+ *
3062
+ * _.uniq([1, 2, 1, 3, 1]);
3063
+ * // => [1, 2, 3]
3064
+ *
3065
+ * _.uniq([1, 1, 2, 2, 3], true);
3066
+ * // => [1, 2, 3]
3067
+ *
3068
+ * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); });
3069
+ * // => [1, 2, 3]
3070
+ *
3071
+ * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math);
3072
+ * // => [1, 2, 3]
3073
+ *
3074
+ * // using "_.pluck" callback shorthand
3075
+ * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
3076
+ * // => [{ 'x': 1 }, { 'x': 2 }]
3077
+ */
3078
+ function uniq(array, isSorted, callback, thisArg) {
3079
+ var index = -1,
3080
+ length = array ? array.length : 0,
3081
+ result = [],
3082
+ seen = result;
3083
+
3084
+ if (typeof isSorted != 'boolean' && isSorted != null) {
3085
+ thisArg = callback;
3086
+ callback = isSorted;
3087
+ isSorted = false;
3088
+ }
3089
+ if (callback != null) {
3090
+ seen = [];
3091
+ callback = createCallback(callback, thisArg);
3092
+ }
3093
+ while (++index < length) {
3094
+ var value = array[index],
3095
+ computed = callback ? callback(value, index, array) : value;
3096
+
3097
+ if (isSorted
3098
+ ? !index || seen[seen.length - 1] !== computed
3099
+ : indexOf(seen, computed) < 0
3100
+ ) {
3101
+ if (callback) {
3102
+ seen.push(computed);
3103
+ }
3104
+ result.push(value);
3105
+ }
3106
+ }
3107
+ return result;
3108
+ }
3109
+
3110
+ /**
3111
+ * Creates an array with all occurrences of the passed values removed using
3112
+ * strict equality for comparisons, i.e. `===`.
3113
+ *
3114
+ * @static
3115
+ * @memberOf _
3116
+ * @category Arrays
3117
+ * @param {Array} array The array to filter.
3118
+ * @param {Mixed} [value1, value2, ...] Values to remove.
3119
+ * @returns {Array} Returns a new filtered array.
3120
+ * @example
3121
+ *
3122
+ * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
3123
+ * // => [2, 3, 4]
3124
+ */
3125
+ function without(array) {
3126
+ var index = -1,
3127
+ length = array.length,
3128
+ result = [];
3129
+
3130
+ while (++index < length) {
3131
+ var value = array[index];
3132
+ if (indexOf(arguments, value, 1) < 0) {
3133
+ result.push(value);
3134
+ }
3135
+ }
3136
+ return result
3137
+ }
3138
+
3139
+ /**
3140
+ * Groups the elements of each array at their corresponding indexes. Useful for
3141
+ * separate data sources that are coordinated through matching array indexes.
3142
+ * For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix
3143
+ * in a similar fashion.
3144
+ *
3145
+ * @static
3146
+ * @memberOf _
3147
+ * @category Arrays
3148
+ * @param {Array} [array1, array2, ...] Arrays to process.
3149
+ * @returns {Array} Returns a new array of grouped elements.
3150
+ * @example
3151
+ *
3152
+ * _.zip(['moe', 'larry'], [30, 40], [true, false]);
3153
+ * // => [['moe', 30, true], ['larry', 40, false]]
3154
+ */
3155
+ function zip(array) {
3156
+ var index = -1,
3157
+ length = array ? max(pluck(arguments, 'length')) : 0,
3158
+ result = Array(length);
3159
+
3160
+ while (++index < length) {
3161
+ result[index] = pluck(arguments, index);
3162
+ }
3163
+ return result;
3164
+ }
3165
+
3166
+ /**
3167
+ * Creates an object composed from arrays of `keys` and `values`. Pass either
3168
+ * a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or
3169
+ * two arrays, one of `keys` and one of corresponding `values`.
3170
+ *
3171
+ * @static
3172
+ * @memberOf _
3173
+ * @alias object
3174
+ * @category Arrays
3175
+ * @param {Array} keys The array of keys.
3176
+ * @param {Array} [values=[]] The array of values.
3177
+ * @returns {Object} Returns an object composed of the given keys and
3178
+ * corresponding values.
3179
+ * @example
3180
+ *
3181
+ * _.zipObject(['moe', 'larry'], [30, 40]);
3182
+ * // => { 'moe': 30, 'larry': 40 }
3183
+ */
3184
+ function zipObject(keys, values) {
3185
+ var index = -1,
3186
+ length = keys ? keys.length : 0,
3187
+ result = {};
3188
+
3189
+ while (++index < length) {
3190
+ var key = keys[index];
3191
+ if (values) {
3192
+ result[key] = values[index];
3193
+ } else {
3194
+ result[key[0]] = key[1];
3195
+ }
3196
+ }
3197
+ return result;
3198
+ }
3199
+
3200
+ /*--------------------------------------------------------------------------*/
3201
+
3202
+ /**
3203
+ * If `n` is greater than `0`, a function is created that is restricted to
3204
+ * executing `func`, with the `this` binding and arguments of the created
3205
+ * function, only after it is called `n` times. If `n` is less than `1`,
3206
+ * `func` is executed immediately, without a `this` binding or additional
3207
+ * arguments, and its result is returned.
3208
+ *
3209
+ * @static
3210
+ * @memberOf _
3211
+ * @category Functions
3212
+ * @param {Number} n The number of times the function must be called before
3213
+ * it is executed.
3214
+ * @param {Function} func The function to restrict.
3215
+ * @returns {Function} Returns the new restricted function.
3216
+ * @example
3217
+ *
3218
+ * var renderNotes = _.after(notes.length, render);
3219
+ * _.forEach(notes, function(note) {
3220
+ * note.asyncSave({ 'success': renderNotes });
3221
+ * });
3222
+ * // `renderNotes` is run once, after all notes have saved
3223
+ */
3224
+ function after(n, func) {
3225
+ if (n < 1) {
3226
+ return func();
3227
+ }
3228
+ return function() {
3229
+ if (--n < 1) {
3230
+ return func.apply(this, arguments);
3231
+ }
3232
+ };
3233
+ }
3234
+
3235
+ /**
3236
+ * Creates a function that, when called, invokes `func` with the `this`
3237
+ * binding of `thisArg` and prepends any additional `bind` arguments to those
3238
+ * passed to the bound function.
3239
+ *
3240
+ * @static
3241
+ * @memberOf _
3242
+ * @category Functions
3243
+ * @param {Function} func The function to bind.
3244
+ * @param {Mixed} [thisArg] The `this` binding of `func`.
3245
+ * @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.
3246
+ * @returns {Function} Returns the new bound function.
3247
+ * @example
3248
+ *
3249
+ * var func = function(greeting) {
3250
+ * return greeting + ' ' + this.name;
3251
+ * };
3252
+ *
3253
+ * func = _.bind(func, { 'name': 'moe' }, 'hi');
3254
+ * func();
3255
+ * // => 'hi moe'
3256
+ */
3257
+ function bind(func, thisArg) {
3258
+ // use `Function#bind` if it exists and is fast
3259
+ // (in V8 `Function#bind` is slower except when partially applied)
3260
+ return support.fastBind || (nativeBind && arguments.length > 2)
3261
+ ? nativeBind.call.apply(nativeBind, arguments)
3262
+ : createBound(func, thisArg, slice.call(arguments, 2));
3263
+ }
3264
+
3265
+ /**
3266
+ * Binds methods on `object` to `object`, overwriting the existing method.
3267
+ * Method names may be specified as individual arguments or as arrays of method
3268
+ * names. If no method names are provided, all the function properties of `object`
3269
+ * will be bound.
3270
+ *
3271
+ * @static
3272
+ * @memberOf _
3273
+ * @category Functions
3274
+ * @param {Object} object The object to bind and assign the bound methods to.
3275
+ * @param {String} [methodName1, methodName2, ...] Method names on the object to bind.
3276
+ * @returns {Object} Returns `object`.
3277
+ * @example
3278
+ *
3279
+ * var view = {
3280
+ * 'label': 'docs',
3281
+ * 'onClick': function() { alert('clicked ' + this.label); }
3282
+ * };
3283
+ *
3284
+ * _.bindAll(view);
3285
+ * jQuery('#docs').on('click', view.onClick);
3286
+ * // => alerts 'clicked docs', when the button is clicked
3287
+ */
3288
+ function bindAll(object) {
3289
+ var funcs = concat.apply(arrayRef, arguments),
3290
+ index = funcs.length > 1 ? 0 : (funcs = functions(object), -1),
3291
+ length = funcs.length;
3292
+
3293
+ while (++index < length) {
3294
+ var key = funcs[index];
3295
+ object[key] = bind(object[key], object);
3296
+ }
3297
+ return object;
3298
+ }
3299
+
3300
+ /**
3301
+ * Creates a function that is the composition of the passed functions,
3302
+ * where each function consumes the return value of the function that follows.
3303
+ * For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`.
3304
+ * Each function is executed with the `this` binding of the composed function.
3305
+ *
3306
+ * @static
3307
+ * @memberOf _
3308
+ * @category Functions
3309
+ * @param {Function} [func1, func2, ...] Functions to compose.
3310
+ * @returns {Function} Returns the new composed function.
3311
+ * @example
3312
+ *
3313
+ * var greet = function(name) { return 'hi ' + name; };
3314
+ * var exclaim = function(statement) { return statement + '!'; };
3315
+ * var welcome = _.compose(exclaim, greet);
3316
+ * welcome('moe');
3317
+ * // => 'hi moe!'
3318
+ */
3319
+ function compose() {
3320
+ var funcs = arguments;
3321
+ return function() {
3322
+ var args = arguments,
3323
+ length = funcs.length;
3324
+
3325
+ while (length--) {
3326
+ args = [funcs[length].apply(this, args)];
3327
+ }
3328
+ return args[0];
3329
+ };
3330
+ }
3331
+
3332
+ /**
3333
+ * Produces a callback bound to an optional `thisArg`. If `func` is a property
3334
+ * name, the created callback will return the property value for a given element.
3335
+ * If `func` is an object, the created callback will return `true` for elements
3336
+ * that contain the equivalent object properties, otherwise it will return `false`.
3337
+ *
3338
+ * Note: All Lo-Dash methods, that accept a `callback` argument, use `_.createCallback`.
3339
+ *
3340
+ * @static
3341
+ * @memberOf _
3342
+ * @category Functions
3343
+ * @param {Mixed} [func=identity] The value to convert to a callback.
3344
+ * @param {Mixed} [thisArg] The `this` binding of the created callback.
3345
+ * @param {Number} [argCount=3] The number of arguments the callback accepts.
3346
+ * @returns {Function} Returns a callback function.
3347
+ * @example
3348
+ *
3349
+ * var stooges = [
3350
+ * { 'name': 'moe', 'age': 40 },
3351
+ * { 'name': 'larry', 'age': 50 }
3352
+ * ];
3353
+ *
3354
+ * // wrap to create custom callback shorthands
3355
+ * _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
3356
+ * var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
3357
+ * return !match ? func(callback, thisArg) : function(object) {
3358
+ * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
3359
+ * };
3360
+ * });
3361
+ *
3362
+ * _.filter(stooges, 'age__gt45');
3363
+ * // => [{ 'name': 'larry', 'age': 50 }]
3364
+ *
3365
+ * // create mixins with support for "_.pluck" and "_.where" callback shorthands
3366
+ * _.mixin({
3367
+ * 'toLookup': function(collection, callback, thisArg) {
3368
+ * callback = _.createCallback(callback, thisArg);
3369
+ * return _.reduce(collection, function(result, value, index, collection) {
3370
+ * return (result[callback(value, index, collection)] = value, result);
3371
+ * }, {});
3372
+ * }
3373
+ * });
3374
+ *
3375
+ * _.toLookup(stooges, 'name');
3376
+ * // => { 'moe': { 'name': 'moe', 'age': 40 }, 'larry': { 'name': 'larry', 'age': 50 } }
3377
+ */
3378
+ function createCallback(func, thisArg, argCount) {
3379
+ if (func == null) {
3380
+ return identity;
3381
+ }
3382
+ var type = typeof func;
3383
+ if (type != 'function') {
3384
+ if (type != 'object') {
3385
+ return function(object) {
3386
+ return object[func];
3387
+ };
3388
+ }
3389
+ var props = keys(func);
3390
+ return function(object) {
3391
+ var length = props.length,
3392
+ result = false;
3393
+ while (length--) {
3394
+ if (!(result = object[props[length]] === func[props[length]])) {
3395
+ break;
3396
+ }
3397
+ }
3398
+ return result;
3399
+ };
3400
+ }
3401
+ if (typeof thisArg != 'undefined') {
3402
+ if (argCount === 1) {
3403
+ return function(value) {
3404
+ return func.call(thisArg, value);
3405
+ };
3406
+ }
3407
+ if (argCount === 2) {
3408
+ return function(a, b) {
3409
+ return func.call(thisArg, a, b);
3410
+ };
3411
+ }
3412
+ if (argCount === 4) {
3413
+ return function(accumulator, value, index, collection) {
3414
+ return func.call(thisArg, accumulator, value, index, collection);
3415
+ };
3416
+ }
3417
+ return function(value, index, collection) {
3418
+ return func.call(thisArg, value, index, collection);
3419
+ };
3420
+ }
3421
+ return func;
3422
+ }
3423
+
3424
+ /**
3425
+ * Creates a function that will delay the execution of `func` until after
3426
+ * `wait` milliseconds have elapsed since the last time it was invoked. Pass
3427
+ * `true` for `immediate` to cause debounce to invoke `func` on the leading,
3428
+ * instead of the trailing, edge of the `wait` timeout. Subsequent calls to
3429
+ * the debounced function will return the result of the last `func` call.
3430
+ *
3431
+ * @static
3432
+ * @memberOf _
3433
+ * @category Functions
3434
+ * @param {Function} func The function to debounce.
3435
+ * @param {Number} wait The number of milliseconds to delay.
3436
+ * @param {Boolean} immediate A flag to indicate execution is on the leading
3437
+ * edge of the timeout.
3438
+ * @returns {Function} Returns the new debounced function.
3439
+ * @example
3440
+ *
3441
+ * var lazyLayout = _.debounce(calculateLayout, 300);
3442
+ * jQuery(window).on('resize', lazyLayout);
3443
+ */
3444
+ function debounce(func, wait, immediate) {
3445
+ var args,
3446
+ result,
3447
+ thisArg,
3448
+ timeoutId;
3449
+
3450
+ function delayed() {
3451
+ timeoutId = null;
3452
+ if (!immediate) {
3453
+ result = func.apply(thisArg, args);
3454
+ }
3455
+ }
3456
+ return function() {
3457
+ var isImmediate = immediate && !timeoutId;
3458
+ args = arguments;
3459
+ thisArg = this;
3460
+
3461
+ clearTimeout(timeoutId);
3462
+ timeoutId = setTimeout(delayed, wait);
3463
+
3464
+ if (isImmediate) {
3465
+ result = func.apply(thisArg, args);
3466
+ }
3467
+ return result;
3468
+ };
3469
+ }
3470
+
3471
+ /**
3472
+ * Defers executing the `func` function until the current call stack has cleared.
3473
+ * Additional arguments will be passed to `func` when it is invoked.
3474
+ *
3475
+ * @static
3476
+ * @memberOf _
3477
+ * @category Functions
3478
+ * @param {Function} func The function to defer.
3479
+ * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the function with.
3480
+ * @returns {Number} Returns the timer id.
3481
+ * @example
3482
+ *
3483
+ * _.defer(function() { alert('deferred'); });
3484
+ * // returns from the function before `alert` is called
3485
+ */
3486
+ function defer(func) {
3487
+ var args = slice.call(arguments, 1);
3488
+ return setTimeout(function() { func.apply(undefined, args); }, 1);
3489
+ }
3490
+
3491
+ /**
3492
+ * Executes the `func` function after `wait` milliseconds. Additional arguments
3493
+ * will be passed to `func` when it is invoked.
3494
+ *
3495
+ * @static
3496
+ * @memberOf _
3497
+ * @category Functions
3498
+ * @param {Function} func The function to delay.
3499
+ * @param {Number} wait The number of milliseconds to delay execution.
3500
+ * @param {Mixed} [arg1, arg2, ...] Arguments to invoke the function with.
3501
+ * @returns {Number} Returns the timer id.
3502
+ * @example
3503
+ *
3504
+ * var log = _.bind(console.log, console);
3505
+ * _.delay(log, 1000, 'logged later');
3506
+ * // => 'logged later' (Appears after one second.)
3507
+ */
3508
+ function delay(func, wait) {
3509
+ var args = slice.call(arguments, 2);
3510
+ return setTimeout(function() { func.apply(undefined, args); }, wait);
3511
+ }
3512
+
3513
+ /**
3514
+ * Creates a function that memoizes the result of `func`. If `resolver` is
3515
+ * passed, it will be used to determine the cache key for storing the result
3516
+ * based on the arguments passed to the memoized function. By default, the first
3517
+ * argument passed to the memoized function is used as the cache key. The `func`
3518
+ * is executed with the `this` binding of the memoized function.
3519
+ *
3520
+ * @static
3521
+ * @memberOf _
3522
+ * @category Functions
3523
+ * @param {Function} func The function to have its output memoized.
3524
+ * @param {Function} [resolver] A function used to resolve the cache key.
3525
+ * @returns {Function} Returns the new memoizing function.
3526
+ * @example
3527
+ *
3528
+ * var fibonacci = _.memoize(function(n) {
3529
+ * return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
3530
+ * });
3531
+ */
3532
+ function memoize(func, resolver) {
3533
+ var cache = {};
3534
+ return function() {
3535
+ var key = String(resolver ? resolver.apply(this, arguments) : arguments[0]);
3536
+ return hasOwnProperty.call(cache, key)
3537
+ ? cache[key]
3538
+ : (cache[key] = func.apply(this, arguments));
3539
+ };
3540
+ }
3541
+
3542
+ /**
3543
+ * Creates a function that is restricted to execute `func` once. Repeat calls to
3544
+ * the function will return the value of the first call. The `func` is executed
3545
+ * with the `this` binding of the created function.
3546
+ *
3547
+ * @static
3548
+ * @memberOf _
3549
+ * @category Functions
3550
+ * @param {Function} func The function to restrict.
3551
+ * @returns {Function} Returns the new restricted function.
3552
+ * @example
3553
+ *
3554
+ * var initialize = _.once(createApplication);
3555
+ * initialize();
3556
+ * initialize();
3557
+ * // `initialize` executes `createApplication` once
3558
+ */
3559
+ function once(func) {
3560
+ var ran,
3561
+ result;
3562
+
3563
+ return function() {
3564
+ if (ran) {
3565
+ return result;
3566
+ }
3567
+ ran = true;
3568
+ result = func.apply(this, arguments);
3569
+
3570
+ // clear the `func` variable so the function may be garbage collected
3571
+ func = null;
3572
+ return result;
3573
+ };
3574
+ }
3575
+
3576
+ /**
3577
+ * Creates a function that, when called, invokes `func` with any additional
3578
+ * `partial` arguments prepended to those passed to the new function. This
3579
+ * method is similar to `_.bind`, except it does **not** alter the `this` binding.
3580
+ *
3581
+ * @static
3582
+ * @memberOf _
3583
+ * @category Functions
3584
+ * @param {Function} func The function to partially apply arguments to.
3585
+ * @param {Mixed} [arg1, arg2, ...] Arguments to be partially applied.
3586
+ * @returns {Function} Returns the new partially applied function.
3587
+ * @example
3588
+ *
3589
+ * var greet = function(greeting, name) { return greeting + ' ' + name; };
3590
+ * var hi = _.partial(greet, 'hi');
3591
+ * hi('moe');
3592
+ * // => 'hi moe'
3593
+ */
3594
+ function partial(func) {
3595
+ return createBound(func, slice.call(arguments, 1));
3596
+ }
3597
+
3598
+ /**
3599
+ * Creates a function that, when executed, will only call the `func`
3600
+ * function at most once per every `wait` milliseconds. If the throttled
3601
+ * function is invoked more than once during the `wait` timeout, `func` will
3602
+ * also be called on the trailing edge of the timeout. Subsequent calls to the
3603
+ * throttled function will return the result of the last `func` call.
3604
+ *
3605
+ * @static
3606
+ * @memberOf _
3607
+ * @category Functions
3608
+ * @param {Function} func The function to throttle.
3609
+ * @param {Number} wait The number of milliseconds to throttle executions to.
3610
+ * @returns {Function} Returns the new throttled function.
3611
+ * @example
3612
+ *
3613
+ * var throttled = _.throttle(updatePosition, 100);
3614
+ * jQuery(window).on('scroll', throttled);
3615
+ */
3616
+ function throttle(func, wait) {
3617
+ var args,
3618
+ result,
3619
+ thisArg,
3620
+ timeoutId,
3621
+ lastCalled = 0;
3622
+
3623
+ function trailingCall() {
3624
+ lastCalled = new Date;
3625
+ timeoutId = null;
3626
+ result = func.apply(thisArg, args);
3627
+ }
3628
+ return function() {
3629
+ var now = new Date,
3630
+ remaining = wait - (now - lastCalled);
3631
+
3632
+ args = arguments;
3633
+ thisArg = this;
3634
+
3635
+ if (remaining <= 0) {
3636
+ clearTimeout(timeoutId);
3637
+ timeoutId = null;
3638
+ lastCalled = now;
3639
+ result = func.apply(thisArg, args);
3640
+ }
3641
+ else if (!timeoutId) {
3642
+ timeoutId = setTimeout(trailingCall, remaining);
3643
+ }
3644
+ return result;
3645
+ };
3646
+ }
3647
+
3648
+ /**
3649
+ * Creates a function that passes `value` to the `wrapper` function as its
3650
+ * first argument. Additional arguments passed to the function are appended
3651
+ * to those passed to the `wrapper` function. The `wrapper` is executed with
3652
+ * the `this` binding of the created function.
3653
+ *
3654
+ * @static
3655
+ * @memberOf _
3656
+ * @category Functions
3657
+ * @param {Mixed} value The value to wrap.
3658
+ * @param {Function} wrapper The wrapper function.
3659
+ * @returns {Function} Returns the new function.
3660
+ * @example
3661
+ *
3662
+ * var hello = function(name) { return 'hello ' + name; };
3663
+ * hello = _.wrap(hello, function(func) {
3664
+ * return 'before, ' + func('moe') + ', after';
3665
+ * });
3666
+ * hello();
3667
+ * // => 'before, hello moe, after'
3668
+ */
3669
+ function wrap(value, wrapper) {
3670
+ return function() {
3671
+ var args = [value];
3672
+ push.apply(args, arguments);
3673
+ return wrapper.apply(this, args);
3674
+ };
3675
+ }
3676
+
3677
+ /*--------------------------------------------------------------------------*/
3678
+
3679
+ /**
3680
+ * Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their
3681
+ * corresponding HTML entities.
3682
+ *
3683
+ * @static
3684
+ * @memberOf _
3685
+ * @category Utilities
3686
+ * @param {String} string The string to escape.
3687
+ * @returns {String} Returns the escaped string.
3688
+ * @example
3689
+ *
3690
+ * _.escape('Moe, Larry & Curly');
3691
+ * // => 'Moe, Larry &amp; Curly'
3692
+ */
3693
+ function escape(string) {
3694
+ return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar);
3695
+ }
3696
+
3697
+ /**
3698
+ * This function returns the first argument passed to it.
3699
+ *
3700
+ * @static
3701
+ * @memberOf _
3702
+ * @category Utilities
3703
+ * @param {Mixed} value Any value.
3704
+ * @returns {Mixed} Returns `value`.
3705
+ * @example
3706
+ *
3707
+ * var moe = { 'name': 'moe' };
3708
+ * moe === _.identity(moe);
3709
+ * // => true
3710
+ */
3711
+ function identity(value) {
3712
+ return value;
3713
+ }
3714
+
3715
+ /**
3716
+ * Adds functions properties of `object` to the `lodash` function and chainable
3717
+ * wrapper.
3718
+ *
3719
+ * @static
3720
+ * @memberOf _
3721
+ * @category Utilities
3722
+ * @param {Object} object The object of function properties to add to `lodash`.
3723
+ * @example
3724
+ *
3725
+ * _.mixin({
3726
+ * 'capitalize': function(string) {
3727
+ * return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
3728
+ * }
3729
+ * });
3730
+ *
3731
+ * _.capitalize('moe');
3732
+ * // => 'Moe'
3733
+ *
3734
+ * _('moe').capitalize();
3735
+ * // => 'Moe'
3736
+ */
3737
+ function mixin(object) {
3738
+ forEach(functions(object), function(methodName) {
3739
+ var func = lodash[methodName] = object[methodName];
3740
+
3741
+ lodash.prototype[methodName] = function() {
3742
+ var args = [this.__wrapped__];
3743
+ push.apply(args, arguments);
3744
+
3745
+ var result = func.apply(lodash, args);
3746
+ if (this.__chain__) {
3747
+ result = new lodashWrapper(result);
3748
+ result.__chain__ = true;
3749
+ }
3750
+ return result;
3751
+ };
3752
+ });
3753
+ }
3754
+
3755
+ /**
3756
+ * Reverts the '_' variable to its previous value and returns a reference to
3757
+ * the `lodash` function.
3758
+ *
3759
+ * @static
3760
+ * @memberOf _
3761
+ * @category Utilities
3762
+ * @returns {Function} Returns the `lodash` function.
3763
+ * @example
3764
+ *
3765
+ * var lodash = _.noConflict();
3766
+ */
3767
+ function noConflict() {
3768
+ window._ = oldDash;
3769
+ return this;
3770
+ }
3771
+
3772
+ /**
3773
+ * Produces a random number between `min` and `max` (inclusive). If only one
3774
+ * argument is passed, a number between `0` and the given number will be returned.
3775
+ *
3776
+ * @static
3777
+ * @memberOf _
3778
+ * @category Utilities
3779
+ * @param {Number} [min=0] The minimum possible value.
3780
+ * @param {Number} [max=1] The maximum possible value.
3781
+ * @returns {Number} Returns a random number.
3782
+ * @example
3783
+ *
3784
+ * _.random(0, 5);
3785
+ * // => a number between 0 and 5
3786
+ *
3787
+ * _.random(5);
3788
+ * // => also a number between 0 and 5
3789
+ */
3790
+ function random(min, max) {
3791
+ if (min == null && max == null) {
3792
+ max = 1;
3793
+ }
3794
+ min = +min || 0;
3795
+ if (max == null) {
3796
+ max = min;
3797
+ min = 0;
3798
+ }
3799
+ return min + floor(nativeRandom() * ((+max || 0) - min + 1));
3800
+ }
3801
+
3802
+ /**
3803
+ * Resolves the value of `property` on `object`. If `property` is a function,
3804
+ * it will be invoked with the `this` binding of `object` and its result returned,
3805
+ * else the property value is returned. If `object` is falsey, then `undefined`
3806
+ * is returned.
3807
+ *
3808
+ * @static
3809
+ * @memberOf _
3810
+ * @category Utilities
3811
+ * @param {Object} object The object to inspect.
3812
+ * @param {String} property The property to get the value of.
3813
+ * @returns {Mixed} Returns the resolved value.
3814
+ * @example
3815
+ *
3816
+ * var object = {
3817
+ * 'cheese': 'crumpets',
3818
+ * 'stuff': function() {
3819
+ * return 'nonsense';
3820
+ * }
3821
+ * };
3822
+ *
3823
+ * _.result(object, 'cheese');
3824
+ * // => 'crumpets'
3825
+ *
3826
+ * _.result(object, 'stuff');
3827
+ * // => 'nonsense'
3828
+ */
3829
+ function result(object, property) {
3830
+ var value = object ? object[property] : null;
3831
+ return isFunction(value) ? object[property]() : value;
3832
+ }
3833
+
3834
+ /**
3835
+ * A micro-templating method that handles arbitrary delimiters, preserves
3836
+ * whitespace, and correctly escapes quotes within interpolated code.
3837
+ *
3838
+ * Note: In the development build, `_.template` utilizes sourceURLs for easier
3839
+ * debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
3840
+ *
3841
+ * Note: Lo-Dash may be used in Chrome extensions by either creating a `lodash csp`
3842
+ * build and using precompiled templates, or loading Lo-Dash in a sandbox.
3843
+ *
3844
+ * For more information on precompiling templates see:
3845
+ * http://lodash.com/#custom-builds
3846
+ *
3847
+ * For more information on Chrome extension sandboxes see:
3848
+ * http://developer.chrome.com/stable/extensions/sandboxingEval.html
3849
+ *
3850
+ * @static
3851
+ * @memberOf _
3852
+ * @category Utilities
3853
+ * @param {String} text The template text.
3854
+ * @param {Obect} data The data object used to populate the text.
3855
+ * @param {Object} options The options object.
3856
+ * escape - The "escape" delimiter regexp.
3857
+ * evaluate - The "evaluate" delimiter regexp.
3858
+ * interpolate - The "interpolate" delimiter regexp.
3859
+ * sourceURL - The sourceURL of the template's compiled source.
3860
+ * variable - The data object variable name.
3861
+ * @returns {Function|String} Returns a compiled function when no `data` object
3862
+ * is given, else it returns the interpolated text.
3863
+ * @example
3864
+ *
3865
+ * // using a compiled template
3866
+ * var compiled = _.template('hello <%= name %>');
3867
+ * compiled({ 'name': 'moe' });
3868
+ * // => 'hello moe'
3869
+ *
3870
+ * var list = '<% _.forEach(people, function(name) { %><li><%= name %></li><% }); %>';
3871
+ * _.template(list, { 'people': ['moe', 'larry'] });
3872
+ * // => '<li>moe</li><li>larry</li>'
3873
+ *
3874
+ * // using the "escape" delimiter to escape HTML in data property values
3875
+ * _.template('<b><%- value %></b>', { 'value': '<script>' });
3876
+ * // => '<b>&lt;script&gt;</b>'
3877
+ *
3878
+ * // using the ES6 delimiter as an alternative to the default "interpolate" delimiter
3879
+ * _.template('hello ${ name }', { 'name': 'curly' });
3880
+ * // => 'hello curly'
3881
+ *
3882
+ * // using the internal `print` function in "evaluate" delimiters
3883
+ * _.template('<% print("hello " + epithet); %>!', { 'epithet': 'stooge' });
3884
+ * // => 'hello stooge!'
3885
+ *
3886
+ * // using custom template delimiters
3887
+ * _.templateSettings = {
3888
+ * 'interpolate': /{{([\s\S]+?)}}/g
3889
+ * };
3890
+ *
3891
+ * _.template('hello {{ name }}!', { 'name': 'mustache' });
3892
+ * // => 'hello mustache!'
3893
+ *
3894
+ * // using the `sourceURL` option to specify a custom sourceURL for the template
3895
+ * var compiled = _.template('hello <%= name %>', null, { 'sourceURL': '/basic/greeting.jst' });
3896
+ * compiled(data);
3897
+ * // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector
3898
+ *
3899
+ * // using the `variable` option to ensure a with-statement isn't used in the compiled template
3900
+ * var compiled = _.template('hi <%= data.name %>!', null, { 'variable': 'data' });
3901
+ * compiled.source;
3902
+ * // => function(data) {
3903
+ * var __t, __p = '', __e = _.escape;
3904
+ * __p += 'hi ' + ((__t = ( data.name )) == null ? '' : __t) + '!';
3905
+ * return __p;
3906
+ * }
3907
+ *
3908
+ * // using the `source` property to inline compiled templates for meaningful
3909
+ * // line numbers in error messages and a stack trace
3910
+ * fs.writeFileSync(path.join(cwd, 'jst.js'), '\
3911
+ * var JST = {\
3912
+ * "main": ' + _.template(mainText).source + '\
3913
+ * };\
3914
+ * ');
3915
+ */
3916
+ function template(text, data, options) {
3917
+ text || (text = '');
3918
+ options = defaults({}, options, lodash.templateSettings);
3919
+
3920
+ var index = 0,
3921
+ source = "__p += '",
3922
+ variable = options.variable;
3923
+
3924
+ var reDelimiters = RegExp(
3925
+ (options.escape || reNoMatch).source + '|' +
3926
+ (options.interpolate || reNoMatch).source + '|' +
3927
+ (options.evaluate || reNoMatch).source + '|$'
3928
+ , 'g');
3929
+
3930
+ text.replace(reDelimiters, function(match, escapeValue, interpolateValue, evaluateValue, offset) {
3931
+ source += text.slice(index, offset).replace(reUnescapedString, escapeStringChar);
3932
+ if (escapeValue) {
3933
+ source += "' +\n_.escape(" + escapeValue + ") +\n'";
3934
+ }
3935
+ if (evaluateValue) {
3936
+ source += "';\n" + evaluateValue + ";\n__p += '";
3937
+ }
3938
+ if (interpolateValue) {
3939
+ source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
3940
+ }
3941
+ index = offset + match.length;
3942
+ return match;
3943
+ });
3944
+
3945
+ source += "';\n";
3946
+ if (!variable) {
3947
+ variable = 'obj';
3948
+ source = 'with (' + variable + ' || {}) {\n' + source + '\n}\n';
3949
+ }
3950
+ source = 'function(' + variable + ') {\n' +
3951
+ "var __t, __p = '', __j = Array.prototype.join;\n" +
3952
+ "function print() { __p += __j.call(arguments, '') }\n" +
3953
+ source +
3954
+ 'return __p\n}';
3955
+
3956
+ try {
3957
+ var result = Function('_', 'return ' + source)(lodash);
3958
+ } catch(e) {
3959
+ e.source = source;
3960
+ throw e;
3961
+ }
3962
+ if (data) {
3963
+ return result(data);
3964
+ }
3965
+ result.source = source;
3966
+ return result;
3967
+ }
3968
+
3969
+ /**
3970
+ * Executes the `callback` function `n` times, returning an array of the results
3971
+ * of each `callback` execution. The `callback` is bound to `thisArg` and invoked
3972
+ * with one argument; (index).
3973
+ *
3974
+ * @static
3975
+ * @memberOf _
3976
+ * @category Utilities
3977
+ * @param {Number} n The number of times to execute the callback.
3978
+ * @param {Function} callback The function called per iteration.
3979
+ * @param {Mixed} [thisArg] The `this` binding of `callback`.
3980
+ * @returns {Array} Returns a new array of the results of each `callback` execution.
3981
+ * @example
3982
+ *
3983
+ * var diceRolls = _.times(3, _.partial(_.random, 1, 6));
3984
+ * // => [3, 6, 4]
3985
+ *
3986
+ * _.times(3, function(n) { mage.castSpell(n); });
3987
+ * // => calls `mage.castSpell(n)` three times, passing `n` of `0`, `1`, and `2` respectively
3988
+ *
3989
+ * _.times(3, function(n) { this.cast(n); }, mage);
3990
+ * // => also calls `mage.castSpell(n)` three times
3991
+ */
3992
+ function times(n, callback, thisArg) {
3993
+ var index = -1,
3994
+ result = Array(n > -1 ? n : 0);
3995
+
3996
+ while (++index < n) {
3997
+ result[index] = callback.call(thisArg, index);
3998
+ }
3999
+ return result;
4000
+ }
4001
+
4002
+ /**
4003
+ * The opposite of `_.escape`, this method converts the HTML entities
4004
+ * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to their
4005
+ * corresponding characters.
4006
+ *
4007
+ * @static
4008
+ * @memberOf _
4009
+ * @category Utilities
4010
+ * @param {String} string The string to unescape.
4011
+ * @returns {String} Returns the unescaped string.
4012
+ * @example
4013
+ *
4014
+ * _.unescape('Moe, Larry &amp; Curly');
4015
+ * // => 'Moe, Larry & Curly'
4016
+ */
4017
+ function unescape(string) {
4018
+ return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar);
4019
+ }
4020
+
4021
+ /**
4022
+ * Generates a unique ID. If `prefix` is passed, the ID will be appended to it.
4023
+ *
4024
+ * @static
4025
+ * @memberOf _
4026
+ * @category Utilities
4027
+ * @param {String} [prefix] The value to prefix the ID with.
4028
+ * @returns {String} Returns the unique ID.
4029
+ * @example
4030
+ *
4031
+ * _.uniqueId('contact_');
4032
+ * // => 'contact_104'
4033
+ *
4034
+ * _.uniqueId();
4035
+ * // => '105'
4036
+ */
4037
+ function uniqueId(prefix) {
4038
+ var id = ++idCounter + '';
4039
+ return prefix ? prefix + id : id;
4040
+ }
4041
+
4042
+ /*--------------------------------------------------------------------------*/
4043
+
4044
+ /**
4045
+ * Creates a `lodash` object that wraps the given `value`.
4046
+ *
4047
+ * @static
4048
+ * @memberOf _
4049
+ * @category Chaining
4050
+ * @param {Mixed} value The value to wrap.
4051
+ * @returns {Object} Returns the wrapper object.
4052
+ * @example
4053
+ *
4054
+ * var stooges = [
4055
+ * { 'name': 'moe', 'age': 40 },
4056
+ * { 'name': 'larry', 'age': 50 },
4057
+ * { 'name': 'curly', 'age': 60 }
4058
+ * ];
4059
+ *
4060
+ * var youngest = _.chain(stooges)
4061
+ * .sortBy(function(stooge) { return stooge.age; })
4062
+ * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; })
4063
+ * .first();
4064
+ * // => 'moe is 40'
4065
+ */
4066
+ function chain(value) {
4067
+ value = new lodashWrapper(value);
4068
+ value.__chain__ = true;
4069
+ return value;
4070
+ }
4071
+
4072
+ /**
4073
+ * Invokes `interceptor` with the `value` as the first argument, and then
4074
+ * returns `value`. The purpose of this method is to "tap into" a method chain,
4075
+ * in order to perform operations on intermediate results within the chain.
4076
+ *
4077
+ * @static
4078
+ * @memberOf _
4079
+ * @category Chaining
4080
+ * @param {Mixed} value The value to pass to `interceptor`.
4081
+ * @param {Function} interceptor The function to invoke.
4082
+ * @returns {Mixed} Returns `value`.
4083
+ * @example
4084
+ *
4085
+ * _([1, 2, 3, 4])
4086
+ * .filter(function(num) { return num % 2 == 0; })
4087
+ * .tap(alert)
4088
+ * .map(function(num) { return num * num; })
4089
+ * .value();
4090
+ * // => // [2, 4] (alerted)
4091
+ * // => [4, 16]
4092
+ */
4093
+ function tap(value, interceptor) {
4094
+ interceptor(value);
4095
+ return value;
4096
+ }
4097
+
4098
+ /**
4099
+ * Enables method chaining on the wrapper object.
4100
+ *
4101
+ * @name chain
4102
+ * @memberOf _
4103
+ * @category Chaining
4104
+ * @returns {Mixed} Returns the wrapper object.
4105
+ * @example
4106
+ *
4107
+ * var sum = _([1, 2, 3])
4108
+ * .chain()
4109
+ * .reduce(function(sum, num) { return sum + num; })
4110
+ * .value()
4111
+ * // => 6`
4112
+ */
4113
+ function wrapperChain() {
4114
+ this.__chain__ = true;
4115
+ return this;
4116
+ }
4117
+
4118
+ /**
4119
+ * Produces the `toString` result of the wrapped value.
4120
+ *
4121
+ * @name toString
4122
+ * @memberOf _
4123
+ * @category Chaining
4124
+ * @returns {String} Returns the string result.
4125
+ * @example
4126
+ *
4127
+ * _([1, 2, 3]).toString();
4128
+ * // => '1,2,3'
4129
+ */
4130
+ function wrapperToString() {
4131
+ return String(this.__wrapped__);
4132
+ }
4133
+
4134
+ /**
4135
+ * Extracts the wrapped value.
4136
+ *
4137
+ * @name valueOf
4138
+ * @memberOf _
4139
+ * @alias value
4140
+ * @category Chaining
4141
+ * @returns {Mixed} Returns the wrapped value.
4142
+ * @example
4143
+ *
4144
+ * _([1, 2, 3]).valueOf();
4145
+ * // => [1, 2, 3]
4146
+ */
4147
+ function wrapperValueOf() {
4148
+ return this.__wrapped__;
4149
+ }
4150
+
4151
+ /*--------------------------------------------------------------------------*/
4152
+
4153
+ // add functions that return wrapped values when chaining
4154
+ lodash.after = after;
4155
+ lodash.bind = bind;
4156
+ lodash.bindAll = bindAll;
4157
+ lodash.compact = compact;
4158
+ lodash.compose = compose;
4159
+ lodash.countBy = countBy;
4160
+ lodash.debounce = debounce;
4161
+ lodash.defaults = defaults;
4162
+ lodash.defer = defer;
4163
+ lodash.delay = delay;
4164
+ lodash.difference = difference;
4165
+ lodash.filter = filter;
4166
+ lodash.flatten = flatten;
4167
+ lodash.forEach = forEach;
4168
+ lodash.functions = functions;
4169
+ lodash.groupBy = groupBy;
4170
+ lodash.initial = initial;
4171
+ lodash.intersection = intersection;
4172
+ lodash.invert = invert;
4173
+ lodash.invoke = invoke;
4174
+ lodash.keys = keys;
4175
+ lodash.map = map;
4176
+ lodash.max = max;
4177
+ lodash.memoize = memoize;
4178
+ lodash.min = min;
4179
+ lodash.omit = omit;
4180
+ lodash.once = once;
4181
+ lodash.pairs = pairs;
4182
+ lodash.partial = partial;
4183
+ lodash.pick = pick;
4184
+ lodash.pluck = pluck;
4185
+ lodash.range = range;
4186
+ lodash.reject = reject;
4187
+ lodash.rest = rest;
4188
+ lodash.shuffle = shuffle;
4189
+ lodash.sortBy = sortBy;
4190
+ lodash.tap = tap;
4191
+ lodash.throttle = throttle;
4192
+ lodash.times = times;
4193
+ lodash.toArray = toArray;
4194
+ lodash.union = union;
4195
+ lodash.uniq = uniq;
4196
+ lodash.values = values;
4197
+ lodash.where = where;
4198
+ lodash.without = without;
4199
+ lodash.wrap = wrap;
4200
+ lodash.zip = zip;
4201
+
4202
+ // add aliases
4203
+ lodash.collect = map;
4204
+ lodash.drop = rest;
4205
+ lodash.each = forEach;
4206
+ lodash.extend = assign;
4207
+ lodash.methods = functions;
4208
+ lodash.object = zipObject;
4209
+ lodash.select = filter;
4210
+ lodash.tail = rest;
4211
+ lodash.unique = uniq;
4212
+
4213
+ /*--------------------------------------------------------------------------*/
4214
+
4215
+ // add functions that return unwrapped values when chaining
4216
+ lodash.clone = clone;
4217
+ lodash.contains = contains;
4218
+ lodash.escape = escape;
4219
+ lodash.every = every;
4220
+ lodash.find = find;
4221
+ lodash.findWhere = findWhere;
4222
+ lodash.has = has;
4223
+ lodash.identity = identity;
4224
+ lodash.indexOf = indexOf;
4225
+ lodash.isArguments = isArguments;
4226
+ lodash.isArray = isArray;
4227
+ lodash.isBoolean = isBoolean;
4228
+ lodash.isDate = isDate;
4229
+ lodash.isElement = isElement;
4230
+ lodash.isEmpty = isEmpty;
4231
+ lodash.isEqual = isEqual;
4232
+ lodash.isFinite = isFinite;
4233
+ lodash.isFunction = isFunction;
4234
+ lodash.isNaN = isNaN;
4235
+ lodash.isNull = isNull;
4236
+ lodash.isNumber = isNumber;
4237
+ lodash.isObject = isObject;
4238
+ lodash.isRegExp = isRegExp;
4239
+ lodash.isString = isString;
4240
+ lodash.isUndefined = isUndefined;
4241
+ lodash.lastIndexOf = lastIndexOf;
4242
+ lodash.mixin = mixin;
4243
+ lodash.noConflict = noConflict;
4244
+ lodash.random = random;
4245
+ lodash.reduce = reduce;
4246
+ lodash.reduceRight = reduceRight;
4247
+ lodash.result = result;
4248
+ lodash.size = size;
4249
+ lodash.some = some;
4250
+ lodash.sortedIndex = sortedIndex;
4251
+ lodash.template = template;
4252
+ lodash.unescape = unescape;
4253
+ lodash.uniqueId = uniqueId;
4254
+
4255
+ // add aliases
4256
+ lodash.all = every;
4257
+ lodash.any = some;
4258
+ lodash.detect = find;
4259
+ lodash.foldl = reduce;
4260
+ lodash.foldr = reduceRight;
4261
+ lodash.include = contains;
4262
+ lodash.inject = reduce;
4263
+
4264
+ /*--------------------------------------------------------------------------*/
4265
+
4266
+ // add functions capable of returning wrapped and unwrapped values when chaining
4267
+ lodash.first = first;
4268
+ lodash.last = last;
4269
+
4270
+ // add aliases
4271
+ lodash.take = first;
4272
+ lodash.head = first;
4273
+
4274
+ /*--------------------------------------------------------------------------*/
4275
+
4276
+ lodash.chain = chain;
4277
+
4278
+ /**
4279
+ * The semantic version number.
4280
+ *
4281
+ * @static
4282
+ * @memberOf _
4283
+ * @type String
4284
+ */
4285
+ lodash.VERSION = '1.1.0';
4286
+
4287
+ // add functions to `lodash.prototype`
4288
+ mixin(lodash);
4289
+
4290
+ // add "Chaining" functions to the wrapper
4291
+ lodash.prototype.chain = wrapperChain;
4292
+ lodash.prototype.value = wrapperValueOf;
4293
+
4294
+ // add `Array` mutator functions to the wrapper
4295
+ forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
4296
+ var func = arrayRef[methodName];
4297
+ lodash.prototype[methodName] = function() {
4298
+ var value = this.__wrapped__;
4299
+ func.apply(value, arguments);
4300
+
4301
+ // avoid array-like object bugs with `Array#shift` and `Array#splice`
4302
+ // in Firefox < 10 and IE < 9
4303
+ if (!support.spliceObjects && value.length === 0) {
4304
+ delete value[0];
4305
+ }
4306
+ return this;
4307
+ };
4308
+ });
4309
+
4310
+ // add `Array` accessor functions to the wrapper
4311
+ forEach(['concat', 'join', 'slice'], function(methodName) {
4312
+ var func = arrayRef[methodName];
4313
+ lodash.prototype[methodName] = function() {
4314
+ var value = this.__wrapped__,
4315
+ result = func.apply(value, arguments);
4316
+
4317
+ if (this.__chain__) {
4318
+ result = new lodashWrapper(result);
4319
+ result.__chain__ = true;
4320
+ }
4321
+ return result;
4322
+ };
4323
+ });
4324
+
4325
+ /*--------------------------------------------------------------------------*/
4326
+
4327
+ // expose Lo-Dash
4328
+ // some AMD build optimizers, like r.js, check for specific condition patterns like the following:
4329
+ if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
4330
+ // Expose Lo-Dash to the global object even when an AMD loader is present in
4331
+ // case Lo-Dash was injected by a third-party script and not intended to be
4332
+ // loaded as a module. The global assignment can be reverted in the Lo-Dash
4333
+ // module via its `noConflict()` method.
4334
+ window._ = lodash;
4335
+
4336
+ // define as an anonymous module so, through path mapping, it can be
4337
+ // referenced as the "underscore" module
4338
+ define(function() {
4339
+ return lodash;
4340
+ });
4341
+ }
4342
+ // check for `exports` after `define` in case a build optimizer adds an `exports` object
4343
+ else if (freeExports && !freeExports.nodeType) {
4344
+ // in Node.js or RingoJS v0.8.0+
4345
+ if (freeModule) {
4346
+ (freeModule.exports = lodash)._ = lodash;
4347
+ }
4348
+ // in Narwhal or RingoJS v0.7.0-
4349
+ else {
4350
+ freeExports._ = lodash;
4351
+ }
4352
+ }
4353
+ else {
4354
+ // in a browser or Rhino
4355
+ window._ = lodash;
4356
+ }
4357
+ }(this));