diff --git a/build.js b/build.js index 8c88e6a50..7c0f1c3aa 100755 --- a/build.js +++ b/build.js @@ -2221,7 +2221,7 @@ } return match.replace(/^(( *)if *\(.*?\bisArray\([^\)]+\).*?\) *{\n)(( *)var index[^;]+.+\n+)/m, function(snippet, statement, indent, vars) { vars = vars - .replace(/\b(length *=)[^;]+/, '$1 collection' + (methodName == 'reduce' ? '.length' : ' ? collection.length : 0')) + .replace(/\b(length *=)[^;=]+/, '$1 collection' + (methodName == 'reduce' ? '.length' : ' ? collection.length : 0')) .replace(RegExp('^ ' + indent, 'gm'), indent); return vars + statement.replace(/\bisArray\([^\)]+\)/, "typeof length == 'number'"); @@ -3263,7 +3263,7 @@ modified = modified .replace(/\bctor *=.+\s+/, '') .replace(/^ *ctor\.prototype.+\s+.+\n/m, '') - .replace(/(?:,\n)? *props *=[^;]+/, '') + .replace(/(?:,\n)? *props *=[^;=]+/, '') .replace(/^ *for *\((?=prop)/, '$&var ') } if (!/support\.nonEnumArgs *=(?! *(?:false|true))/.test(match)) { diff --git a/build/post-compile.js b/build/post-compile.js index 29fa06152..e59442391 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -41,12 +41,17 @@ [/(\w+)\s*=\s*!1\b/, /(\w+)\s*=\s*!0\b/].forEach(function(regexp, index) { var varName = (regexp.exec(source) || 0)[1]; if (varName) { - source = source.replace(RegExp('([!=]==\\s*)' + varName + '|' + varName + '(\\s*[!=]==)', 'g'), '$1' + !!index + '$2'); + source = source.replace(RegExp('([!=]==\\s*)' + varName + '\\b|\\b' + varName + '(\\s*[!=]==)', 'g'), function(match, prelude, postlude, at) { + // avoid replacing local variables with the same name + return RegExp('\\b' + varName + '\\s*(?:,|=[^=])').test(source.slice(at - 10, at)) + ? match + : (prelude || '') + !!index + (postlude || ''); + }); } }); // replace `!1` and `!0` in expressions with `false` and `true` values - [/([!=]==)\s*!1|(.)!1\s*([!=]==)/g, /([!=]==)\s*!0|(.)!0\s*([!=]==)/g].forEach(function(regexp, index) { + [/([!=]==)\s*!1\b|(.)!1\s*([!=]==)/g, /([!=]==)\s*!0\b|(.)!0\s*([!=]==)/g].forEach(function(regexp, index) { source = source.replace(regexp, function(match, prelude, chr, postlude) { return (prelude || chr + (/\w/.test(chr) ? ' ' : '')) + !!index + (postlude || ''); }); diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 92b8651bf..ea31278f3 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -39,11 +39,11 @@ for(t=a.createCallback(t,r),dt(n,function(n,r,u){o[++e]={a:t(n,r,u),b:e,c:n}}),u var e=-1,u=$t(n);for(t=a.createCallback(t,r,1);++er?yr(0,e+r):mr(r,e-1))+1);e--;)if(n[e]===false)return e;return-1},a.mixin=zt,a.noConflict=function(){return e._=Wt,this},a.parseInt=Hr,a.random=function(n,t){null==n&&null==t&&(t=1),n=+n||0,null==t?(t=n,n=0):t=+t||0;var r=br();return n%1||t%1?n+mr(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+tr(r*(t-n+1))},a.reduce=Ct,a.reduceRight=jt,a.result=function(n,t){var e=n?n[t]:r;return ct(e)?n[t]():e},a.runInContext=t,a.size=function(n){var t=n?n.length:0; return typeof t=="number"?t:Br(n).length},a.some=wt,a.sortedIndex=St,a.template=function(n,t,e){var u=a.templateSettings;n||(n=""),e=$r({},e,u);var o,i=$r({},e.imports,u.imports),u=Br(i),i=gt(i),c=0,l=e.interpolate||_,g="__p+='",l=Ht((e.escape||_).source+"|"+l.source+"|"+(true===y?v:_).source+"|"+(e.evaluate||_).source+"|$","g");n.replace(l,function(t,r,e,u,a,i){return e||(e=u),g+=n.slice(c,i).replace(j,V),r&&(g+="'+__e("+r+")+'"),a&&(o=!0,g+="';"+a+";__p+='"),e&&(g+="'+((__t=("+e+"))==null?'':__t)+'"),c=i+t.length,t }),g+="';\n",l=e=e.variable,l||(e="obj",g="with("+e+"){"+g+"}"),g=(o?g.replace(f,""):g).replace(p,"$1").replace(s,"$1;"),g="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+g+"return __p}";try{var h=Rt(u,"return "+g).apply(r,i)}catch(m){throw m.source=g,m}return t?h(t):(h.source=g,h)},a.unescape=function(n){return null==n?"":Jt(n).replace(g,rt)},a.uniqueId=function(n){var t=++o;return Jt(null==n?"":n)+t },a.all=ht,a.any=wt,a.detect=mt,a.foldl=Ct,a.foldr=jt,a.include=vt,a.inject=Ct,Dr(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return ar.apply(t,arguments),n.apply(a,t)})}),a.first=xt,a.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n[u-1];return tt(n,yr(0,u-e))}},a.take=xt,a.head=xt,Dr(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,r){var e=n(this.__wrapped__,t,r); return null==t||r&&typeof t!="function"?e:new X(e)})}),a.VERSION="1.2.1",a.prototype.toString=function(){return Jt(this.__wrapped__)},a.prototype.value=Ft,a.prototype.valueOf=Ft,Nr(["join","pop","shift"],function(n){var t=Mt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Nr(["push","reverse","sort","unshift"],function(n){var t=Mt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Nr(["concat","slice","splice"],function(n){var t=Mt[n];a.prototype[n]=function(){return new X(t.apply(this.__wrapped__,arguments)) -}}),xr.spliceObjects||Nr(["pop","shift","splice"],function(n){var t=Mt[n],r="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,e=t.apply(n,arguments);return 0===n.length&&delete n[0],r?new X(e):e}}),a}var r,e=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==e&&module,a=typeof global=="object"&&global;(a.globatrue===a||a.window===a)&&(n=a);var o=0,i={},c=+new Date+"",l=75,f=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,g=/&(?:amp|lt|gt|quot|#39);/g,v=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/\w*$/,y=/<%=([\s\S]+?)%>/g,m=(m=/\bthis\b/)&&m.test(t)&&m,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",b=RegExp("^["+d+"]*0+(?=.$)"),_=/($^)/,C=/[&<>"']/g,j=/['\n\r\t\u2028\u2029\\]/g,w="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),O="[object Arguments]",E="[object Array]",S="[object Boolean]",A="[object Date]",I="[object Error]",B="[object Function]",N="[object Number]",P="[object Object]",z="[object RegExp]",F="[object String]",$={}; +}}),xr.spliceObjects||Nr(["pop","shift","splice"],function(n){var t=Mt[n],r="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,e=t.apply(n,arguments);return 0===n.length&&delete n[0],r?new X(e):e}}),a}var r,e=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==e&&module,a=typeof global=="object"&&global;(a.global===a||a.window===a)&&(n=a);var o=0,i={},c=+new Date+"",l=75,f=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,g=/&(?:amp|lt|gt|quot|#39);/g,v=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/\w*$/,y=/<%=([\s\S]+?)%>/g,m=(m=/\bthis\b/)&&m.test(t)&&m,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",b=RegExp("^["+d+"]*0+(?=.$)"),_=/($^)/,C=/[&<>"']/g,j=/['\n\r\t\u2028\u2029\\]/g,w="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),O="[object Arguments]",E="[object Array]",S="[object Boolean]",A="[object Date]",I="[object Error]",B="[object Function]",N="[object Number]",P="[object Object]",z="[object RegExp]",F="[object String]",$={}; $[B]=!1,$[O]=$[E]=$[S]=$[A]=$[N]=$[P]=$[z]=$[F]=!0;var q={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},D={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},R=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=R, define(function(){return R})):e&&!e.nodeType?u?(u.exports=R)._=R:e._=R:n._=R}(this); \ No newline at end of file diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 000d39575..4d677a540 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -9,7 +9,7 @@ if(!u)return a;for(var o=arguments,i=0,f=typeof e=="number"?2:o.length;++it||typeof n=="undefined")return 1;if(n=s&&G.indexOf!=l,y={},h={"false":a,"function":a,"null":a,number:{},object:y,string:{},"true":a,undefined:a};if(g){for(;++ce?0:e);++re?0:e);++r