diff --git a/build.js b/build.js index 776328a765..b8402dc19a 100755 --- a/build.js +++ b/build.js @@ -542,7 +542,7 @@ function matchFunction(source, funcName) { var result = source.match(RegExp( // match multi-line comment block (could be on a single line) - '\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/\\n' + + '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/\\n)?' + // begin non-capturing group '(?:' + // match a function declaration @@ -733,16 +733,12 @@ source = source.replace(RegExp('(var ' + varName + ' *=)[\\s\\S]+?(true;\\n)'), '$1$2'); } source = source.replace(RegExp( - // begin non-capturing group - '(?:' + // match multi-line comment block '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/)?\\n' + // match a variable declaration that's not part of a declaration list '( +)var ' + varName + ' *= *(?:.+?(?:;|&&\\n[^;]+;)|(?:\\w+\\(|{)[\\s\\S]+?\\n\\1.+?;)\\n|' + // match a variable in a declaration list - '\\n +' + varName + ' *=.+?,' + - // end non-capturing group - ')' + '\\n +' + varName + ' *=.+?,' ), ''); // remove a varaible at the start of a variable declaration list @@ -1050,17 +1046,76 @@ source = removeVar(source, 'arrayLikeClasses'); source = removeVar(source, 'cloneableClasses'); - // remove large array optimizations from `cachedContains` - source = source.replace(/( +)function cachedContains[\s\S]+?\n\1}/, [ - ' function cachedContains(array, fromIndex) {', - ' return function(value) {', - ' return indexOf(array, value, fromIndex || 0) > -1;', - ' };', + // remove large array optimizations + source = removeFunction(source, 'cachedContains'); + source = removeVar(source, 'largeArraySize'); + + // replace `_.clone` + source = source.replace(/( +)function clone[\s\S]+?\n\1}/, [ + ' function clone(value) {', + ' return value && objectTypes[typeof value]', + ' ? (isArray(value) ? slice.call(value) : extend({}, value))', + ' : value', ' }' ].join('\n')); - // reduce the number of arguments passed to `cachedContains` from 3 to 2 - source = source.replace(/(cachedContains\(\w+, *\w+), *\w+/g, '$1'); + // replace `_.difference` + source = source.replace(/( +)function difference[\s\S]+?\n\1}/, [ + ' function difference(array) {', + ' var index = -1,', + ' length = array.length,', + ' flattened = concat.apply(ArrayProto, arguments),', + ' result = [];', + '', + ' while (++index < length) {', + ' var value = array[index]', + ' if (indexOf(flattened, value, length) < 0) {', + ' result.push(value);', + ' }', + ' }', + ' return result', + ' }' + ].join('\n')); + + // replace `_.intersection` + source = source.replace(/( +)function intersection[\s\S]+?\n\1}/, [ + ' function intersection(array) {', + ' var argsLength = arguments.length,', + ' index = -1,', + ' length = array.length,', + ' result = [];', + '', + ' array: while (++index < length) {', + ' var value = array[index]', + ' if (indexOf(result, value) < 0) {', + ' for (var argsIndex = 1; argsIndex < argsLength; argsIndex++) {', + ' if (indexOf(arguments[argsIndex], value) < 0) {', + ' continue array;', + ' }', + ' }', + ' result.push(value);', + ' }', + ' }', + ' return result', + ' }' + ].join('\n')); + + // replace `_.without` + source = source.replace(/( +)function without[\s\S]+?\n\1}/, [ + ' function without(array) {', + ' var index = -1,', + ' length = array.length,', + ' result = [];', + '', + ' while (++index < length) {', + ' var value = array[index]', + ' if (indexOf(arguments, value, 1) < 0) {', + ' result.push(value);', + ' }', + ' }', + ' return result', + ' }' + ].join('\n')); // replace `arrayLikeClasses` in `_.isEmpty` source = source.replace(/'if *\(arrayLikeClasses[\s\S]+?' \|\|\\n/, "'if (isArray(value) || className == stringClass ||"); @@ -1069,19 +1124,10 @@ source = source.replace(/(?: *\/\/.*\n)*( +)var isArr *= *arrayLikeClasses[^}]+}/, '$1var isArr = isArray(a);'); // remove "exit early" feature from `_.each` - source = source.replace(/( )+var baseIteratorOptions *=[\s\S]+?\n\1.+?;/, function(match) { + source = source.replace(/( +)var baseIteratorOptions *=[\s\S]+?\n\1.+?;/, function(match) { return match.replace(/if *\(callback[^']+/, 'callback(value, index, collection)'); }); - // remove `deep` clone functionality - source = source.replace(/( +)function clone[\s\S]+?\n\1}/, [ - ' function clone(value) {', - ' return value && objectTypes[typeof value]', - ' ? (isArray(value) ? slice.call(value) : extend({}, value))', - ' : value', - ' }' - ].join('\n')); - // remove unused features from `createBound` if (buildMethods.indexOf('partial') == -1) { source = source.replace(matchFunction(source, 'createBound'), function(match) { diff --git a/lodash.underscore.min.js b/lodash.underscore.min.js index 071e91cea1..e591fc0ae4 100644 --- a/lodash.underscore.min.js +++ b/lodash.underscore.min.js @@ -2,34 +2,34 @@ Lo-Dash 0.8.0 lodash.com/license Underscore.js 1.4.0 underscorejs.org/LICENSE */ -;(function(e,t){function s(e,t,r){var s,t=T(t,r),o=e.length,r=-1;if(o===+o){for(;++rarguments.length,t=T(t,r),f=e.length;s=-1;if(f===+f)for(a&&(u=e[++s]);++sn||e===t)return 1;if(earguments.length;if(s!==+s)var u=Dt(e),s=u.length;return f(e,function(a,f,l){f=u?u[--s]:--s,n=o?(o=i,e[f]):t.call(r,n,e[f],f,l)}),n}function D(e,t,n){return t==r||n?e[0]:at.call(e,0,t)}function P(e,t){for(var n,r=-1,i=e.length,s= -[];++rn?mt(0,i+n):n)-1}for(;++rr&&(r=n,o=e[i]);return o}function j(e,t,n){return at.call(e,t==r||n?1:t)}function F(e,t,n,r){for(var i=0,s=e.length,n=T(n,r),t=n(t);i>>1,n(e[r])H(a,r))a.push(r),u.push(e[s]);return u}function q(e,t){return kt||lt&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,K=/&(?:amp|lt|gt|quot|#x27);/g,Q=/\b__p\+='';/g,G=/\b(__p\+=)''\+/g,Y=/(__e\(.*?\)|\b__t\))\+'';/g,Z=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,et=RegExp("^"+(X.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g -,".+?")+"$"),tt=/($^)/,nt=/[&<>"']/g,rt=/['\n\r\t\u2028\u2029\\]/g,it=W.concat,st=X.hasOwnProperty,ot=W.push,ut=X.propertyIsEnumerable,at=W.slice,ft=X.toString,lt=et.test(lt=at.bind)&<,ct=Math.floor,ht=et.test(ht=Object.getPrototypeOf)&&ht,pt=et.test(pt=Array.isArray)&&pt,dt=e.isFinite,vt=et.test(vt=Object.keys)&&vt,mt=Math.max,gt=Math.min,yt=Math.random,bt="[object Boolean]",wt="[object Date]",Et="[object Number]",St="[object Object]",xt="[object RegExp]",Tt="[object String]",Nt=e.clearTimeout -,Ct=e.setTimeout,kt=lt&&/\n|Opera/.test(lt+ft.call(e.opera)),Lt={"boolean":i,"function":n,object:n,number:i,string:i,"undefined":i,unknown:n},At={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};w.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},w.isArguments=function(e){return"[object Arguments]"==ft.call(e)},w.isArguments(arguments)||(w.isArguments=function(e){return!!e&&!!st.call(e,"callee")});var Ot= -pt||function(e){return"[object Array]"==ft.call(e)};A(/x/)&&(A=function(e){return"[object Function]"==ft.call(e)});var X=ht?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=ht(t))&&ht(n);return n?e==n||ht(e)==n&&!isArguments(e):O(e)}:O,Mt={"&":"&","<":"<",">":">",'"':""","'":"'"},_t=b(Mt),Dt=vt?function(e){return"function"==typeof e&&ut.call(e,"prototype")?y(e):vt(e)}:y;w.VERSION="0.8.0",w.after=function(e,t){return 1>e?t():function(){if(1>-- -e)return t.apply(this,arguments)}},w.bind=q,w.bindAll=function(e){var t,n=e,r=e,i=arguments,s=i.length;if(1H(o,t)){for(var u=1;un?mt(0,r+n):gt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},w.map=a,w.max=B,w.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this -,arguments):arguments[0];return st.call(n,r)?n[r]:n[r]=e.apply(this,arguments)}},w.min=function(e,t,n){for(var r=Infinity,i=-1,s=e?e.length:0,o=r,t=T(t,n);++iH(a,r))o[r]=i;return o},w.once=function(e){var t,s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},w.pairs=function(e){var t,n,r=[];for(t in e)st.call(e,t)&&(n=e[t],r.push([t,n]));return r},w.pick=function(e,t,n){var r,i,s=e,o={};if("function"!=typeof t){var s=it.apply(W,arguments),u=s.length;for(r=1;r=f?(a= -r,s=e.apply(o,i)):u||(u=Ct(n,f)),s}},w.times=function(e,t,n){for(var e=+e||0,r=-1,i=Array(e);++rH(r,t[e])&&r.push(t[e]);return r},w.uniq=I,w.uniqueId=function(e){var t=V++;return e?e+t:t},w.values=d,w.where=function(e,t){var r, -i,s=[],o=[];m(t,function(e,t){o.push(t)});var u=o.length,a=e.length;r=-1;if(a===+a)for(;++rarguments.length,t=x(t,r),f=e.length;s=-1;if(f===+f)for(a&&(u=e[++s]);++sn||e===t)return 1;if(earguments.length;if(s!==+s)var u=_t(e),s=u.length;return f(e,function(a,f,l){f=u?u[--s]:--s,n=o?(o=i,e[f]):t.call(r,n,e[f],f,l)}),n}function _(e,t,n){return t==r||n?e[0]:ut.call(e,0,t)}function D(e,t){for(var n,r=-1,i=e.length,s=[];++rn?vt(0,i+n):n)-1}for(;++rr&&(r=n,o=e[i]);return o}function B(e,t,n){return ut.call(e,t==r||n?1:t)}function j(e,t,n,r){for(var i=0,s=e.length,n=x(n,r),t=n(t);i>>1,n(e[r])P(a,r))a.push(r),u.push(e[s]);return u}function I(e,t){return Ct||ft&&2|{(\/]|\[\D|\b(?:delete|in|instanceof|new|typeof|void)\b/,J=/&(?:amp|lt|gt|quot|#x27);/g,K=/\b__p\+='';/g,Q=/\b(__p\+=)''\+/g,G=/(__e\(.*?\)|\b__t\))\+'';/g,Y=/(?:__e|__t=)\(\s*(?![\d\s"']|this\.)/g,Z=RegExp("^"+(W.valueOf+"").replace(/[.*+?^=!:${}()|[\]\/\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),et=/($^)/,tt=/[&<>"']/g,nt=/['\n\r\t\u2028\u2029\\]/g +,rt=z.concat,it=W.hasOwnProperty,st=z.push,ot=W.propertyIsEnumerable,ut=z.slice,at=W.toString,ft=Z.test(ft=ut.bind)&&ft,lt=Math.floor,ct=Z.test(ct=Object.getPrototypeOf)&&ct,ht=Z.test(ht=Array.isArray)&&ht,pt=e.isFinite,dt=Z.test(dt=Object.keys)&&dt,vt=Math.max,mt=Math.min,gt=Math.random,yt="[object Boolean]",bt="[object Date]",wt="[object Number]",Et="[object Object]",St="[object RegExp]",xt="[object String]",Tt=e.clearTimeout,Nt=e.setTimeout,Ct=ft&&/\n|Opera/.test(ft+at.call(e.opera)),kt={"boolean" +:i,"function":n,object:n,number:i,string:i,"undefined":i,unknown:n},Lt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"};w.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},w.isArguments=function(e){return"[object Arguments]"==at.call(e)},w.isArguments(arguments)||(w.isArguments=function(e){return!!e&&!!it.call(e,"callee")});var At=ht||function(e){return"[object Array]"==at.call(e)};L(/x/)&&(L=function( +e){return"[object Function]"==at.call(e)});var W=ct?function(e){if(!e||"object"!=typeof e)return i;var t=e.valueOf,n="function"==typeof t&&(n=ct(t))&&ct(n);return n?e==n||ct(e)==n&&!isArguments(e):A(e)}:A,Ot={"&":"&","<":"<",">":">",'"':""","'":"'"},Mt=b(Ot),_t=dt?function(e){return"function"==typeof e&&ot.call(e,"prototype")?y(e):dt(e)}:y;w.VERSION="0.8.0",w.after=function(e,t){return 1>e?t():function(){if(1>--e)return t.apply(this,arguments)}},w.bind=I,w.bindAll=function(e){ +var t,n=e,r=e,i=arguments,s=i.length;if(1P(r,s,n)&&i.push(s)}return i},w.escape=function(e){return e==r?"":(e+"").replace(tt,N)},w.every=h,w.extend=g,w.filter=c,w.find=l,w.first=_,w.flatten=D,w.forEach=f,w.forIn=m,w.forOwn=function(e,t,n){var r +,t=x(t,n);for(r in e)it.call(e,r)&&(n=e[r],t(n,r,e));return e},w.functions=v,w.groupBy=function(e,t,n){var r,i={},t=x(t,n),s=e.length,n=-1;if(s===+s)for(;++nP(i,s)){for(var o=1;oP(arguments[o],s))continue e;i.push(s)}}return i},w.invert=b,w.invoke=function(e,t){var n,r,i=e,s,o=ut.call(arguments,2),u="function"==typeof t,a=i.length;n=-1;if(a===+a)for(s=Array(a);++nn?vt(0,r+n):mt(n,r-1))+1);r--;)if(e[r]===t)return r;return-1},w.map=a,w.max=H,w.memoize=function(e,t){var n={};return function(){var r=t?t.apply(this,arguments):arguments[0];return it.call(n,r)?n[r]:n[r +]=e.apply(this,arguments)}},w.min=function(e,t,n){for(var r=Infinity,i=-1,s=e?e.length:0,o=r,t=x(t,n);++iP(a,r))o[r]=i;return o},w.once=function(e){var t, +s=i;return function(){return s?t:(s=n,t=e.apply(this,arguments),e=r,t)}},w.pairs=function(e){var t,n,r=[];for(t in e)it.call(e,t)&&(n=e[t],r.push([t,n]));return r},w.pick=function(e,t,n){var r,i,s=e,o={};if("function"!=typeof t){var s=rt.apply(z,arguments),u=s.length;for(r=1;r=f?(a=r,s=e.apply(o,i)):u||(u=Nt(n,f)),s}},w.times=function(e,t +,n){for(var e=+e||0,r=-1,i=Array(e);++rP(r,t[e])&&r.push(t[e]);return r},w.uniq=F,w.uniqueId=function(e){var t=X++;return e?e+t:t},w.values=d,w.where=function(e,t){var r,i,s=[],o=[];m(t,function(e,t){o.push(t)});var u=o.length, +a=e.length;r=-1;if(a===+a)for(;++rP(arguments,i,1)&&r.push(i)}return r},w.wrap=function(e,t){return function(){var n=[e];return arguments.length&&st.apply(n,arguments),t.apply(this,n)}},w.zip=function(e){for(var t=-1,n=H(u(arguments,"length" +)),r=Array(n);++t