Skip to content
This repository
Browse code

Cleanup and comment _.merge's _.reduce support.

  • Loading branch information...
commit 9582468a13923a1fd285c8cbf552d19d71b975fe 1 parent 05a4c84
John-David Dalton authored November 12, 2012

Showing 2 changed files with 7 additions and 3 deletions. Show diff stats Hide diff stats

  1. 8  lodash.js
  2. 2  lodash.min.js
8  lodash.js
@@ -1630,10 +1630,14 @@
1630 1630
         stackA = args[3],
1631 1631
         stackB = args[4];
1632 1632
 
1633  
-    if (typeof indicator != 'number' && indicator !== indicatorObject) {
  1633
+    if (indicator !== indicatorObject) {
1634 1634
       stackA = [];
1635 1635
       stackB = [];
1636  
-      length = args.length;
  1636
+
  1637
+      // work with `_.reduce` by only using its callback `accumulator` and `value` arguments
  1638
+      if (typeof indicator != 'number') {
  1639
+        length = args.length;
  1640
+      }
1637 1641
     }
1638 1642
     while (++index < length) {
1639 1643
       forOwn(args[index], function(source, key) {
2  lodash.min.js
@@ -10,7 +10,7 @@
10 10
 xt.call(e);if(!Gt[u]||Wt&&m(e))return e;var a=u==Dt,n=a||(u==jt?cn(e):n)}if(!n||!t)return n?a?St.call(e):rn({},e):e;n=e.constructor;switch(u){case Pt:case Ht:return new n(+e);case Bt:case It:return new n(e);case Ft:return n(e.source,ot.exec(e))}s||(s=[]),o||(o=[]);for(u=s.length;u--;)if(s[u]==e)return o[u];var f=a?n(e.length):{};return s.push(e),o.push(f),(a?pn:on)(e,function(e,n){f[n]=b(e,t,r,s,o)}),f}function w(e){var t=[];return sn(e,function(e,n){x(e)&&t.push(n)}),t.sort()}function E(e){var t=
11 11
 {};return on(e,function(e,n){t[e]=n}),t}function S(e,t,s,o){if(e===t)return 0!==e||1/e==1/t;if(e==r||t==r)return e===t;var u=xt.call(e);if(u!=xt.call(t))return i;switch(u){case Pt:case Ht:return+e==+t;case Bt:return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case Ft:case It:return e==t+""}var a=u==Dt||u==_t;if(Wt&&!a&&(a=m(e))&&!m(t))return i;if(!a){if(e.__wrapped__||t.__wrapped__)return S(e.__wrapped__||e,t.__wrapped__||t);if(u!=jt||$t&&("function"!=typeof e.toString&&"string"==typeof (e+"")||"function"!=typeof 
12 12
 t.toString&&"string"==typeof (t+"")))return i;var u=e.constructor,f=t.constructor;if(u!=f&&(!x(u)||!(u instanceof u&&x(f)&&f instanceof f)))return i}s||(s=[]),o||(o=[]);for(u=s.length;u--;)if(s[u]==e)return o[u]==t;var u=-1,f=n,l=0;s.push(e),o.push(t);if(a){l=e.length;if(f=l==t.length)for(;l--&&(f=S(e[l],t[l],s,o)););return f}for(var c in e)if(bt.call(e,c)&&(l++,!bt.call(t,c)||!S(e[c],t[c],s,o)))return i;for(c in t)if(bt.call(t,c)&&!(l--))return i;if(qt)for(;7>++u;)if(c=dt[u],bt.call(e,c)&&(!bt.call
13  
-(t,c)||!S(e[c],t[c],s,o)))return i;return n}function x(e){return"function"==typeof e}function T(e){return e?Yt[typeof e]:i}function N(e){return xt.call(e)==It}function C(e,t,n){var i=arguments,s=0,o=2,u=i[3],a=i[4];"number"!=typeof n&&n!==Y&&(u=[],a=[],o=i.length);for(;++s<o;)on(i[s],function(t,n){var i,s,o;if(t&&((s=ln(t))||cn(t))){for(var f=u.length;f--;)if(i=u[f]==t)break;i?e[n]=a[f]:(u.push(t),a.push(o=(o=e[n],s)?ln(o)?o:[]:cn(o)?o:{}),e[n]=C(o,t,Y,u,a))}else t!=r&&(e[n]=t)});return e}function k
  13
+(t,c)||!S(e[c],t[c],s,o)))return i;return n}function x(e){return"function"==typeof e}function T(e){return e?Yt[typeof e]:i}function N(e){return xt.call(e)==It}function C(e,t,n){var i=arguments,s=0,o=2,u=i[3],a=i[4];n!==Y&&(u=[],a=[],"number"!=typeof n&&(o=i.length));for(;++s<o;)on(i[s],function(t,n){var i,s,o;if(t&&((s=ln(t))||cn(t))){for(var f=u.length;f--;)if(i=u[f]==t)break;i?e[n]=a[f]:(u.push(t),a.push(o=(o=e[n],s)?ln(o)?o:[]:cn(o)?o:{}),e[n]=C(o,t,Y,u,a))}else t!=r&&(e[n]=t)});return e}function k
14 14
 (e){var t=[];return on(e,function(e){t.push(e)}),t}function L(e,t,n){var r=-1,s=e?e.length:0,o=i,n=(0>n?At(0,s+n):n)||0;return"number"==typeof s?o=-1<(N(e)?e.indexOf(t,n):q(e,t,n)):pn(e,function(e){if(++r>=n)return!(o=e===t)}),o}function A(e,t,r){var i=n,t=l(t,r);if(ln(e))for(var r=-1,s=e.length;++r<s&&(i=!!t(e[r],r,e)););else pn(e,function(e,n,r){return i=!!t(e,n,r)});return i}function O(e,t,n){var r=[],t=l(t,n);if(ln(e))for(var n=-1,i=e.length;++n<i;){var s=e[n];t(s,n,e)&&r.push(s)}else pn(e,function(
15 15
 e,n,i){t(e,n,i)&&r.push(e)});return r}function M(e,t,n){var r,t=l(t,n);return pn(e,function(e,n,s){if(t(e,n,s))return r=e,i}),r}function _(e,t,n){var r=-1,i=e?e.length:0,s=Array("number"==typeof i?i:0),t=l(t,n);if(ln(e))for(;++r<i;)s[r]=t(e[r],r,e);else pn(e,function(e,n,i){s[++r]=t(e,n,i)});return s}function D(e,t,n){var r=-Infinity,i=-1,s=e?e.length:0,o=r;if(t||!ln(e))t=!t&&N(e)?u:l(t,n),pn(e,function(e,n,i){n=t(e,n,i),n>r&&(r=n,o=e)});else for(;++i<s;)e[i]>o&&(o=e[i]);return o}function P(e,t){
16 16
 var n=[];return pn(e,function(e){n.push(e[t])}),n}function H(e,t,n,r){var s=3>arguments.length,t=l(t,r);return pn(e,function(e,r,o){n=s?(s=i,e):t(n,e,r,o)}),n}function B(e,t,n,r){var s=e,o=e?e.length:0,u=3>arguments.length;if("number"!=typeof o)var a=hn(e),o=a.length;else Vt&&N(e)&&(s=e.split(""));return pn(e,function(e,f,l){f=a?a[--o]:--o,n=u?(u=i,s[f]):t.call(r,n,s[f],f,l)}),n}function j(e,t,n){var r,t=l(t,n);if(ln(e))for(var n=-1,i=e.length;++n<i&&!(r=t(e[n],n,e)););else pn(e,function(e,n,i){return!

0 notes on commit 9582468

Please sign in to comment.
Something went wrong with that request. Please try again.