From 6854fee73ecb335e3782ff687aac5d12fb8790c6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 21 Feb 2014 22:26:17 -0800 Subject: [PATCH] Remove array and object pools. --- dist/lodash.compat.js | 101 ++++------------------------- dist/lodash.compat.min.js | 118 +++++++++++++++++----------------- dist/lodash.js | 101 ++++------------------------- dist/lodash.min.js | 110 +++++++++++++++---------------- dist/lodash.underscore.js | 4 +- dist/lodash.underscore.min.js | 2 +- lodash.js | 101 ++++------------------------- 7 files changed, 153 insertions(+), 384 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 490ea5015..cabd81da7 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -23,9 +23,6 @@ /** Used as the size when optimizations are enabled for arrays */ var LARGE_ARRAY_SIZE = 40; - /** Used as the max size of the `arrayPool` and `objectPool` */ - var MAX_POOL_SIZE = 40; - /** Used as the semantic version number */ var version = '2.4.1'; @@ -85,10 +82,6 @@ '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' ); - /** Used to pool arrays and objects used internally */ - var arrayPool = [], - objectPool = []; - /** Used to assign default `context` object properties */ var contextProps = [ 'Array', 'Boolean', 'Date', 'Error', 'Function', 'Math', 'Number', 'Object', @@ -372,30 +365,6 @@ return '\\' + stringEscapes[match]; } - /** - * Gets an array from the array pool or creates a new one if the pool is empty. - * - * @private - * @returns {Array} The array from the pool. - */ - function getArray() { - return arrayPool.pop() || []; - } - - /** - * Gets an object from the object pool or creates a new one if the pool is empty. - * - * @private - * @returns {Object} The object from the pool. - */ - function getObject() { - return objectPool.pop() || { - 'criteria': null, - 'index': 0, - 'value': null - }; - } - /** * Checks if `value` is a DOM node in IE < 9. * @@ -409,32 +378,6 @@ return typeof value.toString != 'function' && typeof (value + '') == 'string'; } - /** - * Releases `array` back to the array pool. - * - * @private - * @param {Array} array The array to release. - */ - function releaseArray(array) { - array.length = 0; - if (arrayPool.length < MAX_POOL_SIZE) { - arrayPool.push(array); - } - } - - /** - * Releases `object` back to the object pool. - * - * @private - * @param {Object} object The object to release. - */ - function releaseObject(object) { - object.criteria = object.value = null; - if (objectPool.length < MAX_POOL_SIZE) { - objectPool.push(object); - } - } - /** * A fallback implementation of `trim` to remove leading and trailing * whitespace or specified characters from `string`. @@ -1136,8 +1079,8 @@ if (isDeep) { // check for circular references and return corresponding clone var initedStack = !stackA; - stackA || (stackA = getArray()); - stackB || (stackB = getArray()); + stackA || (stackA = []); + stackB || (stackB = []); var length = stackA.length; while (length--) { @@ -1173,10 +1116,6 @@ result[key] = baseClone(objValue, isDeep, callback, stackA, stackB); }); - if (initedStack) { - releaseArray(stackA); - releaseArray(stackB); - } return result; } @@ -1598,8 +1537,8 @@ // the algorithm for detecting cyclic structures is adapted from ES 5.1 // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3) var initedStack = !stackA; - stackA || (stackA = getArray()); - stackB || (stackB = getArray()); + stackA || (stackA = []); + stackB || (stackB = []); var length = stackA.length; while (length--) { @@ -1664,10 +1603,6 @@ stackA.pop(); stackB.pop(); - if (initedStack) { - releaseArray(stackA); - releaseArray(stackB); - } return result; } @@ -1770,7 +1705,7 @@ var seen = createCache(); indexOf = cacheIndexOf; } else { - seen = (!isSorted && callback) ? getArray() : result; + seen = (callback && !isSorted) ? [] : result; } while (++index < length) { var value = array[index], @@ -1788,9 +1723,6 @@ result.push(value); } } - if (!isLarge && callback) { - releaseArray(seen); - } return result; } @@ -2595,10 +2527,10 @@ var args = [], argsIndex = -1, argsLength = arguments.length, - caches = getArray(), + caches = [], indexOf = getIndexOf(), largePrereq = createCache && indexOf === baseIndexOf, - seen = getArray(); + seen = []; while (++argsIndex < argsLength) { var value = arguments[argsIndex]; @@ -2630,8 +2562,6 @@ result.push(value); } } - releaseArray(caches); - releaseArray(seen); return result; } @@ -3212,7 +3142,7 @@ * @memberOf _ * @alias unzip * @category Arrays - * @param {...Array} [array] Arrays to process. + * @param {...Array} [array] The arrays to process. * @returns {Array} Returns a new array of grouped elements. * @example * @@ -4581,18 +4511,13 @@ } else { criteria = callback(value, key, collection); } - var object = result[++index] = getObject(); - object.criteria = criteria; - object.index = index; - object.value = value; + result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; }); length = result.length; result.sort(multi ? compareMultipleAscending : compareAscending); while (length--) { - var object = result[length]; - result[length] = object.value; - releaseObject(object); + result[length] = result[length].value; } return result; } @@ -6456,14 +6381,12 @@ } var sources = slice(arguments, 1, length), index = -1, - stackA = getArray(), - stackB = getArray(); + stackA = [], + stackB = []; while (++index < length) { baseMerge(object, sources[index], callback, stackA, stackB); } - releaseArray(stackA); - releaseArray(stackB); return object; } diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index b8378b849..b654fc73b 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,62 +4,62 @@ * Build: `lodash -o ./dist/lodash.compat.js` */ ;(function(){function n(n,t){if(n!==t){if(n>t||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202=S&&(o=r,e=pe(e));++uo(e,l)&&i.push(l)}return i}function ht(n,t){var r=-1,e=n,u=n?n.length:0;if(typeof u=="number")for(ce.unindexedChars&&fr(e)&&(e=e.split(""));++r=S,f=[];if(l)var p=pe(),a=r;else p=!e&&u?c():f;for(;++oa(p,h)&&((u||l)&&p.push(h),f.push(g)) -}return!l&&u&&s(p),f}function kt(n,t,r){for(var e=t.length,u=-1,o=ne(r.length-e,0),a=-1,i=n.length,l=mr(o+i);++ar&&(r=0),c&&(a=[]),p&&(i=[]),s=[n,t,r,e,u,o,a,i],t==j||t==(j|O)?m(s):st(s))}function St(n){n.d=Y;var t=_r,r="return function("+n.a+"){",e="var r="+n.b+";if(!j(p)){return r}";ce.nonEnumArgs&&(e+="var m=p.length;if(m&&i(p)){l=-1;while(++lu;u++)e+="l='"+n.d[u]+"';if((!(k&&n[l])&&g.call(p,l))",n.e||(e+="||(!n[l]&&p[l]!==q[l])"),e+="){"+n.c+"}";e+="}"}return t("e,f,g,i,j,q,o,u,v,w",r+(e+"return r;")+"}")(et,Sr,Dr,Rt,ir,Ar,fe,lt,Ir,Tr) -}function At(){var n=(n=u.indexOf)===Pt?t:n;return n}function It(n){return typeof n=="function"&&Pr.test(Lr.call(n))}function Nt(n){var t,r;return!n||Tr.call(n)!=at||!Dr.call(n,"constructor")&&(t=n.constructor,ar(t)&&!(t instanceof t))||!ce.argsClass&&Rt(n)||!ce.nodeClass&&p(n)?false:ce.ownLast?(ge(n,function(n,t,e){return r=Dr.call(e,t),false}),false!==r):(ge(n,function(n,t){r=t}),typeof r=="undefined"||Dr.call(n,r))}function Rt(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Tr.call(n)==Z||false -}function Tt(n,t,r){var e=0,o=n?n.length:0;if(typeof t!="number"&&null!=t){var a=-1;for(t=u.createCallback(t,r,3);++ae?ne(0,u+e):e||0;else if(e)return e=$t(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function qt(n,t,r){if(typeof t!="number"&&null!=t){var e=0,o=-1,a=n?n.length:0;for(t=u.createCallback(t,r,3);++ot?t=ne(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=ne(u+r,0):r>u&&(r=u),u=r-t||0,r=mr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!_e(n)&&fr(n))return Gr?Gr.call(n,t,r):-1r?ne(0,e+r):r)||0,-1a&&(a=l)}else t=null==t&&fr(n)?e:u.createCallback(t,r,3),ht(n,function(n,r,e){r=t(n,r,e),r>o&&(o=r,a=n)});return a}function Jt(n,t,r,e){var o=3>arguments.length;if(t=u.createCallback(t,e,4),_e(n)){var a=-1,i=n.length;for(o&&i&&(r=n[++a]);++aarguments.length;return t=u.createCallback(t,e,4),vt(n,function(n,e,u){r=o?(o=false,n):t(r,n,e,u)}),r}function Yt(n){var t=-1,r=n?n.length:0,e=mr(typeof r=="number"?r:0);return ht(n,function(n){var r=xt(0,++t);e[t]=e[r],e[r]=n}),e}function Zt(n,t,r){var e;if(t=u.createCallback(t,r,3),_e(n)){r=-1;for(var o=n.length;++rarguments.length)return Et(n,j,null,t); -if(n)var r=n[N]?n[N][2]:n.length,e=Ft(arguments,2),r=r-e.length;return Et(n,j|O,r,t,e)}function tr(n,t,r){var e,u,o,a,i,l,f,c=0,p=false,s=true;if(!ar(n))throw new Or;if(t=ne(0,t)||0,true===r)var g=true,s=false;else ir(r)&&(g=r.leading,p="maxWait"in r&&(ne(t,r.maxWait)||0),s="trailing"in r?r.trailing:s);var h=function(){var r=t-(Oe()-a);0>=r||r>t?(u&&Fr(u),r=f,u=l=f=w,r&&(c=Oe(),o=n.apply(i,e),l||u||(e=i=null))):l=Mr(h,r)},v=function(){l&&Fr(l),u=l=f=w,(s||p!==t)&&(c=Oe(),o=n.apply(i,e),l||u||(e=i=null))};return function(){if(e=arguments,a=Oe(),i=this,f=s&&(l||!g),false===p)var r=g&&!l; -else{u||g||(c=a);var y=p-(a-c),m=0>=y||y>p;m?(u&&(u=Fr(u)),c=a,o=n.apply(i,e)):u||(u=Mr(v,y))}return m&&l?l=Fr(l):l||t===p||(l=Mr(h,t)),r&&(m=true,o=n.apply(i,e)),!m||l||u||(e=i=null),o}}function rr(n,t,r){var e=arguments,u=0,o=e.length,a=typeof r;if("number"!=a&&"string"!=a||!e[3]||e[3][r]!==t||(o=2),3--n?t.apply(this,arguments):void 0}},u.assign=rr,u.at=function(n,t){var r=arguments,e=-1,u=mt(r,true,false,1),o=u.length,a=typeof t;for("number"!=a&&"string"!=a||!r[2]||r[2][t]!==n||(o=1),ce.unindexedChars&&fr(n)&&(n=n.split("")),r=mr(o);++earguments.length?Et(t,j|x,null,n):Et(t,j|x|O,null,n,Ft(arguments,2))},u.chain=function(n){return n=new o(n),n.__chain__=true,n},u.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t=S&&pe(e?n[e]:l)))}var i=n[0],p=-1,g=i?i.length:0,h=[]; -n:for(;++p(v?r(v,f):a(l,f))){for(e=u,(v||l).push(f);--e;)if(v=o[e],0>(v?r(v,f):a(n[e],f)))continue n;h.push(f)}}return s(o),s(l),h},u.invert=function(n,t){for(var r=-1,e=je(n),u=e.length,o={};++rarguments.length&&_e(n))for(;++rr?ne(0,e+r):te(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=hr,u.noConflict=function(){return n._=Rr,this},u.noop=vr,u.now=Oe,u.parseInt=Ee,u.random=function(n,t,r){var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=ue(),te(n+r*(t-n+parseFloat("1e-"+((r+"").length-1))),t)):xt(n,t) -},u.reduce=Jt,u.reduceRight=Qt,u.result=function(n,t,r){var e=null==n?w:n[t];return typeof e=="undefined"?r:ar(e)?n[t]():e},u.runInContext=_,u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:je(n).length},u.some=Zt,u.sortedIndex=$t,u.template=function(n,t,r){var e=u.templateSettings;n=kr(n||""),r=er({},r,e);var o,a,i=er({},r.imports,e.imports),e=je(i),i=cr(i),l=0,c=r.interpolate||U,p="__p+='",c=Cr((r.escape||U).source+"|"+c.source+"|"+(c===D?W:U).source+"|"+(r.evaluate||U).source+"|$","g"); -n.replace(c,function(t,r,e,u,i,c){return e||(e=u),p+=n.slice(l,c).replace(X,f),r&&(o=true,p+="'+__e("+r+")+'"),i&&(a=true,p+="';"+i+";\n__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l=c+t.length,t}),p+="';",(r=r.variable)||(p="with(obj){"+p+"}"),p=(a?p.replace(T,""):p).replace(P,"$1").replace(q,"$1;"),p="function("+(r||"obj")+"){"+(r?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(a?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=_r(e,"return "+p).apply(w,i) -}catch(g){throw g.source=p,g}return t?s(t):(s.source=p,s)},u.trim=xe,u.trimLeft=Ce,u.trimRight=ke,u.unescape=function(n){return null==n?"":(n=kr(n),0>n.indexOf(";")?n:n.replace(F,b))},u.uniqueId=function(n){var t=++R;return kr(null==n?"":n)+t},u.all=Kt,u.any=Zt,u.detect=Ut,u.findWhere=Ut,u.foldl=Jt,u.foldr=Qt,u.include=zt,u.inject=Jt,hr(function(){var n={};return dt(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),false),u.first=Tt,u.last=function(n,t,r){var e=0,o=n?n.length:0;if(typeof t!="number"&&null!=t){var a=o; -for(t=u.createCallback(t,r,3);a--&&t(n[a],a,n);)e++}else if(e=t,null==e||r)return n?n[o-1]:w;return e=o-e,Ft(n,0"']/g,L=/<%-([\s\S]+?)%>/g,B=/<%([\s\S]+?)%>/g,D=/<%=([\s\S]+?)%>/g,W=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,z=/\w*$/,K=/^\s*function[ \n\r\t]+\w/,M=/^0[xX]/,U=/($^)/,V=/\bthis\b/,X=/['\n\r\t\u2028\u2029\\]/g,G=" \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",H=[],J=[],Q="Array Boolean Date Error Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),Y="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),Z="[object Arguments]",nt="[object Array]",tt="[object Boolean]",rt="[object Date]",et="[object Error]",ut="[object Function]",ot="[object Number]",at="[object Object]",it="[object RegExp]",lt="[object String]",ft={}; -ft[ut]=false,ft[Z]=ft[nt]=ft[tt]=ft[rt]=ft[ot]=ft[at]=ft[it]=ft[lt]=true;var ct={leading:false,maxWait:0,trailing:false},pt={configurable:false,enumerable:false,value:null,writable:false},st={"&":"&","<":"<",">":">",'"':""","'":"'"},gt={"&":"&","<":"<",">":">",""":'"',"'":"'"},ht={"function":true,object:true},vt={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},yt=ht[typeof window]&&window||this,mt=ht[typeof exports]&&exports&&!exports.nodeType&&exports,ht=ht[typeof module]&&module&&!module.nodeType&&module,dt=mt&&ht&&typeof global=="object"&&global; -!dt||dt.global!==dt&&dt.window!==dt&&dt.self!==dt||(yt=dt);var dt=ht&&ht.exports===mt&&mt,bt=_();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(yt._=bt, define(function(){return bt})):mt&&ht?dt?(ht.exports=bt)._=bt:mt._=bt:yt._=bt}).call(this); \ No newline at end of file +if(i)return i}return t.g-r.g}function l(n){return at[n]}function f(n){return"\\"+ft[n]}function c(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function p(n,t){return(n=null==n?"":n+"")?null==t?n.slice(h(n),v(n)+1):(t+="",n.slice(u(n,t),o(n,t)+1)):n}function s(n,t){return(n=null==n?"":n+"")?null==t?n.slice(h(n)):(t+="",n.slice(u(n,t))):n}function g(n,t){return(n=null==n?"":n+"")?null==t?n.slice(0,v(n)+1):(t+="",n.slice(0,o(n,t)+1)):n}function h(n){for(var t=-1,r=n.length;++te||13e||8202r||13r||8202=k&&(o=r,e=ie(e));++uo(e,l)&&i.push(l)}return i}function pt(n,t){var r=-1,e=n,u=n?n.length:0; +if(typeof u=="number")for(ae.unindexedChars&&or(e)&&(e=e.split(""));++r=k,f=[];if(l)var c=ie(),a=r;else c=u&&!e?[]:f;for(;++oa(c,s)&&((u||l)&&c.push(s),f.push(p)) +}return f}function wt(n,t,r){for(var e=t.length,u=-1,o=Jr(r.length-e,0),a=-1,i=n.length,l=gr(o+i);++ar&&(r=0),c&&(a=[]),p&&(i=[]),s=[n,t,r,e,u,o,a,i],t==b||t==(b|x)?h(s):lt(s))}function Ct(n){n.d=V;var t=yr,r="return function("+n.a+"){",e="var r="+n.b+";if(!j(p)){return r}";ae.nonEnumArgs&&(e+="var m=p.length;if(m&&i(p)){l=-1;while(++lu;u++)e+="l='"+n.d[u]+"';if((!(k&&n[l])&&g.call(p,l))",n.e||(e+="||(!n[l]&&p[l]!==q[l])"),e+="){"+n.c+"}";e+="}"}return t("e,f,g,i,j,q,o,u,v,w",r+(e+"return r;")+"}")(Q,Cr,Fr,St,er,kr,oe,rt,Or,Ar) +}function kt(){var n=(n=u.indexOf)===It?t:n;return n}function Ot(n){return typeof n=="function"&&Ir.test(Pr.call(n))}function Et(n){var t,r;return!n||Ar.call(n)!=nt||!Fr.call(n,"constructor")&&(t=n.constructor,rr(t)&&!(t instanceof t))||!ae.argsClass&&St(n)||!ae.nodeClass&&c(n)?false:ae.ownLast?(fe(n,function(n,t,e){return r=Fr.call(e,t),false}),false!==r):(fe(n,function(n,t){r=t}),typeof r=="undefined"||Fr.call(n,r))}function St(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ar.call(n)==X||false +}function At(n,t,r){var e=0,o=n?n.length:0;if(typeof t!="number"&&null!=t){var a=-1;for(t=u.createCallback(t,r,3);++ae?Jr(0,u+e):e||0;else if(e)return e=Tt(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function Nt(n,t,r){if(typeof t!="number"&&null!=t){var e=0,o=-1,a=n?n.length:0;for(t=u.createCallback(t,r,3);++ot?t=Jr(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=Jr(u+r,0):r>u&&(r=u),u=r-t||0,r=gr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!ye(n)&&or(n))return Mr?Mr.call(n,t,r):-1r?Jr(0,e+r):r)||0,-1a&&(a=l)}else t=null==t&&or(n)?e:u.createCallback(t,r,3),pt(n,function(n,r,e){r=t(n,r,e),r>o&&(o=r,a=n)});return a}function Vt(n,t,r,e){var o=3>arguments.length;if(t=u.createCallback(t,e,4),ye(n)){var a=-1,i=n.length;for(o&&i&&(r=n[++a]);++aarguments.length;return t=u.createCallback(t,e,4),st(n,function(n,e,u){r=o?(o=false,n):t(r,n,e,u)}),r}function Gt(n){var t=-1,r=n?n.length:0,e=gr(typeof r=="number"?r:0);return pt(n,function(n){var r=bt(0,++t);e[t]=e[r],e[r]=n}),e}function Ht(n,t,r){var e;if(t=u.createCallback(t,r,3),ye(n)){r=-1;for(var o=n.length;++rarguments.length)return xt(n,b,null,t); +if(n)var r=n[E]?n[E][2]:n.length,e=Rt(arguments,2),r=r-e.length;return xt(n,b|x,r,t,e)}function Qt(n,t,r){var e,u,o,a,i,l,f,c=0,p=false,s=true;if(!rr(n))throw new jr;if(t=Jr(0,t)||0,true===r)var g=true,s=false;else er(r)&&(g=r.leading,p="maxWait"in r&&(Jr(t,r.maxWait)||0),s="trailing"in r?r.trailing:s);var h=function(){var r=t-(je()-a);0>=r||r>t?(u&&Rr(u),r=f,u=l=f=d,r&&(c=je(),o=n.apply(i,e),l||u||(e=i=null))):l=Dr(h,r)},v=function(){l&&Rr(l),u=l=f=d,(s||p!==t)&&(c=je(),o=n.apply(i,e),l||u||(e=i=null))};return function(){if(e=arguments,a=je(),i=this,f=s&&(l||!g),false===p)var r=g&&!l; +else{u||g||(c=a);var y=p-(a-c),m=0>=y||y>p;m?(u&&(u=Rr(u)),c=a,o=n.apply(i,e)):u||(u=Dr(v,y))}return m&&l?l=Rr(l):l||t===p||(l=Dr(h,t)),r&&(m=true,o=n.apply(i,e)),!m||l||u||(e=i=null),o}}function Yt(n,t,r){var e=arguments,u=0,o=e.length,a=typeof r;if("number"!=a&&"string"!=a||!e[3]||e[3][r]!==t||(o=2),3--n?t.apply(this,arguments):void 0}},u.assign=Yt,u.at=function(n,t){var r=arguments,e=-1,u=ht(r,true,false,1),o=u.length,a=typeof t;for("number"!=a&&"string"!=a||!r[2]||r[2][t]!==n||(o=1),ae.unindexedChars&&or(n)&&(n=n.split("")),r=gr(o);++earguments.length?xt(t,b|_,null,n):xt(t,b|_|x,null,n,Rt(arguments,2))},u.chain=function(n){return n=new o(n),n.__chain__=true,n},u.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t=k&&ie(e?n[e]:l)))}var i=n[0],c=-1,p=i?i.length:0,s=[]; +n:for(;++c(g?r(g,f):a(l,f))){for(e=u,(g||l).push(f);--e;)if(g=o[e],0>(g?r(g,f):a(n[e],f)))continue n;s.push(f)}}return s},u.invert=function(n,t){for(var r=-1,e=de(n),u=e.length,o={};++rarguments.length&&ye(n))for(;++rr?Jr(0,e+r):Qr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=cr,u.noConflict=function(){return n._=Sr,this},u.noop=pr,u.now=je,u.parseInt=xe,u.random=function(n,t,r){var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=ne(),Qr(n+r*(t-n+parseFloat("1e-"+((r+"").length-1))),t)):bt(n,t) +},u.reduce=Vt,u.reduceRight=Xt,u.result=function(n,t,r){var e=null==n?d:n[t];return typeof e=="undefined"?r:rr(e)?n[t]():e},u.runInContext=m,u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:de(n).length},u.some=Ht,u.sortedIndex=Tt,u.template=function(n,t,r){var e=u.templateSettings;n=wr(n||""),r=Zt({},r,e);var o,a,i=Zt({},r.imports,e.imports),e=de(i),i=ar(i),l=0,c=r.interpolate||W,p="__p+='",c=_r((r.escape||W).source+"|"+c.source+"|"+(c===F?$:W).source+"|"+(r.evaluate||W).source+"|$","g"); +n.replace(c,function(t,r,e,u,i,c){return e||(e=u),p+=n.slice(l,c).replace(K,f),r&&(o=true,p+="'+__e("+r+")+'"),i&&(a=true,p+="';"+i+";\n__p+='"),e&&(p+="'+((__t=("+e+"))==null?'':__t)+'"),l=c+t.length,t}),p+="';",(r=r.variable)||(p="with(obj){"+p+"}"),p=(a?p.replace(A,""):p).replace(I,"$1").replace(N,"$1;"),p="function("+(r||"obj")+"){"+(r?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(a?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+p+"return __p}";try{var s=yr(e,"return "+p).apply(d,i) +}catch(g){throw g.source=p,g}return t?s(t):(s.source=p,s)},u.trim=be,u.trimLeft=_e,u.trimRight=we,u.unescape=function(n){return null==n?"":(n=wr(n),0>n.indexOf(";")?n:n.replace(R,y))},u.uniqueId=function(n){var t=++S;return wr(null==n?"":n)+t},u.all=Bt,u.any=Ht,u.detect=Wt,u.findWhere=Wt,u.foldl=Vt,u.foldr=Xt,u.include=Lt,u.inject=Vt,cr(function(){var n={};return vt(u,function(t,r){u.prototype[r]||(n[r]=t)}),n}(),false),u.first=At,u.last=function(n,t,r){var e=0,o=n?n.length:0;if(typeof t!="number"&&null!=t){var a=o; +for(t=u.createCallback(t,r,3);a--&&t(n[a],a,n);)e++}else if(e=t,null==e||r)return n?n[o-1]:d;return e=o-e,Rt(n,0"']/g,P=/<%-([\s\S]+?)%>/g,q=/<%([\s\S]+?)%>/g,F=/<%=([\s\S]+?)%>/g,$=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,L=/\w*$/,B=/^\s*function[ \n\r\t]+\w/,D=/^0[xX]/,W=/($^)/,z=/\bthis\b/,K=/['\n\r\t\u2028\u2029\\]/g,M=" \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",U="Array Boolean Date Error Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),V="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),X="[object Arguments]",G="[object Array]",H="[object Boolean]",J="[object Date]",Q="[object Error]",Y="[object Function]",Z="[object Number]",nt="[object Object]",tt="[object RegExp]",rt="[object String]",et={}; +et[Y]=false,et[X]=et[G]=et[H]=et[J]=et[Z]=et[nt]=et[tt]=et[rt]=true;var ut={leading:false,maxWait:0,trailing:false},ot={configurable:false,enumerable:false,value:null,writable:false},at={"&":"&","<":"<",">":">",'"':""","'":"'"},it={"&":"&","<":"<",">":">",""":'"',"'":"'"},lt={"function":true,object:true},ft={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},ct=lt[typeof window]&&window||this,pt=lt[typeof exports]&&exports&&!exports.nodeType&&exports,lt=lt[typeof module]&&module&&!module.nodeType&&module,st=pt&<&&typeof global=="object"&&global; +!st||st.global!==st&&st.window!==st&&st.self!==st||(ct=st);var st=lt&<.exports===pt&&pt,gt=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(ct._=gt, define(function(){return gt})):pt&<?st?(lt.exports=gt)._=gt:pt._=gt:ct._=gt}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 445b4e00c..fcbb893f6 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -23,9 +23,6 @@ /** Used as the size when optimizations are enabled for arrays */ var LARGE_ARRAY_SIZE = 40; - /** Used as the max size of the `arrayPool` and `objectPool` */ - var MAX_POOL_SIZE = 40; - /** Used as the semantic version number */ var version = '2.4.1'; @@ -85,10 +82,6 @@ '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' ); - /** Used to pool arrays and objects used internally */ - var arrayPool = [], - objectPool = []; - /** Used to assign default `context` object properties */ var contextProps = [ 'Array', 'Boolean', 'Date', 'Function', 'Math', 'Number', 'Object', @@ -365,56 +358,6 @@ return '\\' + stringEscapes[match]; } - /** - * Gets an array from the array pool or creates a new one if the pool is empty. - * - * @private - * @returns {Array} The array from the pool. - */ - function getArray() { - return arrayPool.pop() || []; - } - - /** - * Gets an object from the object pool or creates a new one if the pool is empty. - * - * @private - * @returns {Object} The object from the pool. - */ - function getObject() { - return objectPool.pop() || { - 'criteria': null, - 'index': 0, - 'value': null - }; - } - - /** - * Releases `array` back to the array pool. - * - * @private - * @param {Array} array The array to release. - */ - function releaseArray(array) { - array.length = 0; - if (arrayPool.length < MAX_POOL_SIZE) { - arrayPool.push(array); - } - } - - /** - * Releases `object` back to the object pool. - * - * @private - * @param {Object} object The object to release. - */ - function releaseObject(object) { - object.criteria = object.value = null; - if (objectPool.length < MAX_POOL_SIZE) { - objectPool.push(object); - } - } - /** * A fallback implementation of `trim` to remove leading and trailing * whitespace or specified characters from `string`. @@ -914,8 +857,8 @@ if (isDeep) { // check for circular references and return corresponding clone var initedStack = !stackA; - stackA || (stackA = getArray()); - stackB || (stackB = getArray()); + stackA || (stackA = []); + stackB || (stackB = []); var length = stackA.length; while (length--) { @@ -951,10 +894,6 @@ result[key] = baseClone(objValue, isDeep, callback, stackA, stackB); }); - if (initedStack) { - releaseArray(stackA); - releaseArray(stackB); - } return result; } @@ -1370,8 +1309,8 @@ // the algorithm for detecting cyclic structures is adapted from ES 5.1 // section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3) var initedStack = !stackA; - stackA || (stackA = getArray()); - stackB || (stackB = getArray()); + stackA || (stackA = []); + stackB || (stackB = []); var length = stackA.length; while (length--) { @@ -1436,10 +1375,6 @@ stackA.pop(); stackB.pop(); - if (initedStack) { - releaseArray(stackA); - releaseArray(stackB); - } return result; } @@ -1542,7 +1477,7 @@ var seen = createCache(); indexOf = cacheIndexOf; } else { - seen = (!isSorted && callback) ? getArray() : result; + seen = (callback && !isSorted) ? [] : result; } while (++index < length) { var value = array[index], @@ -1560,9 +1495,6 @@ result.push(value); } } - if (!isLarge && callback) { - releaseArray(seen); - } return result; } @@ -2332,10 +2264,10 @@ var args = [], argsIndex = -1, argsLength = arguments.length, - caches = getArray(), + caches = [], indexOf = getIndexOf(), largePrereq = createCache && indexOf === baseIndexOf, - seen = getArray(); + seen = []; while (++argsIndex < argsLength) { var value = arguments[argsIndex]; @@ -2367,8 +2299,6 @@ result.push(value); } } - releaseArray(caches); - releaseArray(seen); return result; } @@ -2949,7 +2879,7 @@ * @memberOf _ * @alias unzip * @category Arrays - * @param {...Array} [array] Arrays to process. + * @param {...Array} [array] The arrays to process. * @returns {Array} Returns a new array of grouped elements. * @example * @@ -4317,18 +4247,13 @@ } else { criteria = callback(value, key, collection); } - var object = result[++index] = getObject(); - object.criteria = criteria; - object.index = index; - object.value = value; + result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; }); length = result.length; result.sort(multi ? compareMultipleAscending : compareAscending); while (length--) { - var object = result[length]; - result[length] = object.value; - releaseObject(object); + result[length] = result[length].value; } return result; } @@ -6177,14 +6102,12 @@ } var sources = slice(arguments, 1, length), index = -1, - stackA = getArray(), - stackB = getArray(); + stackA = [], + stackB = []; while (++index < length) { baseMerge(object, sources[index], callback, stackA, stackB); } - releaseArray(stackA); - releaseArray(stackB); return object; } diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 511124cd3..e658f2775 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,58 +4,58 @@ * Build: `lodash modern -o ./dist/lodash.js` */ ;(function(){function n(n,t){if(n!==t){if(n>t||typeof n=="undefined")return 1;if(ne||13e||8202r||13r||8202=A&&(o=r,e=ae(e));++uo(e,f)&&a.push(f)}return a}function ht(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(;++r=A,l=[];if(f)var s=ae(),i=r;else s=!e&&u?c():l;for(;++oi(s,h)&&((u||f)&&s.push(h),l.push(g)) -}return!f&&u&&p(s),l}function xt(n,t,r){for(var e=t.length,u=-1,o=Jr(r.length-e,0),i=-1,a=n.length,f=vr(o+a);++ir&&(r=0),c&&(i=[]),p&&(a=[]),s=[n,t,r,e,u,o,i,a],t==w||t==(w|C)?S(s):pt(s))}function At(){var n=(n=y.indexOf)===It?t:n;return n}function St(n){return typeof n=="function"&&Rr.test($r.call(n))}function Et(n){var t,r;return n&&Nr.call(n)==et&&(Dr.call(n,"constructor")||(t=n.constructor,!ur(t)||t instanceof t))?(o(n,function(n,t){r=t -}),typeof r=="undefined"||Dr.call(n,r)):false}function Nt(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Nr.call(n)==Q||false}function Rt(n,t,r){var e=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=y.createCallback(t,r,3);++oe?Jr(0,u+e):e||0;else if(e)return e=$t(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function Tt(n,t,r){if(typeof t!="number"&&null!=t){var e=0,u=-1,o=n?n.length:0; -for(t=y.createCallback(t,r,3);++ut?t=Jr(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=Jr(u+r,0):r>u&&(r=u),u=r-t||0,r=vr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!he(n)&&ar(n))return Mr?Mr.call(n,t,r):-1r?Jr(0,e+r):r)||0,-1o&&(o=a)}else t=null==t&&ar(n)?e:y.createCallback(t,r,3),ht(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,o=n)});return o}function Gt(n,t,r,e){var u=3>arguments.length; -t=y.createCallback(t,e,4);var o=-1,i=n?n.length:0;if(typeof i=="number")for(u&&i&&(r=n[++o]);++oarguments.length;return t=y.createCallback(t,e,4),vt(n,function(n,e,o){r=u?(u=false,n):t(r,n,e,o)}),r}function Jt(n){var t=-1,r=n?n.length:0,e=vr(typeof r=="number"?r:0);return ht(n,function(n){var r=jt(0,++t);e[t]=e[r],e[r]=n}),e}function Qt(n,t,r){var e;t=y.createCallback(t,r,3),r=-1;var u=n?n.length:0; -if(typeof u=="number"){for(;++rarguments.length)return Ot(n,w,null,t);if(n)var r=n[N]?n[N][2]:n.length,e=Ft(arguments,2),r=r-e.length;return Ot(n,w|C,r,t,e)}function Zt(n,t,r){function e(){c&&Tr(c),i=c=p=_,(h||g!==t)&&(s=_e(),a=n.apply(l,o),c||i||(o=l=null))}function u(){var r=t-(_e()-f);0>=r||r>t?(i&&Tr(i),r=p,i=c=p=_,r&&(s=_e(),a=n.apply(l,o),c||i||(o=l=null))):c=zr(u,r)}var o,i,a,f,l,c,p,s=0,g=false,h=true; -if(!ur(n))throw new xr;if(t=Jr(0,t)||0,true===r)var v=true,h=false;else or(r)&&(v=r.leading,g="maxWait"in r&&(Jr(t,r.maxWait)||0),h="trailing"in r?r.trailing:h);return function(){if(o=arguments,f=_e(),l=this,p=h&&(c||!v),false===g)var r=v&&!c;else{i||v||(s=f);var y=g-(f-s),m=0>=y||y>g;m?(i&&(i=Tr(i)),s=f,a=n.apply(l,o)):i||(i=zr(e,y))}return m&&c?c=Tr(c):c||t===g||(c=zr(u,t)),r&&(m=true,a=n.apply(l,o)),!m||c||i||(o=l=null),a}}function nr(n,t,r){var e=arguments,u=0,o=e.length,i=typeof r;if("number"!=i&&"string"!=i||!e[3]||e[3][r]!==t||(o=2),3--n?t.apply(this,arguments):void 0}},y.assign=nr,y.at=function(n,t){var r=arguments,e=-1,u=mt(r,true,false,1),o=u.length,i=typeof t;for("number"!=i&&"string"!=i||!r[2]||r[2][t]!==n||(o=1),r=vr(o);++earguments.length?Ot(t,w|j,null,n):Ot(t,w|j|C,null,n,Ft(arguments,2))},y.chain=function(n){return n=new m(n),n.__chain__=true,n},y.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t=A&&ae(e?n[e]:f)))}var a=n[0],s=-1,g=a?a.length:0,h=[]; -n:for(;++s(v?r(v,l):i(f,l))){for(e=u,(v||f).push(l);--e;)if(v=o[e],0>(v?r(v,l):i(n[e],l)))continue n;h.push(l)}}return p(o),p(f),h},y.invert=function(n,t){for(var r=-1,e=ye(n),u=e.length,o={};++rarguments.length&&typeof u=="number")for(;++rr?Jr(0,e+r):Qr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},y.mixin=sr,y.noConflict=function(){return n._=Er,this},y.noop=gr,y.now=_e,y.parseInt=we,y.random=function(n,t,r){var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=ne(),Qr(n+r*(t-n+parseFloat("1e-"+((r+"").length-1))),t)):jt(n,t) -},y.reduce=Gt,y.reduceRight=Ht,y.result=function(n,t,r){var e=null==n?_:n[t];return typeof e=="undefined"?r:ur(e)?n[t]():e},y.runInContext=d,y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ye(n).length},y.some=Qt,y.sortedIndex=$t,y.template=function(n,t,r){var e=y.templateSettings;n=kr(n||""),r=tr({},r,e);var u,o,i=tr({},r.imports,e.imports),e=ye(i),i=fr(i),a=0,f=r.interpolate||M,c="__p+='",f=jr((r.escape||M).source+"|"+f.source+"|"+(f===W?z:M).source+"|"+(r.evaluate||M).source+"|$","g"); -n.replace(f,function(t,r,e,i,f,p){return e||(e=i),c+=n.slice(a,p).replace(V,l),r&&(u=true,c+="'+__e("+r+")+'"),f&&(o=true,c+="';"+f+";\n__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),a=p+t.length,t}),c+="';",(r=r.variable)||(c="with(obj){"+c+"}"),c=(o?c.replace(I,""):c).replace(T,"$1").replace(F,"$1;"),c="function("+(r||"obj")+"){"+(r?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var p=br(e,"return "+c).apply(_,i) -}catch(s){throw s.source=c,s}return t?p(t):(p.source=c,p)},y.trim=me,y.trimLeft=be,y.trimRight=de,y.unescape=function(n){return null==n?"":(n=kr(n),0>n.indexOf(";")?n:n.replace($,b))},y.uniqueId=function(n){var t=++R;return kr(null==n?"":n)+t},y.all=Lt,y.any=Qt,y.detect=Kt,y.findWhere=Kt,y.foldl=Gt,y.foldr=Ht,y.include=zt,y.inject=Gt,sr(function(){var n={};return bt(y,function(t,r){y.prototype[r]||(n[r]=t)}),n}(),false),y.first=Rt,y.last=function(n,t,r){var e=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=u; -for(t=y.createCallback(t,r,3);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n?n[u-1]:_;return e=u-e,Ft(n,0"']/g,D=/<%-([\s\S]+?)%>/g,q=/<%([\s\S]+?)%>/g,W=/<%=([\s\S]+?)%>/g,z=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,L=/\w*$/,P=/^\s*function[ \n\r\t]+\w/,K=/^0[xX]/,M=/($^)/,U=/\bthis\b/,V=/['\n\r\t\u2028\u2029\\]/g,X=" \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",G=[],H=[],J="Array Boolean Date Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),Q="[object Arguments]",Y="[object Array]",Z="[object Boolean]",nt="[object Date]",tt="[object Function]",rt="[object Number]",et="[object Object]",ut="[object RegExp]",ot="[object String]",it={}; -it[tt]=false,it[Q]=it[Y]=it[Z]=it[nt]=it[rt]=it[et]=it[ut]=it[ot]=true;var at={leading:false,maxWait:0,trailing:false},ft={configurable:false,enumerable:false,value:null,writable:false},lt={"&":"&","<":"<",">":">",'"':""","'":"'"},ct={"&":"&","<":"<",">":">",""":'"',"'":"'"},pt={"function":true,object:true},st={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},gt=pt[typeof window]&&window||this,ht=pt[typeof exports]&&exports&&!exports.nodeType&&exports,pt=pt[typeof module]&&module&&!module.nodeType&&module,vt=ht&&pt&&typeof global=="object"&&global; -!vt||vt.global!==vt&&vt.window!==vt&&vt.self!==vt||(gt=vt);var vt=pt&&pt.exports===ht&&ht,yt=d();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(gt._=yt, define(function(){return yt})):ht&&pt?vt?(pt.exports=yt)._=yt:ht._=yt:gt._=yt}).call(this); \ No newline at end of file +if(a)return a}return t.g-r.g}function f(n){return et[n]}function l(n){return"\\"+it[n]}function c(n,t){return(n=null==n?"":n+"")?null==t?n.slice(g(n),h(n)+1):(t+="",n.slice(u(n,t),o(n,t)+1)):n}function p(n,t){return(n=null==n?"":n+"")?null==t?n.slice(g(n)):(t+="",n.slice(u(n,t))):n}function s(n,t){return(n=null==n?"":n+"")?null==t?n.slice(0,h(n)+1):(t+="",n.slice(0,o(n,t)+1)):n}function g(n){for(var t=-1,r=n.length;++te||13e||8202r||13r||8202=x&&(o=r,e=ee(e));++uo(e,f)&&a.push(f)}return a}function pt(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(;++r=x,l=[];if(f)var c=ee(),i=r;else c=u&&!e?[]:l;for(;++oi(c,s)&&((u||f)&&c.push(s),l.push(p))}return l}function _t(n,t,r){for(var e=t.length,u=-1,o=Vr(r.length-e,0),i=-1,a=n.length,f=pr(o+a);++ir&&(r=0),c&&(i=[]),p&&(a=[]),s=[n,t,r,e,u,o,i,a],t==b||t==(b|j)?et(s):ft(s)) +}function kt(){var n=(n=g.indexOf)===St?t:n;return n}function xt(n){return typeof n=="function"&&Ar.test(Rr.call(n))}function Ct(n){var t,r;return n&&Or.call(n)==Q&&(Tr.call(n,"constructor")||(t=n.constructor,!nr(t)||t instanceof t))?(o(n,function(n,t){r=t}),typeof r=="undefined"||Tr.call(n,r)):false}function Ot(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Or.call(n)==U||false}function At(n,t,r){var e=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=g.createCallback(t,r,3);++oe?Vr(0,u+e):e||0;else if(e)return e=Rt(n,r),u&&n[e]===r?e:-1;return t(n,r,e)}function Et(n,t,r){if(typeof t!="number"&&null!=t){var e=0,u=-1,o=n?n.length:0;for(t=g.createCallback(t,r,3);++ut?t=Vr(u+t,0):t>u&&(t=u),typeof r=="undefined"?r=u:0>r?r=Vr(u+r,0):r>u&&(r=u),u=r-t||0,r=pr(u);++e>>1,r(n[e])r?0:r);++t=e)return false;if(typeof n=="string"||!ce(n)&&er(n))return zr?zr.call(n,t,r):-1r?Vr(0,e+r):r)||0,-1o&&(o=a)}else t=null==t&&er(n)?e:g.createCallback(t,r,3),pt(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,o=n)});return o}function Mt(n,t,r,e){var u=3>arguments.length;t=g.createCallback(t,e,4);var o=-1,i=n?n.length:0;if(typeof i=="number")for(u&&i&&(r=n[++o]);++oarguments.length;return t=g.createCallback(t,e,4),st(n,function(n,e,o){r=u?(u=false,n):t(r,n,e,o)}),r}function Vt(n){var t=-1,r=n?n.length:0,e=pr(typeof r=="number"?r:0); +return pt(n,function(n){var r=bt(0,++t);e[t]=e[r],e[r]=n}),e}function Xt(n,t,r){var e;t=g.createCallback(t,r,3),r=-1;var u=n?n.length:0;if(typeof u=="number"){for(;++rarguments.length)return jt(n,b,null,t);if(n)var r=n[O]?n[O][2]:n.length,e=Nt(arguments,2),r=r-e.length;return jt(n,b|j,r,t,e)}function Ht(n,t,r){function e(){c&&Er(c),i=c=p=m,(h||g!==t)&&(s=ye(),a=n.apply(l,o),c||i||(o=l=null)) +}function u(){var r=t-(ye()-f);0>=r||r>t?(i&&Er(i),r=p,i=c=p=m,r&&(s=ye(),a=n.apply(l,o),c||i||(o=l=null))):c=Br(u,r)}var o,i,a,f,l,c,p,s=0,g=false,h=true;if(!nr(n))throw new _r;if(t=Vr(0,t)||0,true===r)var v=true,h=false;else tr(r)&&(v=r.leading,g="maxWait"in r&&(Vr(t,r.maxWait)||0),h="trailing"in r?r.trailing:h);return function(){if(o=arguments,f=ye(),l=this,p=h&&(c||!v),false===g)var r=v&&!c;else{i||v||(s=f);var y=g-(f-s),m=0>=y||y>g;m?(i&&(i=Er(i)),s=f,a=n.apply(l,o)):i||(i=Br(e,y))}return m&&c?c=Er(c):c||t===g||(c=Br(u,t)),r&&(m=true,a=n.apply(l,o)),!m||c||i||(o=l=null),a +}}function Jt(n,t,r){var e=arguments,u=0,o=e.length,i=typeof r;if("number"!=i&&"string"!=i||!e[3]||e[3][r]!==t||(o=2),3--n?t.apply(this,arguments):void 0}},g.assign=Jt,g.at=function(n,t){var r=arguments,e=-1,u=gt(r,true,false,1),o=u.length,i=typeof t;for("number"!=i&&"string"!=i||!r[2]||r[2][t]!==n||(o=1),r=pr(o);++earguments.length?jt(t,b|d,null,n):jt(t,b|d|j,null,n,Nt(arguments,2))},g.chain=function(n){return n=new h(n),n.__chain__=true,n},g.compact=function(n){for(var t=-1,r=n?n.length:0,e=0,u=[];++t=x&&ee(e?n[e]:f)))}var a=n[0],c=-1,p=a?a.length:0,s=[]; +n:for(;++c(g?r(g,l):i(f,l))){for(e=u,(g||f).push(l);--e;)if(g=o[e],0>(g?r(g,l):i(n[e],l)))continue n;s.push(l)}}return s},g.invert=function(n,t){for(var r=-1,e=se(n),u=e.length,o={};++rarguments.length&&typeof u=="number")for(;++rr?Vr(0,e+r):Xr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},g.mixin=fr,g.noConflict=function(){return n._=Cr,this},g.noop=lr,g.now=ye,g.parseInt=me,g.random=function(n,t,r){var e=null==n,u=null==t;return null==r&&(u&&typeof n=="boolean"?(r=n,n=1):typeof t=="boolean"&&(r=t,u=true)),e&&u&&(t=1,u=false),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=Jr(),Xr(n+r*(t-n+parseFloat("1e-"+((r+"").length-1))),t)):bt(n,t) +},g.reduce=Mt,g.reduceRight=Ut,g.result=function(n,t,r){var e=null==n?m:n[t];return typeof e=="undefined"?r:nr(e)?n[t]():e},g.runInContext=y,g.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:se(n).length},g.some=Xt,g.sortedIndex=Rt,g.template=function(n,t,r){var e=g.templateSettings;n=dr(n||""),r=Qt({},r,e);var u,o,i=Qt({},r.imports,e.imports),e=se(i),i=ur(i),a=0,f=r.interpolate||z,c="__p+='",f=br((r.escape||z).source+"|"+f.source+"|"+(f===$?B:z).source+"|"+(r.evaluate||z).source+"|$","g"); +n.replace(f,function(t,r,e,i,f,p){return e||(e=i),c+=n.slice(a,p).replace(P,l),r&&(u=true,c+="'+__e("+r+")+'"),f&&(o=true,c+="';"+f+";\n__p+='"),e&&(c+="'+((__t=("+e+"))==null?'':__t)+'"),a=p+t.length,t}),c+="';",(r=r.variable)||(c="with(obj){"+c+"}"),c=(o?c.replace(S,""):c).replace(E,"$1").replace(N,"$1;"),c="function("+(r||"obj")+"){"+(r?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var p=hr(e,"return "+c).apply(m,i) +}catch(s){throw s.source=c,s}return t?p(t):(p.source=c,p)},g.trim=ge,g.trimLeft=he,g.trimRight=ve,g.unescape=function(n){return null==n?"":(n=dr(n),0>n.indexOf(";")?n:n.replace(R,v))},g.uniqueId=function(n){var t=++A;return dr(null==n?"":n)+t},g.all=Dt,g.any=Xt,g.detect=Wt,g.findWhere=Wt,g.foldl=Mt,g.foldr=Ut,g.include=Bt,g.inject=Mt,fr(function(){var n={};return ht(g,function(t,r){g.prototype[r]||(n[r]=t)}),n}(),false),g.first=At,g.last=function(n,t,r){var e=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=u; +for(t=g.createCallback(t,r,3);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n?n[u-1]:m;return e=u-e,Nt(n,0"']/g,T=/<%-([\s\S]+?)%>/g,F=/<%([\s\S]+?)%>/g,$=/<%=([\s\S]+?)%>/g,B=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,D=/\w*$/,q=/^\s*function[ \n\r\t]+\w/,W=/^0[xX]/,z=/($^)/,L=/\bthis\b/,P=/['\n\r\t\u2028\u2029\\]/g,K=" \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",M="Array Boolean Date Function Math Number Object RegExp Set String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),U="[object Arguments]",V="[object Array]",X="[object Boolean]",G="[object Date]",H="[object Function]",J="[object Number]",Q="[object Object]",Y="[object RegExp]",Z="[object String]",nt={}; +nt[H]=false,nt[U]=nt[V]=nt[X]=nt[G]=nt[J]=nt[Q]=nt[Y]=nt[Z]=true;var tt={leading:false,maxWait:0,trailing:false},rt={configurable:false,enumerable:false,value:null,writable:false},et={"&":"&","<":"<",">":">",'"':""","'":"'"},ut={"&":"&","<":"<",">":">",""":'"',"'":"'"},ot={"function":true,object:true},it={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},at=ot[typeof window]&&window||this,ft=ot[typeof exports]&&exports&&!exports.nodeType&&exports,ot=ot[typeof module]&&module&&!module.nodeType&&module,lt=ft&&ot&&typeof global=="object"&&global; +!lt||lt.global!==lt&<.window!==lt&<.self!==lt||(at=lt);var lt=ot&&ot.exports===ft&&ft,ct=y();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(at._=ct, define(function(){return ct})):ft&&ot?lt?(ot.exports=ct)._=ct:ft._=ct:at._=ct}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 1fbd005a3..e5976a287 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -889,7 +889,7 @@ indexOf = getIndexOf(), length = array ? array.length : 0, result = [], - seen = (!isSorted && callback) ? [] : result; + seen = (callback && !isSorted) ? [] : result; while (++index < length) { var value = array[index], @@ -1969,7 +1969,7 @@ * @memberOf _ * @alias unzip * @category Arrays - * @param {...Array} [array] Arrays to process. + * @param {...Array} [array] The arrays to process. * @returns {Array} Returns a new array of grouped elements. * @example * diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 32dc8f05d..40ac22003 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -9,7 +9,7 @@ f=m(u,o,f)}return this instanceof r?(n=a(t.prototype),f=t.apply(n,f||arguments), return r}function p(n,r){for(var t=-1,e=w(),u=n?n.length:0,o=[];++te(r,i)&&o.push(i)}return o}function s(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(;++tu(f,l)&&(t&&f.push(l),i.push(a))}return i}function m(n,r,t){for(var e=r.length,u=-1,o=Qr(t.length-e,0),i=-1,f=n.length,a=Array(o+f);++iu(f,l)&&(t&&f.push(l),i.push(a))}return i}function m(n,r,t){for(var e=r.length,u=-1,o=Qr(t.length-e,0),i=-1,f=n.length,a=Array(o+f);++it&&(t=0),p&&(i=d(u)),s&&(a=d(o)),n=[n,r,t,e,u,o,i,a],r==er||r==(er|fr)?f(n):c(n)}function d(n){for(var r=-1,t=n.length,e=[];++re?Qr(0,u+e):e||0;else if(e)return e=S(r,t),u&&r[e]===t?e:-1;return n(r,t,e)}function E(n,r,t){if(typeof r!="number"&&null!=r){var e=0,u=-1,o=n?n.length:0; for(r=X(r,t,3);++ur?r=Qr(u+r,0):r>u&&(r=u),typeof t=="undefined"?t=u:0>t?t=Qr(u+t,0):t>u&&(t=u),u=t-r||0,t=Array(u);++e>>1,t(n[e])