From 16242f98ce67315bc6a22e4bec1df7190fc47e0d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 19 May 2013 14:23:35 -0700 Subject: [PATCH] Ensure `each` is converted to `forEach` when used in a ternary operation. Former-commit-id: ff42e367f9987726fd561037337081c63c7a5100 --- build.js | 1 + dist/lodash.compat.js | 2 +- dist/lodash.compat.min.js | 2 +- dist/lodash.js | 2 +- dist/lodash.min.js | 2 +- lodash.js | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.js b/build.js index 363959981..5667f5dbe 100755 --- a/build.js +++ b/build.js @@ -2806,6 +2806,7 @@ .replace(matchFunction(source, 'each'), '') .replace(/^ *lodash\._each *=.+\n/gm, '') .replace(/\beach(?=\(collection)/g, 'forOwn') + .replace(/(\?\s*)each(?=\s*:)/g, '$1forEach') .replace(/\beach(?=\(\[)/g, 'forEach'); } // modify `_.contains`, `_.every`, `_.find`, and `_.some` to use the private `indicatorObject` diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 69093708a..a9e9aa053 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -1266,7 +1266,7 @@ stackB.push(result); // recursively populate clone (susceptible to call stack limits) - (isArr ? forEach : forOwn)(value, function(objValue, key) { + (isArr ? each : forOwn)(value, function(objValue, key) { result[key] = clone(objValue, deep, callback, undefined, stackA, stackB); }); diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 93f23c31a..5282039bf 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -9,7 +9,7 @@ return a||(n=t[i]),r.length&&(e=e.length?(e=mr.call(e),c?e.concat(r):r.concat(e) var u=[];if(wr.enumPrototypes&&u.push('!(E&&m=="prototype")'),wr.enumErrorProps&&u.push('!(D&&(m=="message"||m=="name"))'),t.i&&t.j)e+="var A=-1,B=z[typeof r]?t(r):[],s=B.length;while(++Ak;k++)e+="m='"+t.g[k]+"';if((!(p&&v[m])&&l.call(r,m))",t.i||(e+="||(!v[m]&&r[m]!==y[m])"),e+="){"+t.f+"}"; e+="}"}return(t.b||wr.nonEnumArgs)&&(e+="}"),e+=t.c+";return C",n("i,j,l,n,o,q,t,u,y,z,w,G,H,J",r+e+"}")(A,Kt,tr,Z,Er,it,Sr,a,Mt,$,Cr,z,Ut,or)}function J(n){return at(n)?cr(n):{}}function K(n){return"\\"+q[n]}function M(n){return Ir[n]}function U(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function V(n){this.__wrapped__=n}function Q(){}function W(n){var t=!1;if(!n||or.call(n)!=N||!wr.argsClass&&Z(n))return t;var r=n.constructor;return(ut(r)?r instanceof r:wr.nodeClass||!U(n))?wr.ownLast?(zr(n,function(n,r,e){return t=tr.call(e,r),!1 }),!0===t):(zr(n,function(n,r){t=r}),!1===t||tr.call(n,t)):t}function X(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=zt(0>r?0:r);++ee?se(0,r+e):ve(e,r-1))+1);r--;)if(n[r]===t)return r; diff --git a/lodash.js b/lodash.js index 0815e46d3..57b247b72 100644 --- a/lodash.js +++ b/lodash.js @@ -1284,7 +1284,7 @@ stackB.push(result); // recursively populate clone (susceptible to call stack limits) - (isArr ? forEach : forOwn)(value, function(objValue, key) { + (isArr ? each : forOwn)(value, function(objValue, key) { result[key] = clone(objValue, deep, callback, undefined, stackA, stackB); });