diff --git a/build.js b/build.js index 10a8e0522..db656ceb4 100755 --- a/build.js +++ b/build.js @@ -173,7 +173,7 @@ 'bottom', 'firstArg', 'hasDontEnumBug', - 'isKeysFast', + 'isKeysNative', 'loop', 'nonEnumArgs', 'noCharByIndex', @@ -889,16 +889,14 @@ * @returns {String} Returns the modified source. */ function removeKeysOptimization(source) { - source = removeVar(source, 'isKeysFast'); - // remove optimized branch in `iteratorTemplate` source = source.replace(getIteratorTemplate(source), function(match) { - return match.replace(/(?: *\/\/.*\n)* *["']( *)<% *if *\(isKeysFast[\s\S]+?["']\1<% *} *else *{ *%>.+\n([\s\S]+?) *["']\1<% *} *%>.+/, "'\\n' +\n$2"); + return match.replace(/(?: *\/\/.*\n)* *["']( *)<% *if *\(isKeysNative[\s\S]+?["']\1<% *} *else *{ *%>.+\n([\s\S]+?) *["']\1<% *} *%>.+/, "'\\n' +\n$2"); }); // remove data object property assignment in `createIterator` source = source.replace(matchFunction(source, 'createIterator'), function(match) { - return match.replace(/ *'isKeysFast':.+\n/, ''); + return match.replace(/ *'isKeysNative':.+\n/, ''); }); return source; @@ -1382,7 +1380,7 @@ source = setUseStrictOption(source, isStrict); if (isLegacy) { - _.each(['getPrototypeOf', 'isBindFast', 'isKeysFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'], function(varName) { + _.each(['getPrototypeOf', 'isBindFast', 'nativeBind', 'nativeIsArray', 'nativeKeys'], function(varName) { source = replaceVar(source, varName, 'false'); }); @@ -1401,9 +1399,10 @@ // remove `_.templateSettings.imports assignment source = source.replace(/,[^']*'imports':[^}]+}/, ''); - // remove large array optimizations + // remove large array and keys optimizations source = removeFunction(source, 'cachedContains'); source = removeVar(source, 'largeArraySize'); + source = removeKeysOptimization(source); // replace `_.assign` source = replaceFunction(source, 'assign', [ @@ -1700,8 +1699,6 @@ } } if (isMobile) { - source = replaceVar(source, 'isKeysFast', 'false'); - source = removeKeysOptimization(source); source = removeNoNodeClass(source); // remove `prototype` [[Enumerable]] fix from `_.keys` diff --git a/build/post-compile.js b/build/post-compile.js index 23d91afe8..cbe27dd9e 100644 --- a/build/post-compile.js +++ b/build/post-compile.js @@ -41,7 +41,7 @@ // flip `typeof` expressions to help optimize Safari and // correct the AMD module definition for AMD build optimizers // (e.g. from `"number" == typeof x` to `typeof x == "number") - source = source.replace(/(\w)?("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[.\w[\]]+))/g, function(match, other, type, equality, expression) { + source = source.replace(/(\w)?("[^"]+")\s*([!=]=)\s*(typeof(?:\s*\([^)]+\)|\s+[.\w]+(?!\[)))/g, function(match, other, type, equality, expression) { return (other ? other + ' ' : '') + expression + equality + type; }); diff --git a/build/pre-compile.js b/build/pre-compile.js index 6ffee418e..22a92ff0c 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -39,7 +39,7 @@ 'bottom', 'firstArg', 'hasDontEnumBug', - 'isKeysFast', + 'isKeysNative', 'loop', 'nonEnumArgs', 'noCharByIndex', @@ -275,14 +275,15 @@ // minify properties properties.forEach(function(property, index) { - var reBracketProp = RegExp("\\['(" + property + ")'\\]", 'g'), + var minName = minNames[index], + reBracketProp = RegExp("\\['(" + property + ")'\\]", 'g'), reDotProp = RegExp('\\.' + property + '\\b', 'g'), rePropColon = RegExp("([^?\\s])\\s*([\"'])?\\b" + property + "\\2 *:", 'g'); modified = modified - .replace(reBracketProp, "['" + minNames[index] + "']") - .replace(reDotProp, "['" + minNames[index] + "']") - .replace(rePropColon, "$1'" + minNames[index] + "':"); + .replace(reBracketProp, "['" + minName + "']") + .replace(reDotProp, "['" + minName + "']") + .replace(rePropColon, "$1'" + minName + "':"); }); // replace with modified snippet @@ -320,35 +321,36 @@ }); if (isCreateIterator) { - // replace with modified snippet early and clip snippet to the `factory` - // call so other arguments aren't minified + // replace with modified snippet early and clip snippet source = source.replace(snippet, modified); - snippet = modified = modified.replace(/factory\([\s\S]+$/, ''); + snippet = modified = modified.replace(/^[\s\S]+?data *= *{[^}]+}.+|return factory\([\s\S]+$/g, ''); } - // minify snippet variables / arguments compiledVars.forEach(function(variable, index) { + var minName = minNames[index]; + // ensure properties in compiled strings aren't minified - modified = modified.replace(RegExp('([^.]\\b)' + variable + '\\b(?!\' *[\\]:])', 'g'), '$1' + minNames[index]); + modified = modified.replace(RegExp('([^.]\\b)' + variable + '\\b(?!\' *[\\]:])', 'g'), '$1' + minName); // correct `typeof` values if (/^(?:boolean|function|object|number|string|undefined)$/.test(variable)) { - modified = modified.replace(RegExp("(typeof [^']+')" + minNames[index] + "'", 'g'), '$1' + variable + "'"); + modified = modified.replace(RegExp("(typeof [^']+')" + minName + "'", 'g'), '$1' + variable + "'"); } }); // minify `createIterator` option property names iteratorOptions.forEach(function(property, index) { + var minName = minNames[index]; if (isIteratorTemplate) { // minify property names as interpolated template variables - modified = modified.replace(RegExp('\\b' + property + '\\b', 'g'), minNames[index]); + modified = modified.replace(RegExp('\\b' + property + '\\b', 'g'), minName); } else { // minify property name strings - modified = modified.replace(RegExp("'" + property + "'", 'g'), "'" + minNames[index] + "'"); + modified = modified.replace(RegExp("'" + property + "'", 'g'), "'" + minName + "'"); // minify property names in accessors if (isCreateIterator) { - modified = modified.replace(RegExp('\\.' + property + '\\b' , 'g'), '.' + minNames[index]); + modified = modified.replace(RegExp('\\.' + property + '\\b' , 'g'), '.' + minName); } } }); diff --git a/lodash.js b/lodash.js index 4458143f0..dadc7af57 100644 --- a/lodash.js +++ b/lodash.js @@ -117,14 +117,10 @@ stringClass = '[object String]'; /** Detect various environments */ - var isIeOpera = !!window.attachEvent, - isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera); + var isIeOpera = !!window.attachEvent; /* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */ - var isBindFast = nativeBind && !isV8; - - /* Detect if `Object.keys` exists and is inferred to be fast (IE, Opera, V8) */ - var isKeysFast = nativeKeys && (isIeOpera || isV8); + var isBindFast = nativeBind && /\n|true/.test(nativeBind + isIeOpera); /** * Detect the JScript [[DontEnum]] bug: @@ -414,7 +410,7 @@ ' <% } %>' + // iterate own properties using `Object.keys` if it's fast - ' <% if (isKeysFast && useHas) { %>\n' + + ' <% if (isKeysNative && useHas) { %>\n' + ' var ownIndex = -1,\n' + ' ownProps = objectTypes[typeof iteratee] ? nativeKeys(iteratee) : [],\n' + ' length = ownProps.length;\n\n' + @@ -673,7 +669,7 @@ var data = { // support properties 'hasDontEnumBug': hasDontEnumBug, - 'isKeysFast': isKeysFast, + 'isKeysNative': nativeKeys, 'nonEnumArgs': nonEnumArgs, 'noCharByIndex': noCharByIndex, 'shadowed': shadowed, diff --git a/lodash.min.js b/lodash.min.js index 7bec0348f..7a06e217f 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -4,36 +4,36 @@ * Underscore.js 1.4.3 underscorejs.org/LICENSE */ ;(function(n,t){function r(n){return n&&typeof n=="object"&&n.__wrapped__?n:this instanceof r?(this.__wrapped__=n,void 0):new r(n)}function e(n,t,r){t||(t=0);var e=n.length,u=e-t>=(r||it);if(u)for(var o={},r=t-1;++rt||typeof n=="undefined")return 1;if(ne;e++)r+="i='"+t.j[e]+"';if(","constructor"==t.j[e]&&(r+="!(f&&f.prototype===l)&&"),r+="h.call(l,i)){"+t.g+"}"; -return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,or,Dt,kt)}function c(n){return"\\"+ir[n]}function l(n){return hr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?It(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):lr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),lr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function I(n,t){return F(n,t+"")}function T(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(_r(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; -if(typeof o!="number")var f=gr(n),o=f.length;else nr&&A(n)&&(u=n.split(""));return t=a(t,e,ot),R(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(_r(n))for(var r=-1,u=n.length;++rr?It(0,u+r):r||0)-1;else if(r)return e=L(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function V(n,t){return Jt||qt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,qt=ht.test(qt=v.bind)&&qt,Nt=ht.test(Nt=Array.isArray)&&Nt,Rt=n.isFinite,Ft=n.isNaN,Dt=ht.test(Dt=Object.keys)&&Dt,It=Math.max,Tt=Math.min,Bt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Lt="[object Object]",Ut="[object RegExp]",Vt="[object String]",Gt=!!n.attachEvent,Ht=qt&&!/\n|true/.test(qt+Gt),Jt=qt&&!Ht,Qt=Dt&&(Gt||Ht),Wt=(Wt={0:1,length:1},rt.splice.call(Wt,0,1),Wt[0]),Xt=Q; -(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Xt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Yt=arguments.constructor==Object,Zt=!h(arguments),nr="xx"!="x"[0]+Object("x")[0];try{var tr=$t.call(document)==Lt}catch(rr){}var er={"[object Function]":X};er[Mt]=er[Pt]=er[zt]=er[Ct]=er[Kt]=er[Lt]=er[Ut]=er[Vt]=Q;var ur={};ur[Pt]=Array,ur[zt]=Boolean,ur[Ct]=Date,ur[Lt]=Object,ur[Kt]=Number,ur[Ut]=RegExp,ur[Vt]=String;var or={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ir={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; -r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var ar={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},yr=b(hr),mr=f(ar,{g:"if(t[i]==null)"+ar.g}),_r=Nt||function(n){return Yt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var dr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},r.assign=pr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(nr&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return R(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=gr,r.map=F,r.max=D,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; -return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&_r(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) -}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=gr(n),e=r.length,u=Array(e);++tr?It(0,e+r):Tt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=H,r.noConflict=function(){return n._=at,this -},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Bt()*((+t||0)-n+1))},r.reduce=T,r.reduceRight=B,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:gr(n).length},r.some=M,r.sortedIndex=L,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=mr({},u,o),i=mr({},u.imports,o.imports),o=gr(i),i=S(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t +return(t.b||t.h)&&(r+="}"),r+=t.c+";return t",Function("e,h,j,k,p,n,s","return function("+n+"){"+r+"}")(a,Et,h,A,er,Ft,kt)}function c(n){return"\\"+ur[n]}function l(n){return vr[n]}function p(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function s(){}function v(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);for(var e=-1,r=r-t||0,u=Array(0>r?0:r);++er?Bt(0,u+r):r)||0;return typeof u=="number"?o=-1<(A(n)?n.indexOf(t,r):C(n,t,r)):fr(n,function(n){return++eo&&(o=f)}else t=!t&&A(n)?u:a(t,r),fr(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function B(n,t){return R(n,t+"")}function I(n,t,r,e){var u=3>arguments.length,t=a(t,e,ot);if(yr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length; +if(typeof o!="number")var f=sr(n),o=f.length;else Yt&&A(n)&&(u=n.split(""));return t=a(t,e,ot),D(n,function(n,e,a){e=f?f[--o]:--o,r=i?(i=X,u[e]):t(r,u[e],e,a)}),r}function M(n,t,r){var e,t=a(t,r);if(yr(n))for(var r=-1,u=n.length;++rr?Bt(0,u+r):r||0)-1;else if(r)return e=H(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])C(f,p))&&((r||c)&&f.push(p),i.push(e))}return i}function U(n,t){return Gt||Nt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,ct=/&(?:amp|lt|gt|quot|#x27);/g,lt=/\b__p\+='';/g,pt=/\b(__p\+=)''\+/g,st=/(__e\(.*?\)|\b__t\))\+'';/g,vt=/\w*$/,gt=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,ht=RegExp("^"+(et.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),yt=/\$\{((?:(?=\\?)\\?[\s\S])*?)}/g,mt=/<%=([\s\S]+?)%>/g,_t=/($^)/,dt=/[&<>"']/g,bt=/['\n\r\t\u2028\u2029\\]/g,wt="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),jt=Math.ceil,xt=rt.concat,Ot=Math.floor,At=ht.test(At=Object.getPrototypeOf)&&At,Et=et.hasOwnProperty,St=rt.push,kt=et.propertyIsEnumerable,$t=et.toString,Nt=ht.test(Nt=v.bind)&&Nt,qt=ht.test(qt=Array.isArray)&&qt,Dt=n.isFinite,Rt=n.isNaN,Ft=ht.test(Ft=Object.keys)&&Ft,Bt=Math.max,It=Math.min,Tt=Math.random,Mt="[object Arguments]",Pt="[object Array]",zt="[object Boolean]",Ct="[object Date]",Kt="[object Number]",Ht="[object Object]",Lt="[object RegExp]",Ut="[object String]",Vt=!!n.attachEvent,Gt=Nt&&/\n|true/.test(Nt+Vt),Jt=(Jt={0:1,length:1},rt.splice.call(Jt,0,1),Jt[0]),Qt=Q; +(function(){function n(){this.x=1}var t=[];n.prototype={valueOf:1,y:1};for(var r in new n)t.push(r);for(r in arguments)Qt=!r;nt=!/valueOf/.test(t),tt="x"!=t[0]})(1);var Wt=arguments.constructor==Object,Xt=!h(arguments),Yt="xx"!="x"[0]+Object("x")[0];try{var Zt=$t.call(document)==Ht}catch(nr){}var tr={"[object Function]":X};tr[Mt]=tr[Pt]=tr[zt]=tr[Ct]=tr[Kt]=tr[Ht]=tr[Lt]=tr[Ut]=Q;var rr={};rr[Pt]=Array,rr[zt]=Boolean,rr[Ct]=Date,rr[Ht]=Object,rr[Kt]=Number,rr[Lt]=RegExp,rr[Ut]=String;var er={"boolean":X,"function":Q,object:Q,number:X,string:X,undefined:X},ur={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +r.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:mt,variable:"",imports:{_:r}};var or={a:"o,v,g",k:"var a=0,b=typeof g=='number'?2:arguments.length;while(++a":">",'"':""","'":"'"},gr=b(vr),hr=f(or,{g:"if(t[i]==null)"+or.g}),yr=qt||function(n){return Wt&&n instanceof Array||$t.call(n)==Pt};j(/x/)&&(j=function(n){return n instanceof Function||"[object Function]"==$t.call(n)});var mr=At?function(n){if(!n||typeof n!="object")return X;var t=n.valueOf,r=typeof t=="function"&&(r=At(t))&&At(r);return r?n==r||At(n)==r&&!h(n):y(n)}:y;r.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 +}},r.assign=cr,r.at=function(n){var t=-1,r=xt.apply(rt,v(arguments,1)),e=r.length,u=Array(e);for(Yt&&A(n)&&(n=n.split(""));++tC(c,l)){a&&c.push(l);for(var s=r;--s;)if(!(u[s]||(u[s]=e(t[s],0,100)))(l))continue n;f.push(l)}}return f},r.invert=b,r.invoke=function(n,t){var r=v(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0);return D(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},r.keys=sr,r.map=R,r.max=F,r.memoize=function(n,t){var r={};return function(){var e=(t?t.apply(this,arguments):arguments[0])+""; +return Et.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},r.merge=E,r.min=function(n,t,r){var e=1/0,o=e;if(!t&&yr(n))for(var r=-1,i=n.length;++rC(o,r,1))&&(u[r]=n) +}),u},r.once=function(n){var t,r;return function(){return t?r:(t=Q,r=n.apply(this,arguments),n=W,r)}},r.pairs=function(n){for(var t=-1,r=sr(n),e=r.length,u=Array(e);++tr?Bt(0,e+r):It(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},r.mixin=G,r.noConflict=function(){return n._=at,this +},r.random=function(n,t){return n==W&&t==W&&(t=1),n=+n||0,t==W&&(t=n,n=0),n+Ot(Tt()*((+t||0)-n+1))},r.reduce=I,r.reduceRight=T,r.result=function(n,t){var r=n?n[t]:W;return j(r)?n[t]():r},r.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:sr(n).length},r.some=M,r.sortedIndex=H,r.template=function(n,e,u){var o=r.templateSettings;n||(n="");var u=hr({},u,o),i=hr({},u.imports,o.imports),o=sr(i),i=S(i),a=0,f=u.interpolate||_t,l=!(1==o.length&&"_"==o[0]&&i[0]===r),p="__p+='";if(n.replace(RegExp((u.escape||_t).source+"|"+f.source+"|"+(f===mt?yt:_t).source+"|"+(u.evaluate||_t).source+"|$","g"),function(t,r,e,u,o,i){return e||(e=u),p+=n.slice(a,i).replace(bt,c),r&&(p+="'+__e("+r+")+'"),o&&(p+="';"+o+";__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l||(l=o||ft.test(r||e)),a=i+t.length,t }),p+="';\n",f=u=u.variable,!f)if(u="obj",l)p="with("+u+"){"+p+"}";else var s=RegExp("(\\(\\s*)"+u+"\\."+u+"\\b","g"),p=p.replace(gt,"$&"+u+".").replace(s,"$1__d");p=(l?p.replace(lt,""):p).replace(pt,"$1").replace(st,"$1;"),p="function("+u+"){"+(f?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(l?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":(f?"":",__d="+u+"."+u+"||"+u)+";")+p+"return __p}";try{var v=Function(o,"return "+p).apply(t,i)}catch(g){throw g.source=p,g}return e?v(e):(v.source=p,v) -},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=N,r.foldl=T,r.foldr=B,r.include=k,r.inject=T,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,It(0,e-t))}},r.take=P,r.head=P,vr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); -return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,lr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),lr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),lr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) -}}),Wt&&lr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file +},r.unescape=function(n){return n==W?"":(n+"").replace(ct,g)},r.uniqueId=function(n){var t=++ut;return(n==W?"":n+"")+t},r.all=$,r.any=M,r.detect=q,r.foldl=I,r.foldr=T,r.include=k,r.inject=I,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(){var t=[this.__wrapped__];return St.apply(t,arguments),n.apply(r,t)})}),r.first=P,r.last=function(n,t,r){if(n){var e=n.length;return t==W||r?n[e-1]:v(n,Bt(0,e-t))}},r.take=P,r.head=P,pr(r,function(n,t){r.prototype[t]||(r.prototype[t]=function(t,e){var u=n(this.__wrapped__,t,e); +return t==W||e?u:new r(u)})}),r.VERSION="1.0.0-rc.3",r.prototype.toString=function(){return this.__wrapped__+""},r.prototype.value=J,r.prototype.valueOf=J,fr(["join","pop","shift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),fr(["push","reverse","sort","unshift"],function(n){var t=rt[n];r.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),fr(["concat","slice","splice"],function(n){var t=rt[n];r.prototype[n]=function(){return new r(t.apply(this.__wrapped__,arguments)) +}}),Jt&&fr(["pop","shift","splice"],function(n){var t=rt[n],e="splice"==n;r.prototype[n]=function(){var n=this.__wrapped__,u=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new r(u):u}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=r,define(function(){return r})):Y?typeof module=="object"&&module&&module.exports==Y?(module.exports=r)._=r:Y._=r:n._=r})(this); \ No newline at end of file diff --git a/lodash.underscore.js b/lodash.underscore.js index 7a40320f8..0467fe280 100644 --- a/lodash.underscore.js +++ b/lodash.underscore.js @@ -115,11 +115,10 @@ stringClass = '[object String]'; /** Detect various environments */ - var isIeOpera = !!window.attachEvent, - isV8 = nativeBind && !/\n|true/.test(nativeBind + isIeOpera); + var isIeOpera = !!window.attachEvent; /* Detect if `Function#bind` exists and is inferred to be fast (all but V8) */ - var isBindFast = nativeBind && !isV8; + var isBindFast = nativeBind && /\n|true/.test(nativeBind + isIeOpera); /** * Detect if `Array#shift` and `Array#splice` augment array-like objects diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index b6a76ba40..5790fb0da 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -14,7 +14,7 @@ if(o!=At)return K;var o=n.constructor,a=t.constructor;if(o!=a&&(!b(o)||!(o insta });return i}function R(n,t,r){var e=-1/0,o=e;if(!t&&Bt(n))for(var r=-1,i=n.length;++ro&&(o=a)}else t=f(t,r),u(n,function(n,r,u){r=t(n,r,u),r>e&&(e=r,o=n)});return o}function T(n,t){return F(n,t+"")}function q(n,t,r,e){var o=3>arguments.length,t=f(t,e,Y);if(Bt(n)){var i=-1,a=n.length;for(o&&(r=n[++i]);++iarguments.length;if(typeof u!="number")var i=Rt(n),u=i.length; return t=f(t,e,Y),N(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,t,r){var e,t=f(t,r);if(Bt(n))for(var r=-1,o=n.length;++rr?yt(0,u+r):r||0)-1; else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])I(a,c))&&(r&&a.push(c),i.push(e))}return i}function U(n,t){return Ot||st&&2"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Q=st&&!/\n|true/.test(st+Q),Ot=st&&!Q,St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; +}function V(n){return n}function G(n){N(_(n),function(t){var r=o[t]=n[t];o.prototype[t]=function(){var n=[this.__wrapped__];return ct.apply(n,arguments),n=r.apply(o,n),this.__chain__&&(n=new o(n),n.__chain__=H),n}})}var H=!0,J=null,K=!1,L=typeof exports=="object"&&exports,Q=typeof global=="object"&&global;Q.global===Q&&(n=Q);var W=[],Q=new function(){},X=0,Y=Q,Z=n._,nt=/&(?:amp|lt|gt|quot|#x27);/g,tt=RegExp("^"+(Q.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),rt=/($^)/,et=/[&<>"']/g,ut=/['\n\r\t\u2028\u2029\\]/g,ot=Math.ceil,it=W.concat,at=Math.floor,ft=Q.hasOwnProperty,ct=W.push,lt=Q.toString,st=tt.test(st=p.bind)&&st,pt=tt.test(pt=Array.isArray)&&pt,vt=n.isFinite,gt=n.isNaN,ht=tt.test(ht=Object.keys)&&ht,yt=Math.max,_t=Math.min,mt=Math.random,dt="[object Array]",bt="[object Boolean]",jt="[object Date]",wt="[object Number]",At="[object Object]",xt="[object RegExp]",Et="[object String]",Q=!!n.attachEvent,Ot=st&&/\n|true/.test(st+Q),St=(St={0:1,length:1},W.splice.call(St,0,1),St[0]),kt=arguments.constructor==Object,Nt={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},Ft={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"}; o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},o.isArguments=function(n){return"[object Arguments]"==lt.call(n)},o.isArguments(arguments)||(o.isArguments=function(n){return n?ft.call(n,"callee"):K});var Rt=ht?function(n){return j(n)?ht(n):[]}:h,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},qt=m(Tt),Bt=pt||function(n){return kt&&n instanceof Array||lt.call(n)==dt};b(/x/)&&(b=function(n){return n instanceof Function||"[object Function]"==lt.call(n) }),o.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},o.bind=U,o.bindAll=function(n){for(var t=arguments,r=1I(e,o,r)&&u.push(o)