diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 5fd66c455..f891c7160 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -528,6 +528,10 @@ setTimeout = context.setTimeout, splice = arrayRef.splice; + /** Used to detect `setImmediate` in Node.js */ + var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' && + !reNative.test(setImmediate) && setImmediate; + /** Used to set meta data */ var defineProperty = (function() { // IE 8 only accepts DOM elements @@ -550,10 +554,6 @@ nativeParseInt = context.parseInt, nativeRandom = Math.random; - /** Used to detect `setImmediate` in Node.js */ - var isV8 = nativeCreate && !/\n/.test(nativeCreate) && !reNative.test(context.attachEvent), - setImmediate = typeof (setImmediate = isV8 && moduleExports && context.setImmediate) == 'function' && setImmediate; - /** Used to lookup a built-in constructor by [[Class]] */ var ctorByClass = {}; ctorByClass[arrayClass] = Array; @@ -978,16 +978,18 @@ /*--------------------------------------------------------------------------*/ /** - * The base implementation of `_.bind` without `func` type checking or support - * for setting meta data. + * The base implementation of `_.bind` that creates the bound function and + * sets its meta data. * * @private - * @param {Function} func The function to bind. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partialArgs] An array of arguments to be partially applied. + * @param {Array} bindData The bind data array. * @returns {Function} Returns the new bound function. */ - function baseBind(func, thisArg, partialArgs) { + function baseBind(bindData) { + var func = bindData[0], + partialArgs = bindData[2], + thisArg = bindData[4]; + function bound() { // `Function#bind` spec // http://es5.github.io/#x15.3.4.5 @@ -1005,6 +1007,7 @@ } return func.apply(thisArg, args || arguments); } + setBindData(bound, bindData); return bound; } @@ -1181,44 +1184,42 @@ } /** - * The base implementation of `createWrapper` without `func` type checking - * or support for setting meta data. + * The base implementation of `createWrapper` that creates the wrapper and + * sets its meta data. * * @private - * @param {Function|string} func The function or method name to reference. - * @param {number} bitmask The bitmask of method flags to compose. - * @param {Array} [partialArgs] An array of arguments to prepend to those - * provided to the new function. - * @param {Array} [partialRightArgs] An array of arguments to append to those - * provided to the new function. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {number} [arity] The arity of `func`. + * @param {Array} bindData The bind data array. * @returns {Function} Returns the new function. */ - function baseCreateWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) { + function baseCreateWrapper(bindData) { + var func = bindData[0], + bitmask = bindData[1], + partialArgs = bindData[2], + partialRightArgs = bindData[3], + thisArg = bindData[4], + arity = bindData[5]; + var isBind = bitmask & 1, isBindKey = bitmask & 2, isCurry = bitmask & 4, isCurryBound = bitmask & 8, - isPartial = bitmask & 16, - isPartialRight = bitmask & 32, key = func; function bound() { var thisBinding = isBind ? thisArg : this; - if (isCurry || isPartial || isPartialRight) { - if (isPartial) { + if (isCurry || partialArgs || partialRightArgs) { + if (partialArgs) { var args = partialArgs.slice(); push.apply(args, arguments); } - if (isPartialRight || isCurry) { + if (partialRightArgs || isCurry) { args || (args = slice(arguments)); - if (isPartialRight) { + if (partialRightArgs) { push.apply(args, partialRightArgs); } if (isCurry && args.length < arity) { bitmask |= 16 & ~32; - return createWrapper(func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity); + return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]); } } } @@ -1233,6 +1234,7 @@ } return func.apply(thisBinding, args); } + setBindData(bound, bindData); return bound; } @@ -1677,12 +1679,8 @@ return createWrapper.apply(null, bindData); } // fast path for `_.bind` - var result = (bitmask == 1 || bitmask === 17) - ? baseBind(func, thisArg, partialArgs) - : baseCreateWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity); - - setBindData(result, [func, bitmask, partialArgs, partialRightArgs, thisArg, arity]); - return result; + var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper; + return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]); } /** @@ -1762,7 +1760,7 @@ * * @private * @param {Function} func The function to set data on. - * @param {*} value The value to set. + * @param {Array} value The data array to set. */ var setBindData = !defineProperty ? noop : function(func, value) { descriptor.value = value; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 417fe8f75..40277c950 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -5,54 +5,54 @@ */ ;(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&&f===n,h=u||g?i():c; -if(g){var v=o(h);v?(f=t,h=v):(g=!1,h=u?h:(p(h),c))}for(;++af(h,y))&&((u||g)&&h.push(y),c.push(v))}return g?(p(h.k),s(h)):u&&p(h),c}function pt(n){return function(t,e,r){var u={};if(e=y.createCallback(e,r,3),Ke(t)){r=-1;for(var o=t.length;++rk;k++)r+="n='"+e.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",e.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+e.g+"}";r+="}"}return(e.b||ze.nonEnumArgs)&&(r+="}"),r+=e.c+";return E",n("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",t+r+"}")(et,K,ce,we,_,dt,Ke,kt,X.f,pe,Y,Te,H,se,he) -}function ht(n){return Ue[n]}function vt(){var t=(t=y.indexOf)===qt?n:t;return t}function yt(n){var t,e;return!n||he.call(n)!=J||(t=n.constructor,jt(t)&&!(t instanceof t))||!ze.argsClass&&dt(n)||!ze.nodeClass&&l(n)?!1:ze.ownLast?(tr(n,function(n,t,r){return e=we.call(r,t),!1}),false!==e):(tr(n,function(n,t){e=t}),typeof e=="undefined"||we.call(n,e))}function mt(n){return Ve[n]}function dt(n){return n&&typeof n=="object"&&typeof n.length=="number"&&he.call(n)==L||!1}function _t(n,t,e){var r=Ge(n),u=r.length; -for(t=et(t,e,3);u--&&(e=r[u],false!==t(n[e],e,n)););return n}function bt(n){var t=[];return tr(n,function(n,e){jt(n)&&t.push(e)}),t.sort()}function wt(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=null==t&&kt(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 Rt(n,t,e,r){var u=3>arguments.length;if(t=et(t,r,4),Ke(n)){var o=-1,a=n.length;for(u&&(e=n[++o]);++oarguments.length;return t=et(t,r,4),Nt(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o)}),e}function $t(n){var t=-1,e=n?n.length:0,r=Zt(typeof e=="number"?e:0);return Dt(n,function(n){var e=lt(0,++t);r[t]=r[e],r[e]=n}),r}function Lt(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(l){var c=o(i);c?(u=t,i=c):l=!1}for(;++ru(i,c)&&f.push(c);return l&&s(i),f}function zt(n,t,e){var r=0,u=n?n.length:0;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=Wt(t,e),t[r]===e?r:-1;return n(t,e,r)}function Kt(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);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:D,variable:"",imports:{_:y}},Se||(tt=function(n){if(xt(n)){c.prototype=n;var t=new c;c.prototype=null}return t||{}});var qe=Oe?function(n,t){Q.value=t,Oe(n,"__bindData__",Q)}:c;ze.argsClass||(dt=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&we.call(n,"callee")||!1});var Ke=Ie||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&he.call(n)==T||!1 -},We=gt({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),Ge=Ne?function(n){return xt(n)?ze.enumPrototypes&&typeof n=="function"||ze.nonEnumArgs&&n.length&&dt(n)?We(n):Ne(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=wt(Ue),Qe=ae("("+Ge(Ve).join("|")+")","g"),Xe=ae("["+Ge(Ue).join("")+"]","g"),Ye=gt(Je),Ze=gt(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=gt(Me),tr=gt(Je,He,{j:!1}),er=gt(Je,He); -jt(/x/)&&(jt=function(n){return typeof n=="function"&&he.call(n)==W});var rr=be?function(n){if(!n||he.call(n)!=J||!ze.argsClass&&dt(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=be(t))&&be(e);return e?n==e||be(n)==e:yt(n)}:yt,ur=pt(function(n,t,e){we.call(n,e)?n[e]++:n[e]=1}),or=pt(function(n,t,e){(we.call(n,e)?n[e]:n[e]=[]).push(t)}),ar=pt(function(n,t,e){n[e]=t}),ir=Bt;$e&&(Vt=function(n){if(!jt(n))throw new fe;return $e.apply(e,arguments)});var fr=8==Re(x+"08")?Re:function(n,t){return Re(kt(n)?n.replace(N,""):n,t||0) -};return y.after=function(n,t){if(!jt(t))throw new fe;return function(){return 1>--n?t.apply(this,arguments):void 0}},y.assign=Ze,y.at=function(n){var t=arguments,e=-1,r=at(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Zt(t);for(ze.unindexedChars&&kt(n)&&(n=n.split(""));++e=w&&o(a?r[a]:v)}n:for(;++l(m?t(m,y):c(v,y))){for(a=u,(m||v).push(y);--a;)if(m=f[a],0>(m?t(m,y):c(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=f[u])&&s(m);return p(f),p(v),h},y.invert=wt,y.invoke=function(n,t){var e=g(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=Zt(typeof o=="number"?o:0);return Dt(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},y.keys=Ge,y.map=Bt,y.max=Pt,y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):b+arguments[0]; -return we.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!jt(n))throw new fe;return e.cache={},e},y.merge=function(n){var t=arguments,e=2;if(!xt(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(!jt(n))throw new fe;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=Zt(r);++te?Be(0,r+e):Pe(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},y.mixin=Xt,y.noConflict=function(){return e._=ge,this},y.parseInt=fr,y.random=function(n,t,e){var r=null==n,u=null==t;return null==e&&(typeof n=="boolean"&&u?(e=n,n=1):u||typeof t!="boolean"||(e=t,u=!0)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,e||n%1||t%1?(e=Fe(),Pe(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):lt(n,t) -},y.reduce=Rt,y.reduceRight=Ft,y.result=function(n,t){if(n){var e=n[t];return jt(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=Lt,y.sortedIndex=Wt,y.template=function(n,t,e){var r=y.templateSettings;n=ie(n||""),e=nr({},e,r);var u,o=nr({},e.imports,r.imports),r=Ge(o),o=Et(o),i=0,f=e.interpolate||B,l="__p+='",f=ae((e.escape||B).source+"|"+f.source+"|"+(f===D?S:B).source+"|"+(e.evaluate||B).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(i,c).replace(R,a),e&&(l+="'+__e("+e+")+'"),f&&(u=!0,l+="';"+f+";\n__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t -}),l+="';",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(C,""):l).replace(E,"$1").replace(O,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=ee(r,"return "+l).apply(v,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},y.unescape=function(n){return null==n?"":ie(n).replace(Qe,mt)},y.uniqueId=function(n){var t=++d;return ie(null==n?"":n)+t -},y.all=St,y.any=Lt,y.detect=At,y.findWhere=At,y.foldl=Rt,y.foldr=Ft,y.include=Ot,y.inject=Rt,er(y,function(n,t){y.prototype[t]||(y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return xe.apply(t,arguments),t=n.apply(y,t),e?new m(t,e):t})}),y.first=zt,y.last=function(n,t,e){var r=0,u=n?n.length:0;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?n[u-1]:v;return g(n,Be(0,u-r))},y.sample=function(n,t,e){return n&&typeof n.length!="number"?n=Et(n):ze.unindexedChars&&kt(n)&&(n=n.split("")),null==t||e?n?n[lt(0,n.length-1)]:v:(n=$t(n),n.length=Pe(Be(0,t),n.length),n) -},y.take=zt,y.head=zt,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="2.2.1",y.prototype.chain=function(){return this.__chain__=!0,this},y.prototype.toString=function(){return ie(this.__wrapped__)},y.prototype.value=Yt,y.prototype.valueOf=Yt,Ye(["join","pop","shift"],function(n){var t=le[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=le[n];y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ye(["concat","slice","splice"],function(n){var t=le[n];y.prototype[n]=function(){return new m(t.apply(this.__wrapped__,arguments),this.__chain__)}}),ze.spliceObjects||Ye(["pop","shift","splice"],function(n){var t=le[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 +}function l(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function c(){}function p(n){n.length=0,y.lengthe?0:e);++r=w&&f===n,h=u||g?i():c; +if(g){var v=o(h);v?(f=t,h=v):(g=!1,h=u?h:(p(h),c))}for(;++af(h,y))&&((u||g)&&h.push(y),c.push(v))}return g?(p(h.k),s(h)):u&&p(h),c}function st(n){return function(t,e,r){var u={};if(e=y.createCallback(e,r,3),We(t)){r=-1;for(var o=t.length;++rk;k++)r+="n='"+e.h[k]+"';if((!(r&&x[n])&&m.call(t,n))",e.j||(r+="||(!x[n]&&t[n]!==A[n])"),r+="){"+e.g+"}"; +r+="}"}return(e.b||qe.nonEnumArgs)&&(r+="}"),r+=e.c+";return E",n("d,j,k,m,o,p,q,s,v,A,B,y,I,J,L",t+r+"}")(et,K,pe,je,_,_t,We,Et,X.f,se,Y,ze,H,ge,ve)}function vt(n){return Ve[n]}function yt(){var t=(t=y.indexOf)===Kt?n:t;return t}function mt(n){var t,e;return!n||ve.call(n)!=J||(t=n.constructor,xt(t)&&!(t instanceof t))||!qe.argsClass&&_t(n)||!qe.nodeClass&&l(n)?!1:qe.ownLast?(er(n,function(n,t,r){return e=je.call(r,t),!1}),false!==e):(er(n,function(n,t){e=t}),typeof e=="undefined"||je.call(n,e))}function dt(n){return Qe[n] +}function _t(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ve.call(n)==L||!1}function bt(n,t,e){var r=Je(n),u=r.length;for(t=et(t,e,3);u--&&(e=r[u],false!==t(n[e],e,n)););return n}function wt(n){var t=[];return er(n,function(n,e){xt(n)&&t.push(e)}),t.sort()}function jt(n){for(var t=-1,e=Je(n),r=e.length,u={};++te?Re(0,o+e):e)||0,We(n)?a=-1o&&(o=i)}}else t=null==t&&Et(n)?r:y.createCallback(t,e,3),Ze(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function Ft(n,t,e,r){var u=3>arguments.length;if(t=et(t,r,4),We(n)){var o=-1,a=n.length;for(u&&(e=n[++o]);++oarguments.length;return t=et(t,r,4),Bt(n,function(n,r,o){e=u?(u=!1,n):t(e,n,r,o) +}),e}function Lt(n){var t=-1,e=n?n.length:0,r=ne(typeof e=="number"?e:0);return Nt(n,function(n){var e=ct(0,++t);r[t]=r[e],r[e]=n}),r}function Tt(n,t,e){var r;if(t=y.createCallback(t,e,3),We(n)){e=-1;for(var u=n.length;++e=w&&u===n;if(l){var c=o(i);c?(u=t,i=c):l=!1}for(;++ru(i,c)&&f.push(c);return l&&s(i),f}function qt(n,t,e){var r=0,u=n?n.length:0; +if(typeof t!="number"&&null!=t){var o=-1;for(t=y.createCallback(t,e,3);++or?Re(0,u+r):r||0}else if(r)return r=Gt(t,e),t[r]===e?r:-1;return n(t,e,r)}function Wt(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);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:D,variable:"",imports:{_:y}},Ae||(tt=function(n){if(Ct(n)){c.prototype=n;var t=new c;c.prototype=null}return t||{}});var Ke=Ie?function(n,t){Q.value=t,Ie(n,"__bindData__",Q)}:c;qe.argsClass||(_t=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&je.call(n,"callee")||!1});var We=De||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ve.call(n)==T||!1 +},Ge=ht({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),Je=Pe?function(n){return Ct(n)?qe.enumPrototypes&&typeof n=="function"||qe.nonEnumArgs&&n.length&&_t(n)?Ge(n):Pe(n):[]}:Ge,Me={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:Je,g:"if(e(t[n],n,g)===false)return E"},He={a:"z,H,l",i:"var a=arguments,b=0,c=typeof l=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Qe=jt(Ve),Xe=ie("("+Je(Qe).join("|")+")","g"),Ye=ie("["+Je(Ve).join("")+"]","g"),Ze=ht(Me),nr=ht(He,{i:He.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]"}),tr=ht(He),er=ht(Me,Ue,{j:!1}),rr=ht(Me,Ue); +xt(/x/)&&(xt=function(n){return typeof n=="function"&&ve.call(n)==W});var ur=we?function(n){if(!n||ve.call(n)!=J||!qe.argsClass&&_t(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=we(t))&&we(e);return e?n==e||we(n)==e:mt(n)}:mt,or=st(function(n,t,e){je.call(n,e)?n[e]++:n[e]=1}),ar=st(function(n,t,e){(je.call(n,e)?n[e]:n[e]=[]).push(t)}),ir=st(function(n,t,e){n[e]=t}),fr=Pt;Se&&(Qt=function(n){if(!xt(n))throw new le;return Se.apply(e,arguments)});var lr=8==$e(x+"08")?$e:function(n,t){return $e(Et(n)?n.replace(N,""):n,t||0) +};return y.after=function(n,t){if(!xt(t))throw new le;return function(){return 1>--n?t.apply(this,arguments):void 0}},y.assign=nr,y.at=function(n){var t=arguments,e=-1,r=it(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=ne(t);for(qe.unindexedChars&&Et(n)&&(n=n.split(""));++e=w&&o(a?r[a]:v)}n:for(;++l(m?t(m,y):c(v,y))){for(a=u,(m||v).push(y);--a;)if(m=f[a],0>(m?t(m,y):c(r[a],y)))continue n;h.push(y)}}for(;u--;)(m=f[u])&&s(m);return p(f),p(v),h},y.invert=jt,y.invoke=function(n,t){var e=g(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=ne(typeof o=="number"?o:0);return Nt(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},y.keys=Je,y.map=Pt,y.max=Rt,y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):b+arguments[0]; +return je.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!xt(n))throw new le;return e.cache={},e},y.merge=function(n){var t=arguments,e=2;if(!Ct(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(!xt(n))throw new le;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},y.pairs=function(n){for(var t=-1,e=Je(n),r=e.length,u=ne(r);++te?Re(0,r+e):Fe(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},y.mixin=Yt,y.noConflict=function(){return e._=he,this},y.parseInt=lr,y.random=function(n,t,e){var r=null==n,u=null==t;return null==e&&(typeof n=="boolean"&&u?(e=n,n=1):u||typeof t!="boolean"||(e=t,u=!0)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,e||n%1||t%1?(e=Le(),Fe(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):ct(n,t) +},y.reduce=Ft,y.reduceRight=$t,y.result=function(n,t){if(n){var e=n[t];return xt(e)?n[t]():e}},y.runInContext=h,y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Je(n).length},y.some=Tt,y.sortedIndex=Gt,y.template=function(n,t,e){var r=y.templateSettings;n=fe(n||""),e=tr({},e,r);var u,o=tr({},e.imports,r.imports),r=Je(o),o=Ot(o),i=0,f=e.interpolate||B,l="__p+='",f=ie((e.escape||B).source+"|"+f.source+"|"+(f===D?S:B).source+"|"+(e.evaluate||B).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(i,c).replace(R,a),e&&(l+="'+__e("+e+")+'"),f&&(u=!0,l+="';"+f+";\n__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),i=c+t.length,t +}),l+="';",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(C,""):l).replace(E,"$1").replace(O,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=re(r,"return "+l).apply(v,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},y.unescape=function(n){return null==n?"":fe(n).replace(Xe,dt)},y.uniqueId=function(n){var t=++d;return fe(null==n?"":n)+t +},y.all=It,y.any=Tt,y.detect=Dt,y.findWhere=Dt,y.foldl=Ft,y.foldr=$t,y.include=St,y.inject=Ft,rr(y,function(n,t){y.prototype[t]||(y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return Ce.apply(t,arguments),t=n.apply(y,t),e?new m(t,e):t})}),y.first=qt,y.last=function(n,t,e){var r=0,u=n?n.length:0;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?n[u-1]:v;return g(n,Re(0,u-r))},y.sample=function(n,t,e){return n&&typeof n.length!="number"?n=Ot(n):qe.unindexedChars&&Et(n)&&(n=n.split("")),null==t||e?n?n[ct(0,n.length-1)]:v:(n=Lt(n),n.length=Fe(Re(0,t),n.length),n) +},y.take=qt,y.head=qt,rr(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="2.2.1",y.prototype.chain=function(){return this.__chain__=!0,this},y.prototype.toString=function(){return fe(this.__wrapped__)},y.prototype.value=Zt,y.prototype.valueOf=Zt,Ze(["join","pop","shift"],function(n){var t=ce[n];y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments); +return n?new m(e,n):e}}),Ze(["push","reverse","sort","unshift"],function(n){var t=ce[n];y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ze(["concat","slice","splice"],function(n){var t=ce[n];y.prototype[n]=function(){return new m(t.apply(this.__wrapped__,arguments),this.__chain__)}}),qe.spliceObjects||Ze(["pop","shift","splice"],function(n){var t=ce[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,I=/\w*$/,A=/^function[ \n\r\t]+\w/,D=/<%=([\s\S]+?)%>/g,N=RegExp("^["+x+"]*0+(?=.$)"),B=/($^)/,P=/\bthis\b/,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(" "),L="[object Arguments]",T="[object Array]",z="[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[L]=U[T]=U[z]=U[q]=U[G]=U[J]=U[M]=U[H]=!0;var V={leading:!1,maxWait:0,trailing:!1},Q={configurable:!1,enumerable:!1,value:null,writable:!1},X={a:"",b:null,c:"",d:"",e:"",v:null,g:"",h:null,support:null,i:"",j:!1},Y={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},Z={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},nt=Y[typeof window]&&window||this,tt=Y[typeof exports]&&exports&&!exports.nodeType&&exports,et=Y[typeof module]&&module&&!module.nodeType&&module,rt=et&&et.exports===tt&&tt,ut=Y[typeof global]&&global; !ut||ut.global!==ut&&ut.window!==ut||(nt=ut);var ot=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(nt._=ot, define(function(){return ot})):tt&&et?rt?(et.exports=ot)._=ot:tt._=ot:nt._=ot}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 7bfbe686e..3e7a6cdb8 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -486,6 +486,10 @@ setTimeout = context.setTimeout, splice = arrayRef.splice; + /** Used to detect `setImmediate` in Node.js */ + var setImmediate = typeof (setImmediate = freeGlobal && moduleExports && freeGlobal.setImmediate) == 'function' && + !reNative.test(setImmediate) && setImmediate; + /** Used to set meta data */ var defineProperty = (function() { // IE 8 only accepts DOM elements @@ -508,10 +512,6 @@ nativeParseInt = context.parseInt, nativeRandom = Math.random; - /** Used to detect `setImmediate` in Node.js */ - var isV8 = nativeCreate && !/\n/.test(nativeCreate) && !reNative.test(context.attachEvent), - setImmediate = typeof (setImmediate = isV8 && moduleExports && context.setImmediate) == 'function' && setImmediate; - /** Used to lookup a built-in constructor by [[Class]] */ var ctorByClass = {}; ctorByClass[arrayClass] = Array; @@ -702,16 +702,18 @@ /*--------------------------------------------------------------------------*/ /** - * The base implementation of `_.bind` without `func` type checking or support - * for setting meta data. + * The base implementation of `_.bind` that creates the bound function and + * sets its meta data. * * @private - * @param {Function} func The function to bind. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partialArgs] An array of arguments to be partially applied. + * @param {Array} bindData The bind data array. * @returns {Function} Returns the new bound function. */ - function baseBind(func, thisArg, partialArgs) { + function baseBind(bindData) { + var func = bindData[0], + partialArgs = bindData[2], + thisArg = bindData[4]; + function bound() { // `Function#bind` spec // http://es5.github.io/#x15.3.4.5 @@ -729,6 +731,7 @@ } return func.apply(thisArg, args || arguments); } + setBindData(bound, bindData); return bound; } @@ -905,44 +908,42 @@ } /** - * The base implementation of `createWrapper` without `func` type checking - * or support for setting meta data. + * The base implementation of `createWrapper` that creates the wrapper and + * sets its meta data. * * @private - * @param {Function|string} func The function or method name to reference. - * @param {number} bitmask The bitmask of method flags to compose. - * @param {Array} [partialArgs] An array of arguments to prepend to those - * provided to the new function. - * @param {Array} [partialRightArgs] An array of arguments to append to those - * provided to the new function. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {number} [arity] The arity of `func`. + * @param {Array} bindData The bind data array. * @returns {Function} Returns the new function. */ - function baseCreateWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) { + function baseCreateWrapper(bindData) { + var func = bindData[0], + bitmask = bindData[1], + partialArgs = bindData[2], + partialRightArgs = bindData[3], + thisArg = bindData[4], + arity = bindData[5]; + var isBind = bitmask & 1, isBindKey = bitmask & 2, isCurry = bitmask & 4, isCurryBound = bitmask & 8, - isPartial = bitmask & 16, - isPartialRight = bitmask & 32, key = func; function bound() { var thisBinding = isBind ? thisArg : this; - if (isCurry || isPartial || isPartialRight) { - if (isPartial) { + if (isCurry || partialArgs || partialRightArgs) { + if (partialArgs) { var args = partialArgs.slice(); push.apply(args, arguments); } - if (isPartialRight || isCurry) { + if (partialRightArgs || isCurry) { args || (args = slice(arguments)); - if (isPartialRight) { + if (partialRightArgs) { push.apply(args, partialRightArgs); } if (isCurry && args.length < arity) { bitmask |= 16 & ~32; - return createWrapper(func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity); + return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]); } } } @@ -957,6 +958,7 @@ } return func.apply(thisBinding, args); } + setBindData(bound, bindData); return bound; } @@ -1401,12 +1403,8 @@ return createWrapper.apply(null, bindData); } // fast path for `_.bind` - var result = (bitmask == 1 || bitmask === 17) - ? baseBind(func, thisArg, partialArgs) - : baseCreateWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity); - - setBindData(result, [func, bitmask, partialArgs, partialRightArgs, thisArg, arity]); - return result; + var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper; + return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]); } /** @@ -1438,7 +1436,7 @@ * * @private * @param {Function} func The function to set data on. - * @param {*} value The value to set. + * @param {Array} value The data array to set. */ var setBindData = !defineProperty ? noop : function(func, value) { descriptor.value = value; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index b93ef8723..123f14638 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -5,50 +5,50 @@ */ ;(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=b&&f===n,h=u||v?a():s;if(v){var g=o(h);g?(f=t,h=g):(v=!1,h=u?h:(c(h),s))}for(;++if(h,y))&&((u||v)&&h.push(y),s.push(g))}return v?(c(h.k),p(h)):u&&c(h),s}function pt(n){return function(t,e,r){var u={};e=Y.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++re?Se(0,o+e):e)||0,We(n)?i=-1o&&(o=a)}}else t=null==t&&xt(n)?r:Y.createCallback(t,e,3),St(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function $t(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Zt(r);++earguments.length;t=ut(t,r,4); -var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length;return t=ut(t,r,4),Rt(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=Zt(typeof e=="number"?e:0);return St(n,function(n){var e=lt(0,++t);r[t]=r[e],r[e]=n}),r}function Wt(n,t,e){var r;t=Y.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e=b&&u===n;if(l){var c=o(a);c?(u=t,a=c):l=!1}for(;++ru(a,c)&&f.push(c);return l&&p(a),f}function zt(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=Y.createCallback(t,e,3);++or?Se(0,u+r):r||0}else if(r)return r=Lt(t,e),t[r]===e?r:-1; -return n(t,e,r)}function Kt(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);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Y}},Ce||(rt=function(n){if(jt(n)){l.prototype=n;var t=new l;l.prototype=null}return t||{}});var Be=xe?function(n,t){U.value=t,xe(n,"__bindData__",U)}:l,We=Oe||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&se.call(n)==F||!1},qe=Ee?function(n){return jt(n)?Ee(n):[]}:Q,ze={"&":"&","<":"<",">":">",'"':""","'":"'"},Pe=dt(ze),Ke=ie("("+qe(Pe).join("|")+")","g"),Le=ie("["+qe(ze).join("")+"]","g"),Me=pt(function(n,t,e){be.call(n,e)?n[e]++:n[e]=1 -}),Ue=pt(function(n,t,e){(be.call(n,e)?n[e]:n[e]=[]).push(t)}),Ve=pt(function(n,t,e){n[e]=t});$e&&(Jt=function(n){if(!wt(n))throw new fe;return $e.apply(e,arguments)});var Ge=8==Ae(w+"08")?Ae:function(n,t){return Ae(xt(n)?n.replace(E,""):n,t||0)};return Y.after=function(n,t){if(!wt(t))throw new fe;return function(){return 1>--n?t.apply(this,arguments):void 0}},Y.assign=J,Y.at=function(n){for(var t=arguments,e=-1,r=it(t,!0,!1,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Zt(t);++e=b&&o(i?r[i]:g)}n:for(;++l(m?t(m,y):s(g,y))){for(i=u,(m||g).push(y);--i;)if(m=f[i],0>(m?t(m,y):s(r[i],y)))continue n; -h.push(y)}}for(;u--;)(m=f[u])&&p(m);return c(f),c(g),h},Y.invert=dt,Y.invoke=function(n,t){var e=s(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,i=Zt(typeof o=="number"?o:0);return St(n,function(n){i[++r]=(u?t:n[t]).apply(n,e)}),i},Y.keys=qe,Y.map=At,Y.max=Dt,Y.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):_+arguments[0];return be.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!wt(n))throw new fe;return e.cache={},e},Y.merge=function(n){var t=arguments,e=2; -if(!jt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(i,e))&&(o[e]=n)}),o},Y.once=function(n){var t,e;if(!wt(n))throw new fe;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},Y.pairs=function(n){for(var t=-1,e=qe(n),r=e.length,u=Zt(r);++te?Se(0,r+e):Re(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Y.mixin=Xt,Y.noConflict=function(){return e._=pe,this},Y.parseInt=Ge,Y.random=function(n,t,e){var r=null==n,u=null==t;return null==e&&(typeof n=="boolean"&&u?(e=n,n=1):u||typeof t!="boolean"||(e=t,u=!0)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,e||n%1||t%1?(e=De(),Re(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):lt(n,t) -},Y.reduce=Ft,Y.reduceRight=Tt,Y.result=function(n,t){if(n){var e=n[t];return wt(e)?n[t]():e}},Y.runInContext=v,Y.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:qe(n).length},Y.some=Wt,Y.sortedIndex=Lt,Y.template=function(n,t,e){var r=Y.templateSettings;n=ae(n||""),e=G({},e,r);var u,o=G({},e.imports,r.imports),r=qe(o),o=Ct(o),a=0,f=e.interpolate||S,l="__p+='",f=ie((e.escape||S).source+"|"+f.source+"|"+(f===N?C:S).source+"|"+(e.evaluate||S).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(a,c).replace(A,i),e&&(l+="'+__e("+e+")+'"),f&&(u=!0,l+="';"+f+";\n__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),a=c+t.length,t -}),l+="';",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(j,""):l).replace(k,"$1").replace(x,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=ee(r,"return "+l).apply(h,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},Y.unescape=function(n){return null==n?"":ae(n).replace(Ke,yt)},Y.uniqueId=function(n){var t=++m;return ae(null==n?"":n)+t -},Y.all=It,Y.any=Wt,Y.detect=Et,Y.findWhere=Et,Y.foldl=Ft,Y.foldr=Tt,Y.include=Ot,Y.inject=Ft,y(Y,function(n,t){Y.prototype[t]||(Y.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return we.apply(t,arguments),t=n.apply(Y,t),e?new nt(t,e):t})}),Y.first=zt,Y.last=function(n,t,e){var r=0,u=n?n.length:0;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?n[u-1]:h;return s(n,Se(0,u-r))},Y.sample=function(n,t,e){return n&&typeof n.length!="number"&&(n=Ct(n)),null==t||e?n?n[lt(0,n.length-1)]:h:(n=Bt(n),n.length=Re(Se(0,t),n.length),n) -},Y.take=zt,Y.head=zt,y(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 nt(o,u):o})}),Y.VERSION="2.2.1",Y.prototype.chain=function(){return this.__chain__=!0,this},Y.prototype.toString=function(){return ae(this.__wrapped__)},Y.prototype.value=Yt,Y.prototype.valueOf=Yt,St(["join","pop","shift"],function(n){var t=le[n];Y.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments); -return n?new nt(e,n):e}}),St(["push","reverse","sort","unshift"],function(n){var t=le[n];Y.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),St(["concat","slice","splice"],function(n){var t=le[n];Y.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Y}var h,g=[],y=[],m=0,_=+new Date+"",b=75,d=40,w=" \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",j=/\b__p\+='';/g,k=/\b(__p\+=)''\+/g,x=/(__e\(.*?\)|\b__t\))\+'';/g,C=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,O=/\w*$/,I=/^function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,E=RegExp("^["+w+"]*0+(?=.$)"),S=/($^)/,R=/\bthis\b/,A=/['\n\r\t\u2028\u2029\\]/g,D="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),$="[object Arguments]",F="[object Array]",T="[object Boolean]",B="[object Date]",W="[object Function]",q="[object Number]",z="[object Object]",P="[object RegExp]",K="[object String]",L={}; +}function l(){}function c(n){n.length=0,g.lengthe?0:e);++r=b&&f===n,h=u||v?a():s;if(v){var g=o(h);g?(f=t,h=g):(v=!1,h=u?h:(c(h),s))}for(;++if(h,y))&&((u||v)&&h.push(y),s.push(g)) +}return v?(c(h.k),p(h)):u&&c(h),s}function it(n){return function(t,e,r){var u={};e=g.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++re?Oe(0,o+e):e)||0,De(n)?i=-1o&&(o=a)}}else t=null==t&&bt(n)?r:g.createCallback(t,e,3),Ct(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function Et(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Ht(r);++earguments.length;t=Q(t,r,4); +var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length;return t=Q(t,r,4),Ot(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=Ht(typeof e=="number"?e:0);return Ct(n,function(n){var e=ut(0,++t);r[t]=r[e],r[e]=n}),r}function Dt(n,t,e){var r;t=g.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e=b&&u===n;if(l){var c=o(a);c?(u=t,a=c):l=!1}for(;++ru(a,c)&&f.push(c);return l&&p(a),f}function Ft(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=-1;for(t=g.createCallback(t,e,3);++or?Oe(0,u+r):r||0}else if(r)return r=Wt(t,e),t[r]===e?r:-1; +return n(t,e,r)}function Bt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=g.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:g}},we||(J=function(n){if(mt(n)){l.prototype=n; +var t=new l;l.prototype=null}return t||{}});var Ae=de?function(n,t){U.value=t,de(n,"__bindData__",U)}:l,De=je||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ae.call(n)==F||!1},$e=function(n){var t,e=[];if(!n||!V[typeof n])return e;for(t in n)he.call(n,t)&&e.push(t);return e},Fe=Ce?function(n){return mt(n)?Ce(n):[]}:$e,Te={"&":"&","<":"<",">":">",'"':""","'":"'"},Be=gt(Te),We=te("("+Fe(Be).join("|")+")","g"),qe=te("["+Fe(Te).join("")+"]","g"),ze=function(n,t,e){var r,u=n,o=u; +if(!u)return o;var i=arguments,a=0,f=typeof e=="number"?2:i.length;if(3--n?t.apply(this,arguments):void 0}},g.assign=ze,g.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=Ht(t);++e=b&&o(i?r[i]:g)}n:for(;++l(m?t(m,y):s(g,y))){for(i=u,(m||g).push(y);--i;)if(m=f[i],0>(m?t(m,y):s(r[i],y)))continue n; +h.push(y)}}for(;u--;)(m=f[u])&&p(m);return c(f),c(g),h},g.invert=gt,g.invoke=function(n,t){var e=s(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,i=Ht(typeof o=="number"?o:0);return Ct(n,function(n){i[++r]=(u?t:n[t]).apply(n,e)}),i},g.keys=Fe,g.map=It,g.max=Nt,g.memoize=function(n,t){if(!yt(n))throw new re;var e=function(){var r=e.cache,u=t?t.apply(this,arguments):_+arguments[0];return he.call(r,u)?r[u]:r[u]=n.apply(this,arguments)};return e.cache={},e},g.merge=function(n){var t=arguments,e=2; +if(!mt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(i,e))&&(o[e]=n)}),o},g.once=function(n){var t,e;if(!yt(n))throw new re;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},g.pairs=function(n){for(var t=-1,e=Fe(n),r=e.length,u=Ht(r);++te?Oe(0,r+e):Ie(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},g.mixin=Vt,g.noConflict=function(){return e._=ie,this},g.parseInt=He,g.random=function(n,t,e){var r=null==n,u=null==t;return null==e&&(typeof n=="boolean"&&u?(e=n,n=1):u||typeof t!="boolean"||(e=t,u=!0)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,e||n%1||t%1?(e=Ee(),Ie(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):ut(n,t) +},g.reduce=St,g.reduceRight=Rt,g.result=function(n,t){if(n){var e=n[t];return yt(e)?n[t]():e}},g.runInContext=v,g.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Fe(n).length},g.some=Dt,g.sortedIndex=Wt,g.template=function(n,t,e){var r=g.templateSettings;n=ee(n||""),e=Pe({},e,r);var u,o=Pe({},e.imports,r.imports),r=Fe(o),o=dt(o),a=0,f=e.interpolate||S,l="__p+='",f=te((e.escape||S).source+"|"+f.source+"|"+(f===N?C:S).source+"|"+(e.evaluate||S).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(a,c).replace(A,i),e&&(l+="'+__e("+e+")+'"),f&&(u=!0,l+="';"+f+";\n__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),a=c+t.length,t +}),l+="';",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(j,""):l).replace(k,"$1").replace(x,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=Xt(r,"return "+l).apply(h,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},g.unescape=function(n){return null==n?"":ee(n).replace(We,pt)},g.uniqueId=function(n){var t=++m;return ee(null==n?"":n)+t +},g.all=jt,g.any=Dt,g.detect=xt,g.findWhere=xt,g.foldl=St,g.foldr=Rt,g.include=wt,g.inject=St,Le(g,function(n,t){g.prototype[t]||(g.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return ye.apply(t,arguments),t=n.apply(g,t),e?new y(t,e):t})}),g.first=Ft,g.last=function(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=u;for(t=g.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n?n[u-1]:h;return s(n,Oe(0,u-r))},g.sample=function(n,t,e){return n&&typeof n.length!="number"&&(n=dt(n)),null==t||e?n?n[ut(0,n.length-1)]:h:(n=At(n),n.length=Ie(Oe(0,t),n.length),n) +},g.take=Ft,g.head=Ft,Le(g,function(n,t){var e="sample"!==t;g.prototype[t]||(g.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 y(o,u):o})}),g.VERSION="2.2.1",g.prototype.chain=function(){return this.__chain__=!0,this},g.prototype.toString=function(){return ee(this.__wrapped__)},g.prototype.value=Gt,g.prototype.valueOf=Gt,Ct(["join","pop","shift"],function(n){var t=ue[n];g.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments); +return n?new y(e,n):e}}),Ct(["push","reverse","sort","unshift"],function(n){var t=ue[n];g.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ct(["concat","slice","splice"],function(n){var t=ue[n];g.prototype[n]=function(){return new y(t.apply(this.__wrapped__,arguments),this.__chain__)}}),g}var h,g=[],y=[],m=0,_=+new Date+"",b=75,d=40,w=" \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",j=/\b__p\+='';/g,k=/\b(__p\+=)''\+/g,x=/(__e\(.*?\)|\b__t\))\+'';/g,C=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,O=/\w*$/,I=/^function[ \n\r\t]+\w/,N=/<%=([\s\S]+?)%>/g,E=RegExp("^["+w+"]*0+(?=.$)"),S=/($^)/,R=/\bthis\b/,A=/['\n\r\t\u2028\u2029\\]/g,D="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),$="[object Arguments]",F="[object Array]",T="[object Boolean]",B="[object Date]",W="[object Function]",q="[object Number]",z="[object Object]",P="[object RegExp]",K="[object String]",L={}; L[W]=!1,L[$]=L[F]=L[T]=L[B]=L[q]=L[z]=L[P]=L[K]=!0;var M={leading:!1,maxWait:0,trailing:!1},U={configurable:!1,enumerable:!1,value:null,writable:!1},V={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},G={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},H=V[typeof window]&&window||this,J=V[typeof exports]&&exports&&!exports.nodeType&&exports,Q=V[typeof module]&&module&&!module.nodeType&&module,X=Q&&Q.exports===J&&J,Y=V[typeof global]&&global;!Y||Y.global!==Y&&Y.window!==Y||(H=Y); var Z=v();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(H._=Z, define(function(){return Z})):J&&Q?X?(Q.exports=Z)._=Z:J._=Z:H._=Z}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 3f554d3f4..e52a94827 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -388,16 +388,18 @@ /*--------------------------------------------------------------------------*/ /** - * The base implementation of `_.bind` without `func` type checking or support - * for setting meta data. + * The base implementation of `_.bind` that creates the bound function and + * sets its meta data. * * @private - * @param {Function} func The function to bind. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {Array} [partialArgs] An array of arguments to be partially applied. + * @param {Array} bindData The bind data array. * @returns {Function} Returns the new bound function. */ - function baseBind(func, thisArg, partialArgs) { + function baseBind(bindData) { + var func = bindData[0], + partialArgs = bindData[2], + thisArg = bindData[4]; + function bound() { // `Function#bind` spec // http://es5.github.io/#x15.3.4.5 @@ -477,44 +479,42 @@ } /** - * The base implementation of `createWrapper` without `func` type checking - * or support for setting meta data. + * The base implementation of `createWrapper` that creates the wrapper and + * sets its meta data. * * @private - * @param {Function|string} func The function or method name to reference. - * @param {number} bitmask The bitmask of method flags to compose. - * @param {Array} [partialArgs] An array of arguments to prepend to those - * provided to the new function. - * @param {Array} [partialRightArgs] An array of arguments to append to those - * provided to the new function. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {number} [arity] The arity of `func`. + * @param {Array} bindData The bind data array. * @returns {Function} Returns the new function. */ - function baseCreateWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) { + function baseCreateWrapper(bindData) { + var func = bindData[0], + bitmask = bindData[1], + partialArgs = bindData[2], + partialRightArgs = bindData[3], + thisArg = bindData[4], + arity = bindData[5]; + var isBind = bitmask & 1, isBindKey = bitmask & 2, isCurry = bitmask & 4, isCurryBound = bitmask & 8, - isPartial = bitmask & 16, - isPartialRight = bitmask & 32, key = func; function bound() { var thisBinding = isBind ? thisArg : this; - if (isCurry || isPartial || isPartialRight) { - if (isPartial) { + if (isCurry || partialArgs || partialRightArgs) { + if (partialArgs) { var args = partialArgs.slice(); push.apply(args, arguments); } - if (isPartialRight || isCurry) { + if (partialRightArgs || isCurry) { args || (args = slice(arguments)); - if (isPartialRight) { + if (partialRightArgs) { push.apply(args, partialRightArgs); } if (isCurry && args.length < arity) { bitmask |= 16 & ~32; - return createWrapper(func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity); + return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]); } } } @@ -804,11 +804,8 @@ isPartialRight = partialRightArgs = false; } // fast path for `_.bind` - var result = (bitmask == 1 || bitmask === 17) - ? baseBind(func, thisArg, partialArgs) - : baseCreateWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity); - - return result; + var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper; + return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]); } /** diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 4e4669411..021a3233a 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -4,11 +4,11 @@ * 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(tt?0:t);++eu(f,l))&&(t&&f.push(l),i.push(a))}return i}function h(n){return function(r,t,e){var u={};t=X(t,e,3),e=-1;var o=r?r.length:0;if(typeof o=="number")for(;++eu(f,l))&&(t&&f.push(l),i.push(a))}return i}function h(n){return function(r,t,e){var u={};t=X(t,e,3),e=-1;var o=r?r.length:0;if(typeof o=="number")for(;++e