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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/lodash/rails/version.rb +1 -1
- data/vendor/assets/javascripts/lodash.compat.js +2367 -1634
- data/vendor/assets/javascripts/lodash.compat.min.js +52 -47
- data/vendor/assets/javascripts/lodash.js +2282 -1563
- data/vendor/assets/javascripts/lodash.min.js +48 -44
- data/vendor/assets/javascripts/lodash.underscore.js +1330 -1082
- data/vendor/assets/javascripts/lodash.underscore.min.js +33 -31
- metadata +3 -3
@@ -1,48 +1,52 @@
|
|
1
1
|
/**
|
2
2
|
* @license
|
3
|
-
* Lo-Dash
|
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
|
-
|
8
|
-
}}function
|
9
|
-
}function
|
10
|
-
for(var r=-1,u=L[typeof n]&&
|
11
|
-
if(!u)return
|
12
|
-
}function
|
13
|
-
}
|
14
|
-
|
15
|
-
if(
|
16
|
-
|
17
|
-
}),s&&(
|
18
|
-
if(
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}}
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}}
|
30
|
-
|
31
|
-
}
|
32
|
-
|
33
|
-
},
|
34
|
-
|
35
|
-
}
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
},
|
40
|
-
},
|
41
|
-
|
42
|
-
var
|
43
|
-
|
44
|
-
}
|
45
|
-
|
46
|
-
}
|
47
|
-
|
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&>(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={"&":"&","<":"<",">":">",'"':""","'":"'"},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"&>(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
|
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.
|
7
|
-
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud
|
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(
|
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
|
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
|
-
|
77
|
+
root = freeGlobal;
|
102
78
|
}
|
103
79
|
|
104
80
|
/*--------------------------------------------------------------------------*/
|
105
81
|
|
106
82
|
/**
|
107
|
-
*
|
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 {
|
113
|
-
* @param {
|
114
|
-
* @returns {
|
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
|
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`
|
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 {
|
111
|
+
* @returns {number} Returns the sort order indicator of `1` or `-1`.
|
136
112
|
*/
|
137
113
|
function compareAscending(a, b) {
|
138
|
-
var
|
139
|
-
|
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 (
|
147
|
-
if (
|
119
|
+
if (ac !== bc) {
|
120
|
+
if (ac > bc || typeof ac == 'undefined') {
|
148
121
|
return 1;
|
149
122
|
}
|
150
|
-
if (
|
123
|
+
if (ac < bc || typeof bc == 'undefined') {
|
151
124
|
return -1;
|
152
125
|
}
|
153
126
|
}
|
154
|
-
|
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 {
|
163
|
-
* @returns {
|
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 =
|
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
|
-
|
210
|
-
|
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 =
|
188
|
+
nativeCreate = reNative.test(nativeCreate = Object.create) && nativeCreate,
|
216
189
|
nativeIsArray = reNative.test(nativeIsArray = Array.isArray) && nativeIsArray,
|
217
|
-
nativeIsFinite =
|
218
|
-
nativeIsNaN =
|
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(
|
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
|
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`, `
|
245
|
-
* `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`,
|
246
|
-
* `
|
247
|
-
* `
|
248
|
-
* `
|
249
|
-
* `
|
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`, `
|
255
|
-
* `
|
256
|
-
* `
|
257
|
-
* `
|
258
|
-
* `
|
259
|
-
* `
|
260
|
-
* `
|
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
|
-
*
|
238
|
+
* provided, otherwise they return unwrapped values.
|
264
239
|
*
|
265
240
|
* @name _
|
266
241
|
* @constructor
|
267
|
-
* @alias chain
|
268
242
|
* @category Chaining
|
269
|
-
* @param {
|
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 {
|
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
|
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
|
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
|
361
|
+
* @type string
|
386
362
|
*/
|
387
363
|
'variable': ''
|
388
364
|
};
|
@@ -390,59 +366,333 @@
|
|
390
366
|
/*--------------------------------------------------------------------------*/
|
391
367
|
|
392
368
|
/**
|
393
|
-
*
|
394
|
-
*
|
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 {
|
399
|
-
* @param {
|
400
|
-
* @param {
|
401
|
-
* @
|
402
|
-
|
403
|
-
|
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
|
406
|
-
var
|
407
|
-
|
408
|
-
|
414
|
+
function baseFlatten(array, isShallow, isArgArrays, fromIndex) {
|
415
|
+
var index = (fromIndex || 0) - 1,
|
416
|
+
length = array ? array.length : 0,
|
417
|
+
result = [];
|
409
418
|
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
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
|
-
|
416
|
-
|
417
|
-
|
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
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
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 (
|
429
|
-
|
516
|
+
if (result) {
|
517
|
+
while (size--) {
|
518
|
+
if (!(result = baseIsEqual(a[size], b[size], stackA, stackB))) {
|
519
|
+
break;
|
520
|
+
}
|
521
|
+
}
|
430
522
|
}
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
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
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
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
|
-
|
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
|
462
|
-
|
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 {
|
477
|
-
* @returns {
|
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 `
|
736
|
+
* the `baseIndexOf` function.
|
487
737
|
*
|
488
738
|
* @private
|
489
739
|
* @returns {Function} Returns the "indexOf" function.
|
490
740
|
*/
|
491
|
-
function getIndexOf(
|
492
|
-
var result = (result = lodash.indexOf) === indexOf ?
|
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 {
|
501
|
-
* @returns {
|
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 {
|
516
|
-
* @returns {
|
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 {
|
542
|
-
* @returns {
|
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
|
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
|
813
|
+
* @returns {Array} Returns an array of property names.
|
563
814
|
*/
|
564
|
-
var shimKeys = function
|
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
|
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
|
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
|
'<': '<',
|
607
858
|
'>': '>',
|
608
859
|
'"': '"',
|
609
|
-
"'": '&#
|
860
|
+
"'": '''
|
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
|
621
|
-
*
|
622
|
-
*
|
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} [
|
885
|
+
* @param {...Object} [source] The source objects.
|
631
886
|
* @param {Function} [callback] The function to customize assigning values.
|
632
|
-
* @param {
|
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
|
664
|
-
* be cloned, otherwise they will be assigned by reference. If a
|
665
|
-
*
|
666
|
-
*
|
667
|
-
* The
|
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 {
|
673
|
-
* @param {
|
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 {
|
676
|
-
* @
|
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} [
|
973
|
+
* @param {...Object} [source] The source objects.
|
721
974
|
* @param- {Object} [guard] Allows working with `_.reduce` without using its
|
722
|
-
*
|
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] ==
|
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
|
749
|
-
* the
|
750
|
-
* invoked with three arguments; (value, key, object). Callbacks may exit
|
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 {
|
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
|
-
*
|
1021
|
+
* console.log('Woof, woof!');
|
769
1022
|
* };
|
770
1023
|
*
|
771
1024
|
* _.forIn(new Dog('Dagny'), function(value, key) {
|
772
|
-
*
|
1025
|
+
* console.log(key);
|
773
1026
|
* });
|
774
|
-
* // =>
|
1027
|
+
* // => logs 'bark' and 'name' (property order is not guaranteed across environments)
|
775
1028
|
*/
|
776
|
-
var forIn = function
|
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
|
788
|
-
* for each property. The
|
789
|
-
* arguments; (value, key, object). Callbacks may exit iteration early by
|
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 {
|
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
|
-
*
|
1056
|
+
* console.log(key);
|
804
1057
|
* });
|
805
|
-
* // =>
|
1058
|
+
* // => logs '0', '1', and 'length' (property order is not guaranteed across environments)
|
806
1059
|
*/
|
807
|
-
var forOwn = function
|
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,
|
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
|
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 {
|
853
|
-
* @returns {
|
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
|
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 {
|
896
|
-
* @returns {
|
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 {
|
913
|
-
* @returns {
|
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 {
|
930
|
-
* @returns {
|
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|
|
949
|
-
* @returns {
|
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
|
979
|
-
* compare values. If
|
980
|
-
* by the method instead. The
|
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 {
|
987
|
-
* @param {
|
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 {
|
990
|
-
* @
|
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
|
1017
|
-
|
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
|
1118
|
-
* booleans and empty strings. See http://es5.github.
|
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 {
|
1124
|
-
* @returns {
|
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 {
|
1153
|
-
* @returns {
|
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 {
|
1177
|
-
* @returns {
|
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.
|
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
|
1201
|
-
* `undefined` and other values. See http://es5.github.
|
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 {
|
1207
|
-
* @returns {
|
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 {
|
1235
|
-
* @returns {
|
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 {
|
1255
|
-
* @returns {
|
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 {
|
1272
|
-
* @returns {
|
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
|
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 {
|
1289
|
-
* @returns {
|
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 {
|
1306
|
-
* @returns {
|
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
|
1320
|
-
*
|
1321
|
-
*
|
1322
|
-
*
|
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|
|
1329
|
-
*
|
1330
|
-
* @param {
|
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 =
|
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
|
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
|
1385
|
-
* names. If
|
1386
|
-
* `object
|
1387
|
-
* is bound to `thisArg` and invoked with three arguments;
|
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 {
|
1394
|
-
*
|
1395
|
-
*
|
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 =
|
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
|
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
|
1451
|
-
*
|
1452
|
-
*
|
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|
|
1459
|
-
* @param {
|
1460
|
-
* @param {
|
1461
|
-
* @returns {
|
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
|
1492
|
-
* `collection` through the
|
1493
|
-
* is the number of times the key was returned by the
|
1494
|
-
* is bound to `thisArg` and invoked with three arguments;
|
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
|
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
|
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|
|
1507
|
-
* @param {Function|Object|
|
1508
|
-
* iteration. If a property name or object is
|
1509
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
1510
|
-
* @param {
|
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
|
-
|
1524
|
-
|
1525
|
-
|
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
|
1536
|
-
*
|
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
|
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
|
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|
|
1551
|
-
* @param {Function|Object|
|
1552
|
-
* iteration. If a property name or object is
|
1553
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
1554
|
-
* @param {
|
1555
|
-
* @returns {
|
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
|
-
*
|
1598
|
-
* the
|
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
|
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
|
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|
|
1613
|
-
* @param {Function|Object|
|
1614
|
-
* iteration. If a property name or object is
|
1615
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
1616
|
-
* @param {
|
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
|
-
*
|
1662
|
-
* returns
|
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
|
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
|
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|
|
1677
|
-
* @param {Function|Object|
|
1678
|
-
* iteration. If a property name or object is
|
1679
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
1680
|
-
* @param {
|
1681
|
-
* @returns {
|
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|
|
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 {
|
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
|
1757
|
-
*
|
1758
|
-
*
|
1759
|
-
*
|
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|
|
1920
|
+
* @param {Array|Object|string} collection The collection to iterate over.
|
1766
1921
|
* @param {Function} [callback=identity] The function called per iteration.
|
1767
|
-
* @param {
|
1768
|
-
* @returns {Array|Object|
|
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(
|
1772
|
-
* // =>
|
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 },
|
1775
|
-
* // =>
|
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 :
|
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
|
-
*
|
1795
|
-
* `collection`
|
1796
|
-
*
|
1797
|
-
*
|
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
|
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
|
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|
|
1810
|
-
* @param {Function|Object|
|
1811
|
-
* iteration. If a property name or object is
|
1812
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
1813
|
-
* @param {
|
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
|
-
*
|
1818
|
-
*
|
2047
|
+
* var keys = [
|
2048
|
+
* { 'dir': 'left', 'code': 97 },
|
2049
|
+
* { 'dir': 'right', 'code': 100 }
|
2050
|
+
* ];
|
1819
2051
|
*
|
1820
|
-
* _.
|
1821
|
-
* // => { '
|
2052
|
+
* _.indexBy(keys, 'dir');
|
2053
|
+
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
|
1822
2054
|
*
|
1823
|
-
*
|
1824
|
-
*
|
1825
|
-
*
|
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
|
-
|
1828
|
-
|
1829
|
-
|
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
|
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|
|
1848
|
-
* @param {Function|
|
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 {
|
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
|
1875
|
-
* through the
|
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
|
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
|
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|
|
1890
|
-
* @param {Function|Object|
|
1891
|
-
* iteration. If a property name or object is
|
1892
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
1893
|
-
* @param {
|
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
|
1933
|
-
*
|
1934
|
-
*
|
1935
|
-
*
|
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
|
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
|
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|
|
1948
|
-
* @param {Function|Object|
|
1949
|
-
* iteration. If a property name or object is
|
1950
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
1951
|
-
* @param {
|
1952
|
-
* @returns {
|
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
|
2000
|
-
*
|
2001
|
-
*
|
2002
|
-
*
|
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
|
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
|
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|
|
2015
|
-
* @param {Function|Object|
|
2016
|
-
* iteration. If a property name or object is
|
2017
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
2018
|
-
* @param {
|
2019
|
-
* @returns {
|
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|
|
2073
|
-
* @param {
|
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
|
2100
|
-
* each element in the
|
2101
|
-
*
|
2102
|
-
*
|
2103
|
-
* used as the initial `accumulator` value. The
|
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|
|
2337
|
+
* @param {Array|Object|string} collection The collection to iterate over.
|
2111
2338
|
* @param {Function} [callback=identity] The function called per iteration.
|
2112
|
-
* @param {
|
2113
|
-
* @param {
|
2114
|
-
* @returns {
|
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 =
|
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
|
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|
|
2388
|
+
* @param {Array|Object|string} collection The collection to iterate over.
|
2162
2389
|
* @param {Function} [callback=identity] The function called per iteration.
|
2163
|
-
* @param {
|
2164
|
-
* @param {
|
2165
|
-
* @returns {
|
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
|
2174
|
-
|
2175
|
-
|
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,
|
2186
|
-
: callback(accumulator,
|
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
|
2193
|
-
*
|
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
|
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
|
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|
|
2206
|
-
* @param {Function|Object|
|
2207
|
-
* iteration. If a property name or object is
|
2208
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
2209
|
-
* @param {
|
2210
|
-
* @returns {Array} Returns a new array of elements that
|
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
|
-
*
|
2239
|
-
*
|
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|
|
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 =
|
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|
|
2272
|
-
* @returns {
|
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
|
2291
|
-
*
|
2292
|
-
* does not iterate over the entire
|
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
|
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
|
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|
|
2307
|
-
* @param {Function|Object|
|
2308
|
-
* iteration. If a property name or object is
|
2309
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
2310
|
-
* @param {
|
2311
|
-
* @returns {
|
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
|
2355
|
-
* performs a stable sort, that is, it will preserve the original sort order
|
2356
|
-
* equal elements. The
|
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
|
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
|
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|
|
2370
|
-
* @param {Function|Object|
|
2371
|
-
* iteration. If a property name or object is
|
2372
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
2373
|
-
* @param {
|
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|
|
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
|
-
*
|
2434
|
-
*
|
2435
|
-
*
|
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|
|
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': '
|
2449
|
-
* { 'name': '
|
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
|
-
?
|
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
|
2465
|
-
* `
|
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
|
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
|
2493
|
-
*
|
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} [
|
2500
|
-
* @returns {Array} Returns a new array of
|
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 =
|
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
|
2525
|
-
*
|
2526
|
-
*
|
2527
|
-
*
|
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
|
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
|
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|
|
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
|
2794
|
+
* object is provided it will be used to create a "_.pluck" or "_.where"
|
2545
2795
|
* style callback, respectively.
|
2546
|
-
* @param {
|
2547
|
-
* @returns {
|
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
|
-
|
2582
|
-
|
2583
|
-
length = array.length;
|
2831
|
+
var n = 0,
|
2832
|
+
length = array ? array.length : 0;
|
2584
2833
|
|
2585
|
-
|
2586
|
-
|
2587
|
-
|
2588
|
-
|
2589
|
-
|
2590
|
-
|
2591
|
-
|
2592
|
-
|
2593
|
-
|
2594
|
-
|
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
|
2604
|
-
* is
|
2605
|
-
* flattening. The
|
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
|
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
|
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 {
|
2620
|
-
* @param {Function|Object|
|
2621
|
-
* iteration. If a property name or object is
|
2622
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
2623
|
-
* @param {
|
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
|
-
|
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
|
2661
|
-
*
|
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 {
|
2668
|
-
* @param {
|
2669
|
-
* perform a binary search on a sorted
|
2670
|
-
* @returns {
|
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
|
2926
|
+
return baseIndexOf(array, value, fromIndex);
|
2691
2927
|
}
|
2692
2928
|
|
2693
2929
|
/**
|
2694
|
-
* Gets all but the last element
|
2695
|
-
*
|
2696
|
-
*
|
2697
|
-
*
|
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
|
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
|
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|
|
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
|
2948
|
+
* object is provided it will be used to create a "_.pluck" or "_.where"
|
2714
2949
|
* style callback, respectively.
|
2715
|
-
* @param {
|
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
|
-
*
|
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} [
|
2776
|
-
* @returns {Array} Returns
|
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
|
2809
|
-
*
|
2810
|
-
*
|
2811
|
-
*
|
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
|
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
|
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|
|
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
|
3057
|
+
* object is provided it will be used to create a "_.pluck" or "_.where"
|
2829
3058
|
* style callback, respectively.
|
2830
|
-
* @param {
|
2831
|
-
* @returns {
|
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
|
-
|
2866
|
-
|
2867
|
-
length = array.length;
|
3094
|
+
var n = 0,
|
3095
|
+
length = array ? array.length : 0;
|
2868
3096
|
|
2869
|
-
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
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 {
|
2895
|
-
* @param {
|
2896
|
-
* @returns {
|
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 {
|
2926
|
-
* @param {
|
2927
|
-
* @param {
|
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 =
|
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
|
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
|
2969
|
-
*
|
2970
|
-
* the
|
2971
|
-
*
|
2972
|
-
*
|
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
|
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
|
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|
|
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
|
3219
|
+
* object is provided it will be used to create a "_.pluck" or "_.where"
|
2990
3220
|
* style callback, respectively.
|
2991
|
-
* @param {
|
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
|
3043
|
-
* should be inserted into
|
3044
|
-
*
|
3045
|
-
* each element
|
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
|
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
|
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 {
|
3060
|
-
* @param {Function|Object|
|
3061
|
-
* iteration. If a property name or object is
|
3062
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
3063
|
-
* @param {
|
3064
|
-
* @returns {
|
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
|
-
*
|
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} [
|
3114
|
-
* @returns {Array} Returns
|
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
|
-
|
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
|
3130
|
-
* for comparisons, i.e. `===`. If the
|
3131
|
-
* for `isSorted` will
|
3132
|
-
* element of `array` is passed through the
|
3133
|
-
* The
|
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
|
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
|
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 {
|
3148
|
-
* @param {Function|Object|
|
3149
|
-
* iteration. If a property name or object is
|
3150
|
-
* a "_.pluck" or "_.where" style callback, respectively.
|
3151
|
-
* @param {
|
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
|
-
|
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
|
-
|
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
|
3408
|
+
return baseUniq(array, isSorted, callback);
|
3227
3409
|
}
|
3228
3410
|
|
3229
3411
|
/**
|
3230
|
-
* Creates an array
|
3231
|
-
*
|
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 {
|
3238
|
-
* @returns {Array} Returns a new filtered
|
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
|
-
*
|
3250
|
-
*
|
3251
|
-
*
|
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} [
|
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(
|
3446
|
+
function zip() {
|
3265
3447
|
var index = -1,
|
3266
|
-
length =
|
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`.
|
3277
|
-
* a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]
|
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
|
-
*
|
3313
|
-
*
|
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 {
|
3322
|
-
*
|
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
|
3328
|
-
*
|
3329
|
-
*
|
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
|
-
* //
|
3515
|
+
* // => logs 'Done saving!', after all saves have completed
|
3332
3516
|
*/
|
3333
3517
|
function after(n, func) {
|
3334
|
-
if (
|
3335
|
-
|
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
|
-
*
|
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 {
|
3354
|
-
* @param {
|
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
|
-
|
3368
|
-
|
3369
|
-
|
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
|
3376
|
-
* Method names may be specified as individual arguments or as arrays
|
3377
|
-
* names. If no method names are provided
|
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 {
|
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() {
|
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
|
-
* // =>
|
3578
|
+
* // => logs 'clicked docs', when the button is clicked
|
3396
3579
|
*/
|
3397
3580
|
function bindAll(object) {
|
3398
|
-
var funcs = arguments.length > 1 ?
|
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] =
|
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
|
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} [
|
3601
|
+
* @param {...Function} [func] Functions to compose.
|
3419
3602
|
* @returns {Function} Returns the new composed function.
|
3420
3603
|
* @example
|
3421
3604
|
*
|
3422
|
-
* var
|
3423
|
-
*
|
3424
|
-
*
|
3425
|
-
*
|
3426
|
-
*
|
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
|
3444
|
-
* If `func` is an object
|
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 {
|
3453
|
-
* @param {
|
3454
|
-
* @param {
|
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
|
3493
|
-
|
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
|
-
|
3524
|
-
|
3525
|
-
|
3678
|
+
// handle "_.pluck" style callback shorthands
|
3679
|
+
if (type != 'object') {
|
3680
|
+
return function(object) {
|
3681
|
+
return object[func];
|
3526
3682
|
};
|
3527
3683
|
}
|
3528
|
-
|
3529
|
-
|
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.
|
3536
|
-
* an
|
3537
|
-
* and/or trailing edge of the `wait` timeout. Subsequent calls
|
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
|
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 {
|
3549
|
-
* @param {Object} options The options object.
|
3550
|
-
*
|
3551
|
-
*
|
3552
|
-
*
|
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
|
-
*
|
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
|
-
*
|
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,
|
3737
|
+
function debounce(func, wait, options) {
|
3565
3738
|
var args,
|
3739
|
+
maxTimeoutId,
|
3566
3740
|
result,
|
3741
|
+
stamp,
|
3567
3742
|
thisArg,
|
3568
|
-
timeoutId
|
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
|
3571
|
-
timeoutId
|
3572
|
-
|
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
|
-
|
3582
|
-
|
3583
|
-
|
3584
|
-
|
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
|
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 {
|
3600
|
-
* @returns {
|
3831
|
+
* @param {...*} [arg] Arguments to invoke the function with.
|
3832
|
+
* @returns {number} Returns the timer id.
|
3601
3833
|
* @example
|
3602
3834
|
*
|
3603
|
-
* _.defer(function() {
|
3604
|
-
* // returns from the function before
|
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
|
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 {
|
3620
|
-
* @param {
|
3621
|
-
* @returns {
|
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
|
-
*
|
3636
|
-
* based on the arguments
|
3637
|
-
* argument
|
3638
|
-
* is executed with the `this` binding of the memoized function.
|
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 =
|
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
|
3700
|
-
* method is similar to `_.bind
|
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 {
|
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.
|
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
|
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 {
|
3735
|
-
* @param {Object} options The options object.
|
3736
|
-
*
|
3737
|
-
*
|
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
|
3750
|
-
|
3751
|
-
thisArg,
|
3752
|
-
lastCalled = 0,
|
3753
|
-
timeoutId = null;
|
4005
|
+
function throttle(func, wait, options) {
|
4006
|
+
var leading = true,
|
4007
|
+
trailing = true;
|
3754
4008
|
|
3755
|
-
|
3756
|
-
|
3757
|
-
timeoutId = null;
|
3758
|
-
result = func.apply(thisArg, args);
|
4009
|
+
if (!isFunction(func)) {
|
4010
|
+
throw new TypeError;
|
3759
4011
|
}
|
3760
|
-
|
3761
|
-
|
3762
|
-
|
3763
|
-
|
3764
|
-
|
3765
|
-
|
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
|
-
|
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
|
3782
|
-
* first argument. Additional arguments
|
3783
|
-
* to those
|
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 {
|
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 {
|
3819
|
-
* @returns {
|
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
|
4079
|
+
* This method returns the first argument provided to it.
|
3831
4080
|
*
|
3832
4081
|
* @static
|
3833
4082
|
* @memberOf _
|
3834
4083
|
* @category Utilities
|
3835
|
-
* @param {
|
3836
|
-
* @returns {
|
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
|
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
|
-
|
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
|
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 {
|
3912
|
-
* @param {
|
3913
|
-
* @returns {
|
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
|
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 {
|
3950
|
-
* @returns {
|
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
|
-
|
3968
|
-
|
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 {
|
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
|
-
*
|
3991
|
-
*
|
3992
|
-
*
|
3993
|
-
*
|
3994
|
-
*
|
3995
|
-
* @
|
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><script></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 " +
|
4018
|
-
* // => 'hello
|
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
|
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)(
|
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
|
4106
|
-
* of each
|
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 {
|
4374
|
+
* @param {number} n The number of times to execute the callback.
|
4113
4375
|
* @param {Function} callback The function called per iteration.
|
4114
|
-
* @param {
|
4115
|
-
* @returns {Array} Returns
|
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
|
4392
|
+
result = Array(n);
|
4130
4393
|
|
4394
|
+
callback = baseCreateCallback(callback, thisArg, 1);
|
4131
4395
|
while (++index < n) {
|
4132
|
-
result[index] = callback
|
4396
|
+
result[index] = callback(index);
|
4133
4397
|
}
|
4134
4398
|
return result;
|
4135
4399
|
}
|
4136
4400
|
|
4137
4401
|
/**
|
4138
|
-
* The inverse of `_.escape
|
4402
|
+
* The inverse of `_.escape` this method converts the HTML entities
|
4139
4403
|
* `&`, `<`, `>`, `"`, and `'` in `string` to their
|
4140
4404
|
* corresponding characters.
|
4141
4405
|
*
|
4142
4406
|
* @static
|
4143
4407
|
* @memberOf _
|
4144
4408
|
* @category Utilities
|
4145
|
-
* @param {
|
4146
|
-
* @returns {
|
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 & Curly');
|
@@ -4154,13 +4418,13 @@
|
|
4154
4418
|
}
|
4155
4419
|
|
4156
4420
|
/**
|
4157
|
-
* Generates a unique ID. If `prefix` is
|
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 {
|
4163
|
-
* @returns {
|
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 {
|
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
|
4209
|
-
* returns `value`. The purpose of this method is to "tap into" a method
|
4210
|
-
* in order to perform operations on intermediate results within
|
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 {
|
4480
|
+
* @param {*} value The value to provide to `interceptor`.
|
4216
4481
|
* @param {Function} interceptor The function to invoke.
|
4217
|
-
* @returns {
|
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(
|
4487
|
+
* .tap(function(array) { console.log(array); })
|
4223
4488
|
* .map(function(num) { return num * num; })
|
4224
4489
|
* .value();
|
4225
|
-
* // => // [2, 4] (
|
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 {
|
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 {
|
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
|
4671
|
+
* @type string
|
4420
4672
|
*/
|
4421
|
-
lodash.VERSION = '
|
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
|
-
//
|
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
|
-
|
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
|
-
|
4739
|
+
root._ = lodash;
|
4492
4740
|
}
|
4493
|
-
}(this));
|
4741
|
+
}.call(this));
|