diff --git a/.gitignore b/.gitignore index 92a16a076..000dbab4b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ *.map modularize node_modules +dist/*.backbone.* +dist/*.legacy.* diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 3d90ee5b0..68407f54e 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -5413,37 +5413,36 @@ */ function debounce(func, wait, options) { var args, + maxTimeoutId, result, stamp, thisArg, - callCount = 0, + timeoutId, + trailingCall, lastCalled = 0, maxWait = false, - maxTimeoutId = null, - timeoutId = null, trailing = true; if (!isFunction(func)) { throw new TypeError; } - wait = nativeMax(0, wait || 0); + wait = nativeMax(0, wait) || 0; if (options === true) { var leading = true; trailing = false; } else if (isObject(options)) { leading = options.leading; - maxWait = 'maxWait' in options && nativeMax(wait, options.maxWait || 0); + maxWait = 'maxWait' in options && (nativeMax(wait, options.maxWait) || 0); trailing = 'trailing' in options ? options.trailing : trailing; } var delayed = function() { var remaining = wait - (new Date - stamp); if (remaining <= 0) { - var isCalled = trailing && (!leading || callCount > 1); if (maxTimeoutId) { clearTimeout(maxTimeoutId); } - callCount = 0; - maxTimeoutId = timeoutId = null; + var isCalled = trailingCall; + maxTimeoutId = timeoutId = trailingCall = undefined; if (isCalled) { lastCalled = +new Date; result = func.apply(thisArg, args); @@ -5457,8 +5456,7 @@ if (timeoutId) { clearTimeout(timeoutId); } - callCount = 0; - maxTimeoutId = timeoutId = null; + maxTimeoutId = timeoutId = trailingCall = undefined; if (trailing || (maxWait !== wait)) { lastCalled = +new Date; result = func.apply(thisArg, args); @@ -5469,12 +5467,10 @@ args = arguments; stamp = +new Date; thisArg = this; - callCount++; + trailingCall = trailing && (timeoutId || !leading); if (maxWait === false) { - if (leading && callCount < 2) { - result = func.apply(thisArg, args); - } + var leadingCall = leading && !timeoutId; } else { if (!maxTimeoutId && !leading) { lastCalled = stamp; @@ -5482,8 +5478,7 @@ var remaining = maxWait - (stamp - lastCalled); if (remaining <= 0) { if (maxTimeoutId) { - clearTimeout(maxTimeoutId); - maxTimeoutId = null; + maxTimeoutId = clearTimeout(maxTimeoutId); } lastCalled = stamp; result = func.apply(thisArg, args); @@ -5495,6 +5490,9 @@ if (!timeoutId && wait !== maxWait) { timeoutId = setTimeout(delayed, wait); } + if (leadingCall) { + result = func.apply(thisArg, args); + } return result; }; } @@ -6026,8 +6024,8 @@ * // => 'hello curly' * * // using the internal `print` function in "evaluate" delimiters - * _.template('<% print("hello " + epithet); %>!', { 'epithet': 'stooge' }); - * // => 'hello stooge!' + * _.template('<% print("hello " + name); %>!', { 'name': 'larry' }); + * // => 'hello larry!' * * // using a custom template delimiters * _.templateSettings = { @@ -6144,9 +6142,7 @@ source + 'return __p\n}'; - // Use a sourceURL for easier debugging and wrap in a multi-line comment to - // avoid issues with Narwhal, IE conditional compilation, and the JS engine - // embedded in Adobe products. + // Use a sourceURL for easier debugging. // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl var sourceURL = '\n/*\n//# sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') + '\n*/'; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 40f3cffeb..4a9cd06e6 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,53 +4,53 @@ * Build: `lodash -o ./dist/lodash.compat.js` */ ;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++er||typeof e=="undefined")return 1;if(ee?0:e);++r=w&&l===n,h=u||g?i():c;if(g){var v=o(h);v?(l=t,h=v):(g=!1,h=u?h:(p(h),c))}for(;++al(h,y))&&((u||g)&&h.push(y),c.push(v))}return g?(p(h.b),s(h)):u&&p(h),c}function ut(n){return function(t,e,r){var u={};if(e=y.createCallback(e,r,3),Ke(t)){r=-1;for(var o=t.length;++rr||typeof e=="undefined")return 1;if(ee?0:e);++r=w&&l===n,v=u||g?i():c;if(g){var h=a(v);h?(l=t,v=h):(g=!1,v=u?v:(p(v),c))}for(;++ol(v,y))&&((u||g)&&v.push(y),c.push(h))}return g?(p(v.b),s(v)):u&&p(v),c}function ut(n){return function(t,e,r){var u={};if(e=y.createCallback(e,r,3),Ke(t)){r=-1;for(var a=t.length;++rk;k++)r+="n='"+n.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",n.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+n.g+"}"; -r+="}"}return(n.b||Te.nonEnumArgs)&&(r+="}"),r+=n.c+";return E",t=t("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",e+r+"}"),s(n),t(Q,K,ae,ye,_,st,Ke,_t,n.f,ie,V,Le,H,le,je)}function it(n){return mt(n)?Ee(n):{}}function lt(n){return Ue[n]}function ft(){var t=(t=y.indexOf)===Ft?n:t;return t}function ct(n){var t,e;return!n||je.call(n)!=J||(t=n.constructor,yt(t)&&!(t instanceof t))||!Te.argsClass&&st(n)||!Te.nodeClass&&f(n)?!1:Te.ownLast?(tr(n,function(n,t,r){return e=ye.call(r,t),!1}),false!==e):(tr(n,function(n,t){e=t -}),e===v||ye.call(n,e))}function pt(n){return Ve[n]}function st(n){return n&&typeof n=="object"?je.call(n)==z:!1}function gt(n,t,e){var r=Ge(n),u=r.length;for(t=Q(t,e,3);u--&&(e=r[u],false!==t(n[e],e,n)););return n}function ht(n){var t=[];return tr(n,function(n,e){yt(n)&&t.push(e)}),t.sort()}function vt(n){for(var t=-1,e=Ge(n),r=e.length,u={};++te?Be(0,o+e):e)||0,Ke(n)?a=-1o&&(o=i)}}else t=!t&&_t(n)?r:y.createCallback(t,e,3),Ye(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function At(n,t,e,r){var u=3>arguments.length;if(t=Q(t,r,4),Ke(n)){var o=-1,a=n.length;for(u&&(e=n[++o]);++oarguments.length;return t=Q(t,r,4),Et(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function Bt(n){var t=-1,e=n?n.length:0,r=Vt(typeof e=="number"?e:0); -return Ct(n,function(n){var e=Ht(++t);r[t]=r[e],r[e]=n}),r}function Nt(n,t,e){var r;if(t=y.createCallback(t,e,3),Ke(n)){e=-1;for(var u=n.length;++e=w&&u===n;if(f){var c=o(i);c?(u=t,i=c):f=!1}for(;++ru(i,c)&&l.push(c);return f&&s(i),l -}function Rt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=-1;for(t=y.createCallback(t,e,3);++or?Be(0,u+r):r||0}else if(r)return r=zt(t,e),t[r]===e?r:-1;return n(t,e,r)}function $t(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=y.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tf&&(a=n.apply(l,o));else{s||v||(c=i);var e=p-(i-c);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:B,variable:"",imports:{_:y}},Ee||(it=function(n){if(mt(n)){c.prototype=n;var t=new c;c.prototype=null}return t||{}});var qe=xe?function(n,t){var e=l();e.value=t,xe(n,"__bindData__",e),s(e)}:c;Te.argsClass||(st=function(n){return n&&typeof n=="object"?ye.call(n,"callee"):!1});var Ke=Oe||function(n){return n&&typeof n=="object"?je.call(n)==L:!1 -},We=at({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),Ge=Ie?function(n){return mt(n)?Te.enumPrototypes&&typeof n=="function"||Te.nonEnumArgs&&n.length&&st(n)?We(n):Ie(n):[]}:We,Je={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:Ge,g:"if(e(t[n],n,g)===false)return E"},Me={a:"z,H,l",i:"var a=arguments,b=0,c=typeof l=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Ve=vt(Ue),Qe=ee("("+Ge(Ve).join("|")+")","g"),Xe=ee("["+Ge(Ue).join("")+"]","g"),Ye=at(Je),Ze=at(Me,{i:Me.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),nr=at(Me),tr=at(Je,He,{j:!1}),er=at(Je,He); -yt(/x/)&&(yt=function(n){return typeof n=="function"&&je.call(n)==W});var rr=ve?function(n){if(!n||je.call(n)!=J||!Te.argsClass&&st(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=ve(t))&&ve(e);return e?n==e||ve(n)==e:ct(n)}:ct,ur=ut(function(n,t,e){ye.call(n,e)?n[e]++:n[e]=1}),or=ut(function(n,t,e){(ye.call(n,e)?n[e]:n[e]=[]).push(t)}),ar=ut(function(n,t,e){n[e]=t}),ir=Ot;$e&&Z&&typeof _e=="function"&&(Gt=function(n){if(!yt(n))throw new ue;return _e.apply(e,arguments)});var lr=8==De(x+"08")?De:function(n,t){return De(_t(n)?n.replace(N,""):n,t||0) -};return y.after=function(n,t){if(!yt(t))throw new ue;return function(){return 1>--n?t.apply(this,arguments):void 0}},y.assign=Ze,y.at=function(n){var t=arguments,e=-1,r=Y(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Vt(t);for(Te.unindexedChars&&_t(n)&&(n=n.split(""));++e=w&&o(a?r[a]:v)}n:for(;++f(m?t(m,y):c(v,y))){for(a=u,(m||v).push(y);--a;)if(m=l[a],0>(m?t(m,y):c(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=l[u])&&s(m);return p(l),p(v),h},y.invert=vt,y.invoke=function(n,t){var e=Re.call(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Vt(typeof o=="number"?o:0);return Ct(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},y.keys=Ge,y.map=Ot,y.max=St,y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):b+arguments[0]; -return ye.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!yt(n))throw new ue;return e.cache={},e},y.merge=function(n){var t=arguments,e=2;if(!mt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(a,e))&&(o[e]=n)}),o},y.once=function(n){var t,e;if(!yt(n))throw new ue;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},y.pairs=function(n){for(var t=-1,e=Ge(n),r=e.length,u=Vt(r);++te?Ne(0,a+e):e)||0,Ke(n)?o=-1a&&(a=i)}}else t=!t&&_t(n)?r:y.createCallback(t,e,3),Ye(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,a=n)});return a}function At(n,t,e,r){var u=3>arguments.length;if(t=Q(t,r,4),Ke(n)){var a=-1,o=n.length;for(u&&(e=n[++a]);++aarguments.length;return t=Q(t,r,4),Et(n,function(n,r,a){e=u?(u=!1,n):t(e,n,r,a)}),e}function Nt(n){var t=-1,e=n?n.length:0,r=Vt(typeof e=="number"?e:0); +return Ct(n,function(n){var e=Ht(++t);r[t]=r[e],r[e]=n}),r}function Bt(n,t,e){var r;if(t=y.createCallback(t,e,3),Ke(n)){e=-1;for(var u=n.length;++e=w&&u===n;if(f){var c=a(i);c?(u=t,i=c):f=!1}for(;++ru(i,c)&&l.push(c);return f&&s(i),l +}function Rt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var a=-1;for(t=y.createCallback(t,e,3);++ar?Ne(0,u+r):r||0}else if(r)return r=zt(t,e),t[r]===e?r:-1;return n(t,e,r)}function $t(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,a=n?n.length:0;for(t=y.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:y}},Ee||(it=function(n){if(mt(n)){c.prototype=n;var t=new c;c.prototype=null}return t||{}});var qe=xe?function(n,t){var e=l();e.value=t,xe(n,"__bindData__",e),s(e)}:c;Te.argsClass||(st=function(n){return n&&typeof n=="object"?ye.call(n,"callee"):!1});var Ke=Oe||function(n){return n&&typeof n=="object"?je.call(n)==L:!1 +},We=ot({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),Ge=Ie?function(n){return mt(n)?Te.enumPrototypes&&typeof n=="function"||Te.nonEnumArgs&&n.length&&st(n)?We(n):Ie(n):[]}:We,Je={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:Ge,g:"if(e(t[n],n,g)===false)return E"},Me={a:"z,H,l",i:"var a=arguments,b=0,c=typeof l=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Ve=ht(Ue),Qe=ee("("+Ge(Ve).join("|")+")","g"),Xe=ee("["+Ge(Ue).join("")+"]","g"),Ye=ot(Je),Ze=ot(Me,{i:Me.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var e=d(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){e=a[--c]}"),g:"E[n]=e?e(E[n],t[n]):t[n]"}),nr=ot(Me),tr=ot(Je,He,{j:!1}),er=ot(Je,He); +yt(/x/)&&(yt=function(n){return typeof n=="function"&&je.call(n)==W});var rr=he?function(n){if(!n||je.call(n)!=J||!Te.argsClass&&st(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=he(t))&&he(e);return e?n==e||he(n)==e:ct(n)}:ct,ur=ut(function(n,t,e){ye.call(n,e)?n[e]++:n[e]=1}),ar=ut(function(n,t,e){(ye.call(n,e)?n[e]:n[e]=[]).push(t)}),or=ut(function(n,t,e){n[e]=t}),ir=Ot;$e&&Z&&typeof _e=="function"&&(Gt=function(n){if(!yt(n))throw new ue;return _e.apply(e,arguments)});var lr=8==De(x+"08")?De:function(n,t){return De(_t(n)?n.replace(B,""):n,t||0) +};return y.after=function(n,t){if(!yt(t))throw new ue;return function(){return 1>--n?t.apply(this,arguments):void 0}},y.assign=Ze,y.at=function(n){var t=arguments,e=-1,r=Y(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Vt(t);for(Te.unindexedChars&&_t(n)&&(n=n.split(""));++e=w&&a(o?r[o]:h)}n:for(;++f(m?t(m,y):c(h,y))){for(o=u,(m||h).push(y);--o;)if(m=l[o],0>(m?t(m,y):c(r[o],y)))continue n;v.push(y)}}for(;u--;)(m=l[u])&&s(m);return p(l),p(h),v},y.invert=ht,y.invoke=function(n,t){var e=Re.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Vt(typeof a=="number"?a:0);return Ct(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},y.keys=Ge,y.map=Ot,y.max=St,y.memoize=function(n,t){if(!yt(n))throw new ue;var e=function(){var r=e.cache,u=t?t.apply(this,arguments):b+arguments[0]; +return ye.call(r,u)?r[u]:r[u]=n.apply(this,arguments)};return e.cache={},e},y.merge=function(n){var t=arguments,e=2;if(!mt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(o,e))&&(a[e]=n)}),a},y.once=function(n){var t,e;if(!yt(n))throw new ue;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},y.pairs=function(n){for(var t=-1,e=Ge(n),r=e.length,u=Vt(r);++te?Be(0,r+e):Ne(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},y.mixin=Mt,y.noConflict=function(){return e._=fe,this},y.parseInt=lr,y.random=Ht,y.reduce=At,y.reduceRight=It,y.result=function(n,t){var e=n?n[t]:v;return yt(e)?n[t]():e},y.runInContext=h,y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Ge(n).length},y.some=Nt,y.sortedIndex=zt,y.template=function(n,t,e){var r=y.templateSettings; -n||(n=""),e=nr({},e,r);var u,o=nr({},e.imports,r.imports),r=Ge(o),o=bt(o),i=0,l=e.interpolate||D,f="__p+='",l=ee((e.escape||D).source+"|"+l.source+"|"+(l===B?S:D).source+"|"+(e.evaluate||D).source+"|$","g");n.replace(l,function(t,e,r,o,l,c){return r||(r=o),f+=n.slice(i,c).replace(R,a),e&&(f+="'+__e("+e+")+'"),l&&(u=!0,f+="';"+l+";__p+='"),r&&(f+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),f+="';\n",l=e=e.variable,l||(e="obj",f="with("+e+"){"+f+"}"),f=(u?f.replace(C,""):f).replace(E,"$1").replace(O,"$1;"),f="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}"; -try{var c=Yt(r,"return "+f).apply(v,o)}catch(p){throw p.source=f,p}return t?c(t):(c.source=f,c)},y.unescape=function(n){return null==n?"":re(n).replace(Qe,pt)},y.uniqueId=function(n){var t=++d;return re(null==n?"":n)+t},y.all=jt,y.any=Nt,y.detect=xt,y.findWhere=xt,y.foldl=At,y.foldr=It,y.include=wt,y.inject=At,er(y,function(n,t){y.prototype[t]||(y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return me.apply(t,arguments),t=n.apply(y,t),e?new m(t,e):t})}),y.first=Rt,y.last=function(n,t,e){if(n){var r=0,u=n.length; -if(typeof t!="number"&&null!=t){var o=u;for(t=y.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[u-1];return g(n,Be(0,u-r))}},y.sample=function(n,t,e){return Ke(n)||(n=Dt(n)),null==t||e?n[Ht(n.length-1)]:(n=Bt(n),n.length=Ne(Be(0,t),n.length),n)},y.take=Rt,y.head=Rt,er(y,function(n,t){var e="sample"!==t;y.prototype[t]||(y.prototype[t]=function(t,r){var u=this.__chain__,o=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new m(o,u):o})}),y.VERSION="1.3.1",y.prototype.chain=function(){return this.__chain__=!0,this -},y.prototype.toString=function(){return re(this.__wrapped__)},y.prototype.value=Ut,y.prototype.valueOf=Ut,Ye(["join","pop","shift"],function(n){var t=oe[n];y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new m(e,n):e}}),Ye(["push","reverse","sort","unshift"],function(n){var t=oe[n];y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ye(["concat","slice","splice"],function(n){var t=oe[n];y.prototype[n]=function(){return new m(t.apply(this.__wrapped__,arguments),this.__chain__) -}}),Te.spliceObjects||Ye(["pop","shift","splice"],function(n){var t=oe[n],e="splice"==n;y.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments);return 0===r.length&&delete r[0],n||e?new m(u,n):u}}),y}var v,y=[],m=[],d=0,_={},b=+new Date+"",w=75,j=40,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",C=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,O=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,I=/^function[ \n\r\t]+\w/,B=/<%=([\s\S]+?)%>/g,N=RegExp("^["+x+"]*0+(?=.$)"),D=/($^)/,P=(P=/\bthis\b/)&&P.test(h)&&P,R=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),$="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),z="[object Arguments]",L="[object Array]",T="[object Boolean]",q="[object Date]",K="[object Error]",W="[object Function]",G="[object Number]",J="[object Object]",M="[object RegExp]",H="[object String]",U={}; -U[W]=!1,U[z]=U[L]=U[T]=U[q]=U[G]=U[J]=U[M]=U[H]=!0;var V={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Q={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},X=V[typeof window]&&window||this,Y=V[typeof exports]&&exports,Z=V[typeof module]&&module&&module.exports==Y&&module,nt=V[typeof global]&&global;!nt||nt.global!==nt&&nt.window!==nt||(X=nt);var tt=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(X._=tt, define(function(){return tt +},y.isString=_t,y.isUndefined=function(n){return typeof n=="undefined"},y.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?Ne(0,r+e):Be(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},y.mixin=Mt,y.noConflict=function(){return e._=fe,this},y.parseInt=lr,y.random=Ht,y.reduce=At,y.reduceRight=It,y.result=function(n,t){var e=n?n[t]:h;return yt(e)?n[t]():e},y.runInContext=v,y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Ge(n).length},y.some=Bt,y.sortedIndex=zt,y.template=function(n,t,e){var r=y.templateSettings; +n||(n=""),e=nr({},e,r);var u,a=nr({},e.imports,r.imports),r=Ge(a),a=bt(a),i=0,l=e.interpolate||D,f="__p+='",l=ee((e.escape||D).source+"|"+l.source+"|"+(l===N?S:D).source+"|"+(e.evaluate||D).source+"|$","g");n.replace(l,function(t,e,r,a,l,c){return r||(r=a),f+=n.slice(i,c).replace(R,o),e&&(f+="'+__e("+e+")+'"),l&&(u=!0,f+="';"+l+";__p+='"),r&&(f+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t}),f+="';\n",l=e=e.variable,l||(e="obj",f="with("+e+"){"+f+"}"),f=(u?f.replace(C,""):f).replace(E,"$1").replace(O,"$1;"),f="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}"; +try{var c=Yt(r,"return "+f).apply(h,a)}catch(p){throw p.source=f,p}return t?c(t):(c.source=f,c)},y.unescape=function(n){return null==n?"":re(n).replace(Qe,pt)},y.uniqueId=function(n){var t=++d;return re(null==n?"":n)+t},y.all=jt,y.any=Bt,y.detect=xt,y.findWhere=xt,y.foldl=At,y.foldr=It,y.include=wt,y.inject=At,er(y,function(n,t){y.prototype[t]||(y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return me.apply(t,arguments),t=n.apply(y,t),e?new m(t,e):t})}),y.first=Rt,y.last=function(n,t,e){if(n){var r=0,u=n.length; +if(typeof t!="number"&&null!=t){var a=u;for(t=y.createCallback(t,e,3);a--&&t(n[a],a,n);)r++}else if(r=t,null==r||e)return n[u-1];return g(n,Ne(0,u-r))}},y.sample=function(n,t,e){return Ke(n)||(n=Dt(n)),null==t||e?n[Ht(n.length-1)]:(n=Nt(n),n.length=Be(Ne(0,t),n.length),n)},y.take=Rt,y.head=Rt,er(y,function(n,t){var e="sample"!==t;y.prototype[t]||(y.prototype[t]=function(t,r){var u=this.__chain__,a=n(this.__wrapped__,t,r);return u||null!=t&&(!r||e&&typeof t=="function")?new m(a,u):a})}),y.VERSION="1.3.1",y.prototype.chain=function(){return this.__chain__=!0,this +},y.prototype.toString=function(){return re(this.__wrapped__)},y.prototype.value=Ut,y.prototype.valueOf=Ut,Ye(["join","pop","shift"],function(n){var t=ae[n];y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new m(e,n):e}}),Ye(["push","reverse","sort","unshift"],function(n){var t=ae[n];y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ye(["concat","slice","splice"],function(n){var t=ae[n];y.prototype[n]=function(){return new m(t.apply(this.__wrapped__,arguments),this.__chain__) +}}),Te.spliceObjects||Ye(["pop","shift","splice"],function(n){var t=ae[n],e="splice"==n;y.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments);return 0===r.length&&delete r[0],n||e?new m(u,n):u}}),y}var h,y=[],m=[],d=0,_={},b=+new Date+"",w=75,j=40,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",C=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,O=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,I=/^function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,B=RegExp("^["+x+"]*0+(?=.$)"),D=/($^)/,P=(P=/\bthis\b/)&&P.test(v)&&P,R=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),$="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),z="[object Arguments]",L="[object Array]",T="[object Boolean]",q="[object Date]",K="[object Error]",W="[object Function]",G="[object Number]",J="[object Object]",M="[object RegExp]",H="[object String]",U={}; +U[W]=!1,U[z]=U[L]=U[T]=U[q]=U[G]=U[J]=U[M]=U[H]=!0;var V={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Q={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},X=V[typeof window]&&window||this,Y=V[typeof exports]&&exports,Z=V[typeof module]&&module&&module.exports==Y&&module,nt=V[typeof global]&&global;!nt||nt.global!==nt&&nt.window!==nt||(X=nt);var tt=v();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(X._=tt, define(function(){return tt })):Y&&!Y.nodeType?Z?(Z.exports=tt)._=tt:Y._=tt:X._=tt}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index cf44b9b2f..10a757c26 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -5069,37 +5069,36 @@ */ function debounce(func, wait, options) { var args, + maxTimeoutId, result, stamp, thisArg, - callCount = 0, + timeoutId, + trailingCall, lastCalled = 0, maxWait = false, - maxTimeoutId = null, - timeoutId = null, trailing = true; if (!isFunction(func)) { throw new TypeError; } - wait = nativeMax(0, wait || 0); + wait = nativeMax(0, wait) || 0; if (options === true) { var leading = true; trailing = false; } else if (isObject(options)) { leading = options.leading; - maxWait = 'maxWait' in options && nativeMax(wait, options.maxWait || 0); + maxWait = 'maxWait' in options && (nativeMax(wait, options.maxWait) || 0); trailing = 'trailing' in options ? options.trailing : trailing; } var delayed = function() { var remaining = wait - (now() - stamp); if (remaining <= 0) { - var isCalled = trailing && (!leading || callCount > 1); if (maxTimeoutId) { clearTimeout(maxTimeoutId); } - callCount = 0; - maxTimeoutId = timeoutId = null; + var isCalled = trailingCall; + maxTimeoutId = timeoutId = trailingCall = undefined; if (isCalled) { lastCalled = now(); result = func.apply(thisArg, args); @@ -5113,8 +5112,7 @@ if (timeoutId) { clearTimeout(timeoutId); } - callCount = 0; - maxTimeoutId = timeoutId = null; + maxTimeoutId = timeoutId = trailingCall = undefined; if (trailing || (maxWait !== wait)) { lastCalled = now(); result = func.apply(thisArg, args); @@ -5125,12 +5123,10 @@ args = arguments; stamp = now(); thisArg = this; - callCount++; + trailingCall = trailing && (timeoutId || !leading); if (maxWait === false) { - if (leading && callCount < 2) { - result = func.apply(thisArg, args); - } + var leadingCall = leading && !timeoutId; } else { if (!maxTimeoutId && !leading) { lastCalled = stamp; @@ -5138,8 +5134,7 @@ var remaining = maxWait - (stamp - lastCalled); if (remaining <= 0) { if (maxTimeoutId) { - clearTimeout(maxTimeoutId); - maxTimeoutId = null; + maxTimeoutId = clearTimeout(maxTimeoutId); } lastCalled = stamp; result = func.apply(thisArg, args); @@ -5151,6 +5146,9 @@ if (!timeoutId && wait !== maxWait) { timeoutId = setTimeout(delayed, wait); } + if (leadingCall) { + result = func.apply(thisArg, args); + } return result; }; } @@ -5682,8 +5680,8 @@ * // => 'hello curly' * * // using the internal `print` function in "evaluate" delimiters - * _.template('<% print("hello " + epithet); %>!', { 'epithet': 'stooge' }); - * // => 'hello stooge!' + * _.template('<% print("hello " + name); %>!', { 'name': 'larry' }); + * // => 'hello larry!' * * // using a custom template delimiters * _.templateSettings = { @@ -5800,9 +5798,7 @@ source + 'return __p\n}'; - // Use a sourceURL for easier debugging and wrap in a multi-line comment to - // avoid issues with Narwhal, IE conditional compilation, and the JS engine - // embedded in Adobe products. + // Use a sourceURL for easier debugging. // http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl var sourceURL = '\n/*\n//# sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') + '\n*/'; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 7f2800257..2bf1ae440 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -23,9 +23,9 @@ else o=[],g(n,function(n,e,u){o[++r]=t(n,e,u)});return o}function Nt(n,t,e){var else g(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)});return e}function St(n,t,e,r){var u=3>arguments.length;return t=nt(t,r,4),Ct(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function At(n){var t=-1,e=n?n.length:0,r=Jt(typeof e=="number"?e:0);return xt(n,function(n){var e=Gt(++t);r[t]=r[e],r[e]=n}),r}function Rt(n,t,e){var r;t=X.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e=_&&u===n;if(l){var p=o(i);p?(u=t,i=p):l=!1}for(;++ru(i,p)&&f.push(p);return l&&c(i),f}function Dt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=-1;for(t=X.createCallback(t,e,3);++or?Ie(0,u+r):r||0}else if(r)return r=zt(t,e),t[r]===e?r:-1; return n(t,e,r)}function Tt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=X.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tl&&(a=n.apply(f,o));else{s||g||(c=i);var e=p-(i-c);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:X}};var ze=Ce||function(n){return n&&typeof n=="object"?de.call(n)==$:!1},qe=Ee?function(n){return yt(n)?Ee(n):[]}:H,We={"&":"&","<":"<",">":">",'"':""","'":"'"},Pe=ht(We),Ke=ee("("+qe(Pe).join("|")+")","g"),Le=ee("["+qe(We).join("")+"]","g"),Me=ot(function(n,t,e){he.call(n,e)?n[e]++:n[e]=1}),Ue=ot(function(n,t,e){(he.call(n,e)?n[e]:n[e]=[]).push(t) }),Ve=ot(function(n,t,e){n[e]=t});De&&G&&typeof me=="function"&&(Mt=function(n){if(!gt(n))throw new ue;return me.apply(e,arguments)});var Ge=8==Ae(d+"08")?Ae:function(n,t){return Ae(_t(n)?n.replace(E,""):n,t||0)};return X.after=function(n,t){if(!gt(t))throw new ue;return function(){return 1>--n?t.apply(this,arguments):void 0}},X.assign=V,X.at=function(n){for(var t=arguments,e=-1,r=tt(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Jt(t);++e': '>', '"': '"', - "'": ''', - '/': '/' + "'": ''' }; /** Used to convert HTML entities to characters */ @@ -2017,6 +2016,49 @@ (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); }); + /** + * Creates an object composed of keys generated from the results of running + * each element of the collection through the given callback. The corresponding + * value of each key is the last element responsible for generating the key. + * The callback is bound to `thisArg` and invoked with three arguments; + * (value, index|key, collection). + * + * If a property name is provided for `callback` the created "_.pluck" style + * callback will return the property value of the given element. + * + * If an object is provided for `callback` the created "_.where" style callback + * will return `true` for elements that have the properties of the given object, + * else `false`. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [callback=identity] The function called + * per iteration. If a property name or object is provided it will be used + * to create a "_.pluck" or "_.where" style callback, respectively. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns the composed aggregate object. + * @example + * + * var keys = [ + * { 'dir': 'left', 'code': 97 }, + * { 'dir': 'right', 'code': 100 } + * ]; + * + * _.indexBy(keys, 'dir'); + * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } + * + * _.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + * + * _.indexBy(stooges, function(key) { this.fromCharCode(key.code); }, String); + * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + */ + var indexBy = createAggregator(function(result, value, key) { + result[key] = value; + }); + /** * Invokes the method named by `methodName` on each element in the `collection` * returning an array of the results of each invoked method. Additional arguments @@ -2407,6 +2449,37 @@ }); } + /** + * Retrieves a random element or `n` random elements from a collection. + * + * @static + * @memberOf _ + * @category Collections + * @param {Array|Object|string} collection The collection to sample. + * @param {number} [n] The number of elements to sample. + * @param- {Object} [guard] Allows working with functions, like `_.map`, + * without using their `key` and `object` arguments as sources. + * @returns {Array} Returns the random sample(s) of `collection`. + * @example + * + * _.sample([1, 2, 3, 4]); + * // => 2 + * + * _.sample([1, 2, 3, 4], 2); + * // => [3, 1] + */ + function sample(collection, n, guard) { + if (!isArray(collection)) { + collection = toArray(collection); + } + if (n == null || guard) { + return collection[random(collection.length - 1)]; + } + var result = shuffle(collection); + result.length = nativeMin(nativeMax(0, n), result.length); + return result; + } + /** * Creates an array of shuffled values, using a version of the Fisher-Yates * shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -3666,37 +3739,36 @@ */ function debounce(func, wait, options) { var args, + maxTimeoutId, result, stamp, thisArg, - callCount = 0, + timeoutId, + trailingCall, lastCalled = 0, maxWait = false, - maxTimeoutId = null, - timeoutId = null, trailing = true; if (!isFunction(func)) { throw new TypeError; } - wait = nativeMax(0, wait || 0); + wait = nativeMax(0, wait) || 0; if (options === true) { var leading = true; trailing = false; } else if (isObject(options)) { leading = options.leading; - maxWait = 'maxWait' in options && nativeMax(wait, options.maxWait || 0); + maxWait = 'maxWait' in options && (nativeMax(wait, options.maxWait) || 0); trailing = 'trailing' in options ? options.trailing : trailing; } var delayed = function() { var remaining = wait - (new Date - stamp); if (remaining <= 0) { - var isCalled = trailing && (!leading || callCount > 1); if (maxTimeoutId) { clearTimeout(maxTimeoutId); } - callCount = 0; - maxTimeoutId = timeoutId = null; + var isCalled = trailingCall; + maxTimeoutId = timeoutId = trailingCall = undefined; if (isCalled) { lastCalled = +new Date; result = func.apply(thisArg, args); @@ -3710,8 +3782,7 @@ if (timeoutId) { clearTimeout(timeoutId); } - callCount = 0; - maxTimeoutId = timeoutId = null; + maxTimeoutId = timeoutId = trailingCall = undefined; if (trailing || (maxWait !== wait)) { lastCalled = +new Date; result = func.apply(thisArg, args); @@ -3722,12 +3793,10 @@ args = arguments; stamp = +new Date; thisArg = this; - callCount++; + trailingCall = trailing && (timeoutId || !leading); if (maxWait === false) { - if (leading && callCount < 2) { - result = func.apply(thisArg, args); - } + var leadingCall = leading && !timeoutId; } else { if (!maxTimeoutId && !leading) { lastCalled = stamp; @@ -3735,8 +3804,7 @@ var remaining = maxWait - (stamp - lastCalled); if (remaining <= 0) { if (maxTimeoutId) { - clearTimeout(maxTimeoutId); - maxTimeoutId = null; + maxTimeoutId = clearTimeout(maxTimeoutId); } lastCalled = stamp; result = func.apply(thisArg, args); @@ -3748,6 +3816,9 @@ if (!timeoutId && wait !== maxWait) { timeoutId = setTimeout(delayed, wait); } + if (leadingCall) { + result = func.apply(thisArg, args); + } return result; }; } @@ -3837,7 +3908,7 @@ function memoize(func, resolver) { var cache = {}; return function() { - var key = keyPrefix + (resolver ? resolver.apply(this, arguments) : arguments[0]); + var key = resolver ? resolver.apply(this, arguments) : keyPrefix + arguments[0]; return hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = func.apply(this, arguments)); @@ -3938,6 +4009,9 @@ var leading = true, trailing = true; + if (!isFunction(func)) { + throw new TypeError; + } if (options === false) { leading = false; } else if (isObject(options)) { @@ -4196,8 +4270,8 @@ * // => 'hello curly' * * // using the internal `print` function in "evaluate" delimiters - * _.template('<% print("hello " + epithet); %>!', { 'epithet': 'stooge' }); - * // => 'hello stooge!' + * _.template('<% print("hello " + name); %>!', { 'name': 'larry' }); + * // => 'hello larry!' * * // using a custom template delimiters * _.templateSettings = { @@ -4479,6 +4553,7 @@ lodash.forEach = forEach; lodash.functions = functions; lodash.groupBy = groupBy; + lodash.indexBy = indexBy; lodash.initial = initial; lodash.intersection = intersection; lodash.invert = invert; @@ -4578,6 +4653,7 @@ // add functions capable of returning wrapped and unwrapped values when chaining lodash.first = first; lodash.last = last; + lodash.sample = sample; // add aliases lodash.take = first; diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 4a5988f02..aaa266873 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -3,36 +3,35 @@ * Lo-Dash 1.3.1 (Custom Build) lodash.com/license | Underscore.js 1.5.1 underscorejs.org/LICENSE * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` */ -;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined")return 1;if(tu(f,l))&&(t&&f.push(l),o.push(a))}return o}function c(n){return function(r,t,e){var u={};t=J(t,e,3),e=-1;var i=r?r.length:0;if(typeof i=="number")for(;++ee&&(e=t,u=n)});else for(;++iu&&(u=t);return u}function q(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++targuments.length;r=o(r,e,4); -var i=-1,f=n.length;if(typeof f=="number")for(u&&(t=n[++i]);++iarguments.length;return r=o(r,e,4),B(n,function(n,e,i){t=u?(u=!1,n):r(t,n,e,i)}),t}function I(n,r,t){var e;r=J(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++tt(u,o)&&i.push(o)}return i}function C(n,r,t){if(n){var e=0,u=n.length;if(typeof r!="number"&&null!=r){var i=-1;for(r=J(r,t,3);++ie?kr(0,u+e):e||0}else if(e)return e=V(r,t),r[e]===t?e:-1;return n(r,t,e)}function U(n,r,t){if(typeof r!="number"&&null!=r){var e=0,u=-1,i=n?n.length:0;for(r=J(r,t,3);++u>>1,t(n[e])f&&(u=n.apply(o,e)); -else{c||v||(a=i);var t=l-(i-a);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Fr||(s=function(n){if(x(n)){e.prototype=n;var r=new e;e.prototype=null}return r||{}}),y(arguments)||(y=function(n){return n&&typeof n=="object"?Er.call(n,"callee"):!1});var Cr=Nr||function(n){return n&&typeof n=="object"?Tr.call(n)==ir:!1},Pr=function(n){var r,t=[]; -if(!n||!sr[typeof n])return t;for(r in n)Er.call(n,r)&&t.push(r);return t},Ur=Dr?function(n){return x(n)?Dr(n):[]}:Pr,Vr={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Gr=b(Vr),Hr=RegExp("("+Ur(Gr).join("|")+")","g"),Jr=RegExp("["+Ur(Vr).join("")+"]","g"),Kr=function(n,r){var t;if(!n||!sr[typeof n])return n;for(t in n)if(r(n[t],t,n)===nr)break;return n},Lr=function(n,r){var t;if(!n||!sr[typeof n])return n;for(t in n)if(Er.call(n,t)&&r(n[t],t,n)===nr)break;return n};j(/x/)&&(j=function(n){return typeof n=="function"&&"[object Function]"==Tr.call(n) -});var Qr=c(function(n,r,t){Er.call(n,t)?n[t]++:n[t]=1}),Xr=c(function(n,r,t){(Er.call(n,t)?n[t]:n[t]=[]).push(r)});u.after=function(n,r){if(!j(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=H,u.bindAll=function(n){for(var r=1u(o,f)){for(var a=t;--a;)if(0>u(r[a],f))continue n;o.push(f)}}return o},u.invert=b,u.invoke=function(n,r){var t=$r.call(arguments,2),e=-1,u=typeof r=="function",i=n?n.length:0,o=Array(typeof i=="number"?i:0); -return R(n,function(n){o[++e]=(u?r:n[r]).apply(n,t)}),o},u.keys=Ur,u.map=D,u.max=k,u.memoize=function(n,r){var t={};return function(){var e=rr+(r?r.apply(this,arguments):arguments[0]);return Er.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var e=1/0,u=e,i=-1,o=n?n.length:0;if(r||typeof o!="number")r=J(r,t,3),R(n,function(n,t,i){t=r(n,t,i),tr(t,u)&&(e[u]=n) -}),e},u.once=function(n){var r,t;if(!j(n))throw new TypeError;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},u.pairs=function(n){for(var r=-1,t=Ur(n),e=t.length,u=Array(e);++rr?0:r);++nt?kr(0,e+t):qr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=Q,u.noConflict=function(){return hr._=br,this},u.random=X,u.reduce=M,u.reduceRight=$,u.result=function(n,r){var t=n?n[r]:Y;return j(t)?n[r]():t},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Ur(n).length -},u.some=I,u.sortedIndex=V,u.template=function(n,r,e){var i=u,o=i.templateSettings;n||(n=""),e=_({},e,o);var f=0,a="__p+='",o=e.variable;n.replace(RegExp((e.escape||tr).source+"|"+(e.interpolate||tr).source+"|"+(e.evaluate||tr).source+"|$","g"),function(r,e,u,i,o){return a+=n.slice(f,o).replace(er,t),e&&(a+="'+_.escape("+e+")+'"),i&&(a+="';"+i+";__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=o+r.length,r}),a+="';\n",o||(o="obj",a="with("+o+"||{}){"+a+"}"),a="function("+o+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}"; -try{var l=Function("_","return "+a)(i)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Hr,g)},u.uniqueId=function(n){var r=++Z+"";return n?n+r:r},u.all=S,u.any=I,u.detect=N,u.findWhere=function(n,r){return W(n,r,!0)},u.foldl=M,u.foldr=$,u.include=O,u.inject=M,u.first=C,u.last=function(n,r,t){if(n){var e=0,u=n.length;if(typeof r!="number"&&null!=r){var i=u;for(r=J(r,t,3);i--&&r(n[i],i,n);)e++}else if(e=r,null==e||t)return n[u-1];return $r.call(n,kr(0,u-e)) -}},u.take=C,u.head=C,Q(u),u.VERSION="1.3.1",u.prototype.chain=function(){return this.__chain__=!0,this},u.prototype.value=function(){return this.__wrapped__},R("pop push reverse shift sort splice unshift".split(" "),function(n){var r=_r[n];u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),zr.spliceObjects||0!==n.length||delete n[0],this}}),R(["concat","join","slice"],function(n){var r=_r[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new i(n),n.__chain__=!0),n -}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(hr._=u, define(function(){return u})):gr&&!gr.nodeType?yr?(yr.exports=u)._=u:gr._=u:hr._=u}).call(this); \ No newline at end of file +;(function(){function n(n,r,t){t=(t||0)-1;for(var e=n?n.length:0;++te||typeof t=="undefined")return 1;if(tu(f,l))&&(t&&f.push(l),o.push(a))}return o}function c(n){return function(r,t,e){var u={};t=L(t,e,3),e=-1;var i=r?r.length:0;if(typeof i=="number")for(;++ee&&(e=t,u=n)});else for(;++iu&&(u=t);return u}function q(n,r){var t=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++targuments.length;r=o(r,e,4); +var i=-1,f=n.length;if(typeof f=="number")for(u&&(t=n[++i]);++iarguments.length;return r=o(r,e,4),D(n,function(n,e,i){t=u?(u=!1,n):r(t,n,e,i)}),t}function I(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return R(n,function(n){var t=Z(++r);e[r]=e[t],e[t]=n}),e}function W(n,r,t){var e;r=L(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++tt(u,o)&&i.push(o)}return i}function U(n,r,t){if(n){var e=0,u=n.length;if(typeof r!="number"&&null!=r){var i=-1;for(r=L(r,t,3);++ie?Mr(0,u+e):e||0}else if(e)return e=H(r,t),r[e]===t?e:-1;return n(r,t,e)}function G(n,r,t){if(typeof r!="number"&&null!=r){var e=0,u=-1,i=n?n.length:0;for(r=L(r,t,3);++u>>1,t(n[e])/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Rr||(s=function(n){if(x(n)){e.prototype=n;var r=new e;e.prototype=null}return r||{}}),y(arguments)||(y=function(n){return n&&typeof n=="object"?Tr.call(n,"callee"):!1});var Ur=Dr||function(n){return n&&typeof n=="object"?Sr.call(n)==fr:!1},Vr=function(n){var r,t=[]; +if(!n||!hr[typeof n])return t;for(r in n)Tr.call(n,r)&&t.push(r);return t},Gr=qr?function(n){return x(n)?qr(n):[]}:Vr,Hr={"&":"&","<":"<",">":">",'"':""","'":"'"},Jr=b(Hr),Kr=RegExp("("+Gr(Jr).join("|")+")","g"),Lr=RegExp("["+Gr(Hr).join("")+"]","g"),Qr=function(n,r){var t;if(!n||!hr[typeof n])return n;for(t in n)if(r(n[t],t,n)===tr)break;return n},Xr=function(n,r){var t;if(!n||!hr[typeof n])return n;for(t in n)if(Tr.call(n,t)&&r(n[t],t,n)===tr)break;return n};j(/x/)&&(j=function(n){return typeof n=="function"&&"[object Function]"==Sr.call(n) +});var Yr=c(function(n,r,t){Tr.call(n,t)?n[t]++:n[t]=1}),Zr=c(function(n,r,t){(Tr.call(n,t)?n[t]:n[t]=[]).push(r)}),nt=c(function(n,r,t){n[t]=r});u.after=function(n,r){if(!j(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=K,u.bindAll=function(n){for(var r=1u(o,f)){for(var a=t;--a;)if(0>u(r[a],f))continue n;o.push(f)}}return o},u.invert=b,u.invoke=function(n,r){var t=Wr.call(arguments,2),e=-1,u=typeof r=="function",i=n?n.length:0,o=Array(typeof i=="number"?i:0); +return R(n,function(n){o[++e]=(u?r:n[r]).apply(n,t)}),o},u.keys=Gr,u.map=F,u.max=k,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):er+arguments[0];return Tr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var e=1/0,u=e,i=-1,o=n?n.length:0;if(r||typeof o!="number")r=L(r,t,3),R(n,function(n,t,i){t=r(n,t,i),tr(t,u)&&(e[u]=n) +}),e},u.once=function(n){var r,t;if(!j(n))throw new TypeError;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},u.pairs=function(n){for(var r=-1,t=Gr(n),e=t.length,u=Array(e);++rr?0:r);++nt?Mr(0,e+t):$r(t,e-1))+1);e--;)if(n[e]===r)return e;return-1 +},u.mixin=Y,u.noConflict=function(){return yr._=jr,this},u.random=Z,u.reduce=M,u.reduceRight=$,u.result=function(n,r){var t=n?n[r]:nr;return j(t)?n[r]():t},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Gr(n).length},u.some=W,u.sortedIndex=H,u.template=function(n,r,e){var i=u,o=i.templateSettings;n||(n=""),e=_({},e,o);var f=0,a="__p+='",o=e.variable;n.replace(RegExp((e.escape||ur).source+"|"+(e.interpolate||ur).source+"|"+(e.evaluate||ur).source+"|$","g"),function(r,e,u,i,o){return a+=n.slice(f,o).replace(ir,t),e&&(a+="'+_.escape("+e+")+'"),i&&(a+="';"+i+";__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=o+r.length,r +}),a+="';\n",o||(o="obj",a="with("+o+"||{}){"+a+"}"),a="function("+o+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";try{var l=Function("_","return "+a)(i)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+"").replace(Kr,g)},u.uniqueId=function(n){var r=++rr+"";return n?n+r:r},u.all=S,u.any=W,u.detect=N,u.findWhere=function(n,r){return C(n,r,!0)},u.foldl=M,u.foldr=$,u.include=O,u.inject=M,u.first=U,u.last=function(n,r,t){if(n){var e=0,u=n.length; +if(typeof r!="number"&&null!=r){var i=u;for(r=L(r,t,3);i--&&r(n[i],i,n);)e++}else if(e=r,null==e||t)return n[u-1];return Wr.call(n,Mr(0,u-e))}},u.sample=function(n,r,t){return Ur(n)||(n=z(n)),null==r||t?n[Z(n.length-1)]:(n=I(n),n.length=$r(Mr(0,r),n.length),n)},u.take=U,u.head=U,Y(u),u.VERSION="1.3.1",u.prototype.chain=function(){return this.__chain__=!0,this},u.prototype.value=function(){return this.__wrapped__},R("pop push reverse shift sort splice unshift".split(" "),function(n){var r=br[n];u.prototype[n]=function(){var n=this.__wrapped__; +return r.apply(n,arguments),Pr.spliceObjects||0!==n.length||delete n[0],this}}),R(["concat","join","slice"],function(n){var r=br[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new i(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(yr._=u, define(function(){return u})):mr&&!mr.nodeType?_r?(_r.exports=u)._=u:mr._=u:yr._=u}).call(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 698476cff..ab1ae456e 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1063,7 +1063,7 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6288 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6284 "View in source") [Ⓣ][1] Creates a `lodash` object that wraps the given `value`. @@ -1096,7 +1096,7 @@ var youngest = _.chain(stooges) ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6316 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6312 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument and then returns `value`. The purpose of this method is to "tap into" a method chain in order to perform operations on intermediate results within the chain. @@ -1126,7 +1126,7 @@ _([1, 2, 3, 4]) ### `_.prototype.chain()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6336 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6332 "View in source") [Ⓣ][1] Enables method chaining on the wrapper object. @@ -1150,7 +1150,7 @@ var sum = _([1, 2, 3]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6353 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6349 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1171,7 +1171,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6370 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6366 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -2433,7 +2433,7 @@ source.addEventListener('message', _.debounce(batchLog, 250, { ### `_.defer(func, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5537 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5535 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be provided to `func` when it is invoked. @@ -2458,7 +2458,7 @@ _.defer(function() { console.log('deferred'); }); ### `_.delay(func, wait, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5571 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5569 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be provided to `func` when it is invoked. @@ -2485,7 +2485,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func, [resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5613 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5611 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is provided it will be used to determine the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. The result cache is exposed as the `cache` property on the memoized function. @@ -2525,7 +2525,7 @@ stooge('curly'); ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5646 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5644 "View in source") [Ⓣ][1] Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. @@ -2551,7 +2551,7 @@ initialize(); ### `_.partial(func, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5684 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5682 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those provided to the new function. This method is similar to `_.bind` except it does **not** alter the `this` binding. @@ -2578,7 +2578,7 @@ hi('moe'); ### `_.partialRight(func, [arg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5715 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5713 "View in source") [Ⓣ][1] This method is like `_.partial` except that `partial` arguments are appended to those provided to the new function. @@ -2615,7 +2615,7 @@ options.imports ### `_.throttle(func, wait, [options], [options.leading=true], [options.trailing=true])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5750 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5748 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Provide an options object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2651,7 +2651,7 @@ jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5794 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5792 "View in source") [Ⓣ][1] Creates a function that provides `value` to the wrapper function as its first argument. Additional arguments provided to the function are appended to those provided to the wrapper function. The wrapper is executed with the `this` binding of the created function. @@ -3826,7 +3826,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5821 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5819 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3850,7 +3850,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5837 "View in source") [Ⓣ][1] This method returns the first argument provided to it. @@ -3875,7 +3875,7 @@ moe === _.identity(moe); ### `_.mixin(object, object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5866 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5864 "View in source") [Ⓣ][1] Adds function properties of a source object to the `lodash` function and chainable wrapper. @@ -3906,7 +3906,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5904 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5902 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3926,7 +3926,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value, [radix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5928 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5926 "View in source") [Ⓣ][1] Converts the given `value` into an integer of the specified `radix`. If `radix` is `undefined` or `0` a `radix` of `10` is used unless the `value` is a hexadecimal, in which case a `radix` of `16` is used. @@ -3953,7 +3953,7 @@ _.parseInt('08'); ### `_.random([min=0], [max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5952 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5950 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is provided a number between `0` and the given number will be returned. @@ -3981,7 +3981,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5996 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5994 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey then `undefined` is returned. @@ -4034,7 +4034,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, [options], [options.escape], [options.evaluate], [options.imports], [options.interpolate], [sourceURL], [variable])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6087 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6085 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -4081,8 +4081,8 @@ _.template('hello ${ name }', { 'name': 'curly' }); // => 'hello curly' // using the internal `print` function in "evaluate" delimiters -_.template('<% print("hello " + epithet); %>!', { 'epithet': 'stooge' }); -// => 'hello stooge!' +_.template('<% print("hello " + name); %>!', { 'name': 'larry' }); +// => 'hello larry!' // using a custom template delimiters _.templateSettings = { @@ -4128,7 +4128,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback, [thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6212 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6208 "View in source") [Ⓣ][1] Executes the callback `n` times, returning an array of the results of each callback execution. The callback is bound to `thisArg` and invoked with one argument; *(index)*. @@ -4160,7 +4160,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6239 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6235 "View in source") [Ⓣ][1] The inverse of `_.escape` this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -4184,7 +4184,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6259 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6255 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is provided the ID will be appended to it. @@ -4237,7 +4237,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6568 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6564 "View in source") [Ⓣ][1] *(string)*: The semantic version number.