lodash-rails 1.3.1 → 2.0.0

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