From e3b4b2f667fb6d2ecf2c34db67a733d3836aa235 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 14 Dec 2013 00:29:40 -0800 Subject: [PATCH] Simplify `iteratorTemplate`. --- dist/lodash.compat.js | 211 ++++++++++----------------- dist/lodash.compat.min.js | 113 ++++++++------- dist/lodash.js | 28 ++-- dist/lodash.min.js | 68 ++++----- dist/lodash.underscore.js | 44 +++--- dist/lodash.underscore.min.js | 36 ++--- lodash.js | 260 +++++++++++++--------------------- 7 files changed, 314 insertions(+), 446 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 81567ec89..13ed2f0d7 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -126,21 +126,6 @@ 'writable': false }; - /** Used as the data object for `iteratorTemplate` */ - var iteratorData = { - 'args': '', - 'array': null, - 'bottom': '', - 'firstArg': '', - 'init': '', - 'keys': null, - 'loop': '', - 'shadowedProps': null, - 'support': null, - 'top': '', - 'useHas': false - }; - /** Used to determine if values are of the language type Object */ var objectTypes = { 'boolean': false, @@ -892,91 +877,58 @@ */ var iteratorTemplate = function(obj) { - var __p = 'var index, iterable = ' + - (obj.firstArg) + - ', result = ' + + var __p = 'var result = ' + (obj.init) + - ';\nif (!iterable) return result;\n' + + ';\nif (!(object && objectTypes[typeof object])) return result;\n' + (obj.top) + ';'; - if (obj.array) { - __p += '\nvar length = iterable.length; index = -1;\nif (' + - (obj.array) + - ') { '; - if (support.unindexedChars) { - __p += '\n if (isString(iterable)) {\n iterable = iterable.split(\'\')\n } '; - } - __p += '\n while (++index < length) {\n ' + + if (support.nonEnumArgs) { + __p += '\nvar length = object.length;\nif (length && isArguments(object)) {\n key = -1;\n while (++key < length) {\n key += \'\';\n ' + (obj.loop) + - ';\n }\n}\nelse { '; - } else if (support.nonEnumArgs) { - __p += '\n var length = iterable.length; index = -1;\n if (length && isArguments(iterable)) {\n while (++index < length) {\n index += \'\';\n ' + - (obj.loop) + - ';\n }\n } else { '; + ';\n }\n return result\n}'; } if (support.enumPrototypes) { - __p += '\n var skipProto = typeof iterable == \'function\';\n '; + __p += '\nvar skipProto = typeof object == \'function\';\n'; } if (support.enumErrorProps) { - __p += '\n var skipErrorProps = iterable === errorProto || iterable instanceof Error;\n '; + __p += '\nvar skipErrorProps = object === errorProto || object instanceof Error;\n'; } - var conditions = []; if (support.enumPrototypes) { conditions.push('!(skipProto && index == "prototype")'); } if (support.enumErrorProps) { conditions.push('!(skipErrorProps && (index == "message" || index == "name"))'); } - - if (obj.useHas && obj.keys) { - __p += '\n var ownIndex = -1,\n ownProps = keys(iterable),\n length = ownProps.length;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n'; - if (conditions.length) { + var conditions = []; + if (support.enumPrototypes) { conditions.push('!(skipProto && key == \'prototype\')'); } + if (support.enumErrorProps) { conditions.push('!(skipErrorProps && (key == \'message\' || key == \'name\'))'); } + __p += '\nfor (var key in object) {\n'; + if (obj.useHas) { conditions.push('hasOwnProperty.call(object, key)'); } + if (conditions.length) { __p += ' if (' + (conditions.join(' && ')) + ') {\n '; } __p += (obj.loop) + - '; '; + '; '; if (conditions.length) { __p += '\n }'; } - __p += '\n } '; - } else { - __p += '\n for (index in iterable) {\n'; - if (obj.useHas) { conditions.push("hasOwnProperty.call(iterable, index)"); } if (conditions.length) { - __p += ' if (' + - (conditions.join(' && ')) + - ') {\n '; - } - __p += - (obj.loop) + - '; '; - if (conditions.length) { - __p += '\n }'; - } - __p += '\n } '; + __p += '\n}\n'; if (support.nonEnumShadows) { - __p += '\n\n if (iterable !== objectProto) {\n var ctor = iterable.constructor,\n isProto = iterable === (ctor && ctor.prototype),\n className = iterable === stringProto ? stringClass : iterable === errorProto ? errorClass : toString.call(iterable),\n nonEnum = nonEnumProps[className];\n '; - for (k = 0; k < 7; k++) { - __p += '\n index = \'' + - (obj.shadowedProps[k]) + - '\';\n if ((!(isProto && nonEnum[index]) && hasOwnProperty.call(iterable, index))'; - if (!obj.useHas) { - __p += ' || (!nonEnum[index] && iterable[index] !== objectProto[index])'; + __p += '\nif (object !== objectProto) {\n var ctor = object.constructor,\n isProto = object === (ctor && ctor.prototype),\n className = object === stringProto ? stringClass : object === errorProto ? errorClass : toString.call(object),\n nonEnum = nonEnumProps[className];\n '; + for (var index = 0; index < 7; index++) { + __p += '\n key = \'' + + (obj.shadowedProps[index]) + + '\';\n if ((!(isProto && nonEnum[key]) && hasOwnProperty.call(object, key))'; + if (!obj.useHas) { + __p += ' || (!nonEnum[key] && object[key] !== objectProto[key])'; } - __p += ') {\n ' + + __p += ') {\n ' + (obj.loop) + - ';\n } '; + ';\n } '; } - __p += '\n } '; - } - - } - - if (obj.array || support.nonEnumArgs) { __p += '\n}'; } - __p += - (obj.bottom) + - ';\nreturn result'; + __p += '\nreturn result'; return __p }; @@ -1285,6 +1237,40 @@ return result; } + /** + * Iterates `arguments` objects, arrays, objects, and strings consistently + * across environments, executing the callback for each element in the + * collection. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index|key, collection). Callbacks may exit iteration + * early by explicitly returning `false`. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|string} Returns `collection`. + */ + function baseEach(collection, callback, thisArg) { + var index = -1, + iterable = collection, + length = collection ? collection.length : 0; + + callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); + if (typeof length == 'number') { + if (support.unindexedChars && isString(iterable)) { + iterable = iterable.split(''); + } + while (++index < length) { + if (callback(iterable[index], index, collection) === false) { + break; + } + } + } else { + forOwn(collection, callback); + } + return collection; + } + /** * The base implementation of `_.flatten` without support for callback * shorthands or `thisArg` binding. @@ -1741,47 +1727,27 @@ * Creates compiled iteration functions. * * @private - * @param {...Object} [options] The compile options object(s). - * @param {string} [options.array] Code to determine if the iterable is an array or array-like. - * @param {boolean} [options.useHas] Specify using `hasOwnProperty` checks in the object loop. - * @param {Function} [options.keys] A reference to `_.keys` for use in own property iteration. + * @param {Object} [options] The compile options object. * @param {string} [options.args] A comma separated string of iteration function arguments. * @param {string} [options.top] Code to execute before the iteration branches. * @param {string} [options.loop] Code to execute in the object loop. - * @param {string} [options.bottom] Code to execute after the iteration branches. + * @param {boolean} [options.useHas] Specify using `hasOwnProperty` checks in the object loop. * @returns {Function} Returns the compiled function. */ - function createIterator() { - // data properties - iteratorData.shadowedProps = shadowedProps; - - // iterator options - iteratorData.array = iteratorData.bottom = iteratorData.loop = iteratorData.top = ''; - iteratorData.init = 'iterable'; - iteratorData.useHas = true; - - // merge options into a template data object - for (var object, index = 0; object = arguments[index]; index++) { - for (var key in object) { - iteratorData[key] = object[key]; - } - } - var args = iteratorData.args; - iteratorData.firstArg = /^[^,]+/.exec(args)[0]; + function createIterator(options) { + options.shadowedProps = shadowedProps; // create the function factory var factory = Function( - 'baseCreateCallback, errorClass, errorProto, hasOwnProperty, ' + - 'indicatorObject, isArguments, isArray, isString, keys, objectProto, ' + - 'objectTypes, nonEnumProps, stringClass, stringProto, toString', - 'return function(' + args + ') {\n' + iteratorTemplate(iteratorData) + '\n}' + 'baseCreateCallback, errorClass, errorProto, hasOwnProperty, isArguments, ' + + 'objectProto, objectTypes, nonEnumProps, stringClass, stringProto, toString', + 'return function(' + options.args + ') {\n' + iteratorTemplate(options) + '\n}' ); // return the compiled function return factory( - baseCreateCallback, errorClass, errorProto, hasOwnProperty, - indicatorObject, isArguments, isArray, isString, iteratorData.keys, objectProto, - objectTypes, nonEnumProps, stringClass, stringProto, toString + baseCreateCallback, errorClass, errorProto, hasOwnProperty, isArguments, + objectProto, objectTypes, nonEnumProps, stringClass, stringProto, toString ); } @@ -1948,7 +1914,8 @@ 'args': 'object', 'init': '[]', 'top': 'if (!(objectTypes[typeof object])) return result', - 'loop': 'result.push(index)' + 'loop': 'result.push(key)', + 'useHas': true }); /** @@ -1975,15 +1942,6 @@ return nativeKeys(object); }; - /** Reusable iterator options shared by `each`, `forIn`, and `forOwn` */ - var eachIteratorOptions = { - 'args': 'collection, callback, thisArg', - 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)", - 'array': "typeof length == 'number'", - 'keys': keys, - 'loop': 'if (callback(iterable[index], index, collection) === false) return result' - }; - /** * Used to convert characters to HTML entities: * @@ -2007,22 +1965,6 @@ var reEscapedHtml = RegExp('(' + keys(htmlUnescapes).join('|') + ')', 'g'), reUnescapedHtml = RegExp('[' + keys(htmlEscapes).join('') + ']', 'g'); - /** - * A function compiled to iterate `arguments` objects, arrays, objects, and - * strings consistenly across environments, executing the callback for each - * element in the collection. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index|key, collection). Callbacks may exit - * iteration early by explicitly returning `false`. - * - * @private - * @type Function - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array|Object|string} Returns `collection`. - */ - var baseEach = createIterator(eachIteratorOptions); - /*--------------------------------------------------------------------------*/ /** @@ -2034,7 +1976,6 @@ * * @static * @memberOf _ - * @type Function * @alias extend * @category Objects * @param {Object} object The destination object. @@ -2220,7 +2161,6 @@ * * @static * @memberOf _ - * @type Function * @category Objects * @param {Object} object The destination object. * @param {...Object} [source] The source objects. @@ -2393,9 +2333,11 @@ * }); * // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments) */ - var forIn = createIterator(eachIteratorOptions, { - 'top': 'if (!objectTypes[typeof iterable]) return result;\n' + eachIteratorOptions.top, - 'array': false, + var forIn = createIterator({ + 'args': 'object, callback, thisArg', + 'init': 'object', + 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)", + 'loop': 'if (callback(object[key], key, object) === false) return result', 'useHas': false }); @@ -2452,7 +2394,6 @@ * * @static * @memberOf _ - * @type Function * @category Objects * @param {Object} object The object to iterate over. * @param {Function} [callback=identity] The function called per iteration. @@ -3751,7 +3692,7 @@ } else if (support.unindexedChars && isString(collection)) { iterable = collection.split(''); } - baseEach(collection, function(value, key, collection) { + baseEach(iterable, function(value, key) { key = props ? props[--length] : --length; return callback(iterable[key], key, collection); }); diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index a44cde291..25bfce2c8 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -3,60 +3,59 @@ * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE * Build: `lodash -o ./dist/lodash.compat.js` */ -;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++ei||typeof a=="undefined")return 1;if(ae?0:e);++r=_&&a===n,l=[];if(f){var c=o(r);c?(a=t,r=c):f=false}for(;++ua(r,c)&&l.push(c);return f&&p(r),l}function ot(n,t,e,r){r=(r||0)-1; -for(var u=n?n.length:0,o=[];++r=_&&f===n,h=u||g?i():s;for(g&&(h=o(h),f=t);++af(h,y))&&((u||g)&&h.push(y),s.push(v))}return g?(c(h.k),p(h)):u&&c(h),s}function ct(n){return function(t,e,r){var u={}; -if(e=v.createCallback(e,r,3),Ve(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||Je.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+"}")(tt,W,he,Oe,d,dt,Ve,At,Q.f,ve,X,Ge,M,ye,_e)}function gt(n){return Xe[n]}function ht(){var t=(t=v.indexOf)===Gt?n:t;return t}function vt(n){return typeof n=="function"&&we.test(ke.call(n))}function yt(n){var t,e;return!n||_e.call(n)!=G||(t=n.constructor,Et(t)&&!(t instanceof t))||!Je.argsClass&&dt(n)||!Je.nodeClass&&l(n)?false:Je.ownLast?(er(n,function(n,t,r){return e=Oe.call(r,t),false}),false!==e):(er(n,function(n,t){e=t -}),typeof e=="undefined"||Oe.call(n,e))}function mt(n){return Ye[n]}function dt(n){return n&&typeof n=="object"&&typeof n.length=="number"&&_e.call(n)==F||false}function bt(n,t,e){var r=arguments,u=0,o=typeof e=="number"?2:r.length;if(3e?Le(0,o+e):e)||0,Ve(n)?a=-1o&&(o=i)}}else t=null==t&&At(n)?r:v.createCallback(t,e,3),tr(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n) -});return o}function Lt(n,t,e,r){var u=3>arguments.length;if(t=v.createCallback(t,r,4),Ve(n)){var o=-1,a=n.length;for(u&&(e=n[++o]);++oarguments.length;return t=v.createCallback(t,r,4),Bt(n,function(n,r,o){e=u?(u=false,n):t(e,n,r,o)}),e}function Wt(n){var t=-1,e=n?n.length:0,r=re(typeof e=="number"?e:0);return Tt(n,function(n){var e=ft(0,++t);r[t]=r[e],r[e]=n}),r}function qt(n,t,e){var r;if(t=v.createCallback(t,e,3),Ve(n)){e=-1; -for(var u=n.length;++er?Le(0,u+r):r||0}else if(r)return r=Mt(t,e),t[r]===e?r:-1;return n(t,e,r)}function Jt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0; -for(t=v.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t=h;m?(u&&(u=xe(u)),c=a,o=n.apply(i,r)):u||(u=Ie(y,h))}return m&&f?f=xe(f):f||t===p||(f=Ie(v,t)),e&&(m=true,o=n.apply(i,r)),!m||f||u||(r=i=null),o}}function Yt(n){return n}function Zt(n,t,e){var r=true,u=t&&xt(t);t&&(e||u.length)||(null==e&&(e=t),o=y,t=n,n=v,u=xt(t)),false===e?r=false:Ot(e)&&"chain"in e&&(r=e.chain); -var o=n,a=Et(o);Tt(u,function(e){var u=n[e]=t[e];a&&(o.prototype[e]=function(){var t=this.__chain__,e=this.__wrapped__,a=[e];if(Se.apply(a,arguments),a=u.apply(n,a),r||t){if(e===a&&Ot(a))return this;a=new o(a),a.__chain__=t}return a})})}function ne(){}function te(n){return function(t){return t[n]}}function ee(){return this.__wrapped__}e=e?ut.defaults(Z.Object(),e,ut.pick(Z,T)):Z;var re=e.Array,ue=e.Boolean,oe=e.Date,ae=e.Function,ie=e.Math,fe=e.Number,le=e.Object,ce=e.RegExp,pe=e.String,se=e.TypeError,ge=[],he=e.Error.prototype,ve=le.prototype,ye=pe.prototype,me=e.window,de=me&&me.document,be=e._,_e=ve.toString,we=ce("^"+pe(_e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),je=ie.ceil,xe=e.clearTimeout,Ce=ie.floor,ke=ae.prototype.toString,Ee=vt(Ee=le.getPrototypeOf)&&Ee,Oe=ve.hasOwnProperty,Se=ge.push,Ae=ve.propertyIsEnumerable,Ie=e.setTimeout,Ne=ge.splice,De=ge.unshift,Re=function(){try{var n={},t=vt(t=le.defineProperty)&&t,e=t(n,n,n)&&t -}catch(r){}return e}(),Pe=vt(Pe=le.create)&&Pe,Te=vt(Te=re.isArray)&&Te,Be=e.isFinite,Fe=e.isNaN,$e=vt($e=le.keys)&&$e,Le=ie.max,ze=ie.min,We=e.parseInt,qe=ie.random,Ke={};Ke[$]=re,Ke[L]=ue,Ke[z]=oe,Ke[q]=ae,Ke[G]=le,Ke[K]=fe,Ke[J]=ce,Ke[M]=pe;var Ge={};Ge[$]=Ge[z]=Ge[K]={constructor:true,toLocaleString:true,toString:true,valueOf:true},Ge[L]=Ge[M]={constructor:true,toString:true,valueOf:true},Ge[W]=Ge[q]=Ge[J]={constructor:true,toString:true},Ge[G]={constructor:true},function(){for(var n=B.length;n--;){var t,e=B[n]; -for(t in Ge)Oe.call(Ge,t)&&!Oe.call(Ge[t],e)&&(Ge[t][e]=false)}}(),y.prototype=v.prototype;var Je=v.support={};!function(){var n=function(){this.x=1},t={0:1,length:1},r=[];n.prototype={valueOf:1,y:1};for(var u in new n)r.push(u);for(u in arguments);Je.argsClass=_e.call(arguments)==F,Je.argsObject=arguments.constructor==le&&!(arguments instanceof re),Je.dom=!!de&&typeof de=="object"&&we.test(xe)&&we.test(Ie),Je.enumErrorProps=Ae.call(he,"message")||Ae.call(he,"name"),Je.enumPrototypes=Ae.call(n,"prototype"),Je.funcDecomp=!vt(e.WinRTError)&&R.test(g),Je.funcNames=typeof ae.name=="string",Je.nonEnumArgs=0!=u,Je.nonEnumShadows=!/valueOf/.test(r),Je.ownLast="x"!=r[0],Je.spliceObjects=(ge.splice.call(t,0,1),!t[0]),Je.unindexedChars="xx"!="x"[0]+le("x")[0]; -try{Je.nodeClass=!(_e.call(de)==G&&!({toString:0}+""))}catch(o){Je.nodeClass=true}}(1),v.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:I,variable:"",imports:{_:v}},Pe||(nt=function(){function n(){}return function(t){if(Ot(t)){n.prototype=t;var r=new n;n.prototype=null}return r||e.Object()}}());var Me=Re?function(n,t){H.value=t,Re(n,"__bindData__",H)}:ne;Je.argsClass||(dt=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Oe.call(n,"callee")&&!Ae.call(n,"callee")||false});var Ve=Te||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&_e.call(n)==$||false -},Ue=st({a:"z",e:"[]",i:"if(!(B[typeof z]))return E",g:"E.push(n)"}),He=$e?function(n){return Ot(n)?Je.enumPrototypes&&typeof n=="function"||Je.nonEnumArgs&&n.length&&dt(n)?Ue(n):$e(n):[]}:Ue,Qe={a:"g,e,K",i:"e=e&&typeof K=='undefined'?e:d(e,K,3)",b:"typeof u=='number'",v:He,g:"if(e(t[n],n,g)===false)return E"},Xe={"&":"&","<":"<",">":">",'"':""","'":"'"},Ye=Ct(Xe),Ze=ce("("+He(Ye).join("|")+")","g"),nr=ce("["+He(Xe).join("")+"]","g"),tr=st(Qe),er=st(Qe,{i:"if(!B[typeof t])return E;"+Qe.i,b:false,j:false}); -Je.dom||(kt=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!rr(n)||false}),Et(/x/)&&(Et=function(n){return typeof n=="function"&&_e.call(n)==q});var rr=Ee?function(n){if(!n||_e.call(n)!=G||!Je.argsClass&&dt(n))return false;var t=n.valueOf,e=vt(t)&&(e=Ee(t))&&Ee(e);return e?n==e||Ee(n)==e:yt(n)}:yt,ur=ct(function(n,t,e){Oe.call(n,e)?n[e]++:n[e]=1}),or=ct(function(n,t,e){(Oe.call(n,e)?n[e]:n[e]=[]).push(t)}),ar=ct(function(n,t,e){n[e]=t}),ir=Ft,fr=vt(fr=oe.now)&&fr||function(){return(new oe).getTime() -},lr=8==We(j+"08")?We:function(n,t){return We(At(n)?n.replace(N,""):n,t||0)};return v.after=function(n,t){if(!Et(t))throw new se;return function(){return 1>--n?t.apply(this,arguments):void 0}},v.assign=bt,v.at=function(n){var t=arguments,e=-1,r=ot(t,true,false,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=re(t);for(Je.unindexedChars&&At(n)&&(n=n.split(""));++e=_&&o(r?e[r]:s))) -}var l=e[0],h=-1,v=l?l.length:0,y=[];n:for(;++h(m?t(m,g):f(s,g))){for(r=u,(m||s).push(g);--r;)if(m=a[r],0>(m?t(m,g):f(e[r],g)))continue n;y.push(g)}}for(;u--;)(m=a[u])&&p(m);return c(a),c(s),y},v.invert=Ct,v.invoke=function(n,t){var e=s(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,a=re(typeof o=="number"?o:0);return Tt(n,function(n){a[++r]=(u?t:n[t]).apply(n,e)}),a},v.keys=He,v.map=Ft,v.mapValues=function(n,t,e){var r={};return t=v.createCallback(t,e,3),wt(n,function(n,e,u){r[e]=t(n,e,u) -}),r},v.max=$t,v.memoize=function(n,t){if(!Et(n))throw new se;var e=function(){var r=e.cache,u=t?t.apply(this,arguments):b+arguments[0];return Oe.call(r,u)?r[u]:r[u]=n.apply(this,arguments)};return e.cache={},e},v.merge=function(n){var t=arguments,e=2;if(!Ot(n))return n;if("number"!=typeof t[2]&&(e=t.length),3e?Le(0,r+e):ze(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},v.mixin=Zt,v.noConflict=function(){return e._=be,this},v.noop=ne,v.now=fr,v.parseInt=lr,v.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=true)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,e||n%1||t%1?(e=qe(),ze(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):ft(n,t) -},v.reduce=Lt,v.reduceRight=zt,v.result=function(n,t){if(n){var e=n[t];return Et(e)?n[t]():e}},v.runInContext=g,v.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:He(n).length},v.some=qt,v.sortedIndex=Mt,v.template=function(n,t,e){var r=v.templateSettings;n=pe(n||""),e=_t({},e,r);var u,o=_t({},e.imports,r.imports),r=He(o),o=It(o),i=0,f=e.interpolate||D,l="__p+='",f=ce((e.escape||D).source+"|"+f.source+"|"+(f===I?O:D).source+"|"+(e.evaluate||D).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(i,c).replace(P,a),e&&(l+="'+__e("+e+")+'"),f&&(u=true,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(x,""):l).replace(C,"$1").replace(E,"$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=ae(r,"return "+l).apply(h,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},v.unescape=function(n){return null==n?"":(n=pe(n),0>n.indexOf(";")?n:n.replace(Ze,mt))},v.uniqueId=function(n){var t=++m; -return pe(null==n?"":n)+t},v.all=Dt,v.any=qt,v.detect=Pt,v.findWhere=Pt,v.foldl=Lt,v.foldr=zt,v.include=Nt,v.inject=Lt,Zt(function(){var n={};return wt(v,function(t,e){v.prototype[e]||(n[e]=t)}),n}(),false),v.first=Kt,v.last=function(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=u;for(t=v.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,Le(0,u-r))},v.sample=function(n,t,e){return n&&typeof n.length!="number"?n=It(n):Je.unindexedChars&&At(n)&&(n=n.split("")),null==t||e?n?n[ft(0,n.length-1)]:h:(n=Wt(n),n.length=ze(Le(0,t),n.length),n) -},v.take=Kt,v.head=Kt,wt(v,function(n,t){var e="sample"!==t;v.prototype[t]||(v.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})}),v.VERSION="2.4.1",v.prototype.chain=function(){return this.__chain__=true,this},v.prototype.toString=function(){return pe(this.__wrapped__)},v.prototype.value=ee,v.prototype.valueOf=ee,tr(["join","pop","shift"],function(n){var t=ge[n];v.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments); -return n?new y(e,n):e}}),tr(["push","reverse","sort","unshift"],function(n){var t=ge[n];v.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),tr(["concat","slice","splice"],function(n){var t=ge[n];v.prototype[n]=function(){return new y(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Je.spliceObjects||tr(["pop","shift","splice"],function(n){var t=ge[n],e="splice"==n;v.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 y(u,n):u -}}),v}var h,v=[],y=[],m=0,d={},b=+new Date+"",_=75,w=40,j=" \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",x=/\b__p\+='';/g,C=/\b(__p\+=)''\+/g,E=/(__e\(.*?\)|\b__t\))\+'';/g,O=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,S=/\w*$/,A=/^\s*function[ \n\r\t]+\w/,I=/<%=([\s\S]+?)%>/g,N=RegExp("^["+j+"]*0+(?=.$)"),D=/($^)/,R=/\bthis\b/,P=/['\n\r\t\u2028\u2029\\]/g,T="Array Boolean Date Error Function Math Number Object RegExp String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),B="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),F="[object Arguments]",$="[object Array]",L="[object Boolean]",z="[object Date]",W="[object Error]",q="[object Function]",K="[object Number]",G="[object Object]",J="[object RegExp]",M="[object String]",V={}; -V[q]=false,V[F]=V[$]=V[L]=V[z]=V[K]=V[G]=V[J]=V[M]=true;var U={leading:false,maxWait:0,trailing:false},H={configurable:false,enumerable:false,value:null,writable:false},Q={a:"",b:null,c:"",d:"",e:"",v:null,g:"",h:null,support:null,i:"",j:false},X={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},Y={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Z=X[typeof window]&&window||this,nt=X[typeof exports]&&exports&&!exports.nodeType&&exports,tt=X[typeof module]&&module&&!module.nodeType&&module,et=tt&&tt.exports===nt&&nt,rt=X[typeof global]&&global; -!rt||rt.global!==rt&&rt.window!==rt||(Z=rt);var ut=g();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Z._=ut, define(function(){return ut})):nt&&tt?et?(tt.exports=ut)._=ut:nt._=ut:Z._=ut}).call(this); \ No newline at end of file +;(function(){function n(n,t,r){r=(r||0)-1;for(var e=n?n.length:0;++ri||typeof a=="undefined")return 1;if(ar?0:r);++e=b&&a===n,l=[];if(f){var c=o(e);c?(a=t,e=c):f=false}for(;++ua(e,c)&&l.push(c);return f&&p(e),l}function rt(n,t,r){var e=-1,u=n,o=n?n.length:0; +if(t=t&&typeof r=="undefined"?t:Y(t,r,3),typeof o=="number")for(Kr.unindexedChars&&Et(u)&&(u=u.split(""));++e=b&&f===n,h=u||g?i():s;for(g&&(h=o(h),f=t);++af(h,y))&&((u||g)&&h.push(y),s.push(v)) +}return g?(c(h.g),p(h)):u&&c(h),s}function ft(n){return function(t,r,e){var u={};if(r=v.createCallback(r,e,3),Vr(t)){e=-1;for(var o=t.length;++eu;u++)e+="l='"+n.d[u]+"';if((!(k&&n[l])&&h.call(p,l))",n.f||(e+="||(!n[l]&&p[l]!==q[l])"),e+="){"+n.c+"}"; +e+="}"}return t("a,f,g,h,j,q,r,o,v,w,y",r+(e+"return s")+"}")(Y,B,sr,kr,yt,gr,H,zr,M,hr,dr)}function pt(n){return Hr[n]}function st(){var t=(t=v.indexOf)===zt?n:t;return t}function gt(n){return typeof n=="function"&&br.test(xr.call(n))}function ht(n){var t,r;return!n||dr.call(n)!=z||(t=n.constructor,Ct(t)&&!(t instanceof t))||!Kr.argsClass&&yt(n)||!Kr.nodeClass&&l(n)?false:Kr.ownLast?(Yr(n,function(n,t,e){return r=kr.call(e,t),false}),false!==r):(Yr(n,function(n,t){r=t}),typeof r=="undefined"||kr.call(n,r)) +}function vt(n){return Jr[n]}function yt(n){return n&&typeof n=="object"&&typeof n.length=="number"&&dr.call(n)==D||false}function mt(n,t,r){var e=arguments,u=0,o=typeof r=="number"?2:e.length;if(3r?Fr(0,o+r):r)||0,Vr(n)?a=-1o&&(o=i)}}else t=null==t&&Et(n)?e:v.createCallback(t,r,3),rt(n,function(n,r,e){r=t(n,r,e),r>u&&(u=r,o=n) +});return o}function Ft(n,t,r,e){var u=3>arguments.length;if(t=v.createCallback(t,e,4),Vr(n)){var o=-1,a=n.length;for(u&&(r=n[++o]);++oarguments.length;return t=v.createCallback(t,e,4),Tt(n,function(n,e,o){r=u?(u=false,n):t(r,n,e,o)}),r}function Bt(n){var t=-1,r=n?n.length:0,e=tr(typeof r=="number"?r:0);return Pt(n,function(n){var r=at(0,++t);e[t]=e[r],e[r]=n}),e}function Lt(n,t,r){var e;if(t=v.createCallback(t,r,3),Vr(n)){r=-1; +for(var u=n.length;++re?Fr(0,u+e):e||0}else if(e)return e=Mt(t,r),t[e]===r?e:-1;return n(t,r,e)}function Kt(n,t,r){if(typeof t!="number"&&null!=t){var e=0,u=-1,o=n?n.length:0; +for(t=v.createCallback(t,r,3);++u>>1,r(n[e])r?0:r);++t=h;m?(u&&(u=wr(u)),c=a,o=n.apply(i,e)):u||(u=Sr(y,h))}return m&&f?f=wr(f):f||t===p||(f=Sr(v,t)),r&&(m=true,o=n.apply(i,e)),!m||f||u||(e=i=null),o}}function Qt(n){return n}function Xt(n,t,r){var e=true,u=t&&wt(t);t&&(r||u.length)||(null==r&&(r=t),o=y,t=n,n=v,u=wt(t)),false===r?e=false:kt(r)&&"chain"in r&&(e=r.chain); +var o=n,a=Ct(o);Pt(u,function(r){var u=n[r]=t[r];a&&(o.prototype[r]=function(){var t=this.__chain__,r=this.__wrapped__,a=[r];if(Or.apply(a,arguments),a=u.apply(n,a),e||t){if(r===a&&kt(a))return this;a=new o(a),a.__chain__=t}return a})})}function Yt(){}function Zt(n){return function(t){return t[n]}}function nr(){return this.__wrapped__}r=r?tt.defaults(Q.Object(),r,tt.pick(Q,P)):Q;var tr=r.Array,rr=r.Boolean,er=r.Date,ur=r.Function,or=r.Math,ar=r.Number,ir=r.Object,fr=r.RegExp,lr=r.String,cr=r.TypeError,pr=[],sr=r.Error.prototype,gr=ir.prototype,hr=lr.prototype,vr=r.window,yr=vr&&vr.document,mr=r._,dr=gr.toString,br=fr("^"+lr(dr).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),_r=or.ceil,wr=r.clearTimeout,jr=or.floor,xr=ur.prototype.toString,Cr=gt(Cr=ir.getPrototypeOf)&&Cr,kr=gr.hasOwnProperty,Or=pr.push,Er=gr.propertyIsEnumerable,Sr=r.setTimeout,Ir=pr.splice,Ar=pr.unshift,Nr=function(){try{var n={},t=gt(t=ir.defineProperty)&&t,r=t(n,n,n)&&t +}catch(e){}return r}(),Rr=gt(Rr=ir.create)&&Rr,Pr=gt(Pr=tr.isArray)&&Pr,Tr=r.isFinite,Dr=r.isNaN,$r=gt($r=ir.keys)&&$r,Fr=or.max,qr=or.min,Br=r.parseInt,Lr=or.random,Wr={};Wr[$]=tr,Wr[F]=rr,Wr[q]=er,Wr[L]=ur,Wr[z]=ir,Wr[W]=ar,Wr[K]=fr,Wr[M]=lr;var zr={};zr[$]=zr[q]=zr[W]={constructor:true,toLocaleString:true,toString:true,valueOf:true},zr[F]=zr[M]={constructor:true,toString:true,valueOf:true},zr[B]=zr[L]=zr[K]={constructor:true,toString:true},zr[z]={constructor:true},function(){for(var n=T.length;n--;){var t,r=T[n]; +for(t in zr)kr.call(zr,t)&&!kr.call(zr[t],r)&&(zr[t][r]=false)}}(),y.prototype=v.prototype;var Kr=v.support={};!function(){var n=function(){this.x=1},t={0:1,length:1},e=[];n.prototype={valueOf:1,y:1};for(var u in new n)e.push(u);for(u in arguments);Kr.argsClass=dr.call(arguments)==D,Kr.argsObject=arguments.constructor==ir&&!(arguments instanceof tr),Kr.dom=!!yr&&typeof yr=="object"&&br.test(wr)&&br.test(Sr),Kr.enumErrorProps=Er.call(sr,"message")||Er.call(sr,"name"),Kr.enumPrototypes=Er.call(n,"prototype"),Kr.funcDecomp=!gt(r.WinRTError)&&N.test(g),Kr.funcNames=typeof ur.name=="string",Kr.nonEnumArgs=0!=u,Kr.nonEnumShadows=!/valueOf/.test(e),Kr.ownLast="x"!=e[0],Kr.spliceObjects=(pr.splice.call(t,0,1),!t[0]),Kr.unindexedChars="xx"!="x"[0]+ir("x")[0]; +try{Kr.nodeClass=!(dr.call(yr)==z&&!({toString:0}+""))}catch(o){Kr.nodeClass=true}}(1),v.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:S,variable:"",imports:{_:v}},Rr||(X=function(){function n(){}return function(t){if(kt(t)){n.prototype=t;var e=new n;n.prototype=null}return e||r.Object()}}());var Mr=Nr?function(n,t){G.value=t,Nr(n,"__bindData__",G)}:Yt;Kr.argsClass||(yt=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&kr.call(n,"callee")&&!Er.call(n,"callee")||false});var Vr=Pr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&dr.call(n)==$||false +},Ur=ct({a:"p",b:"[]",e:"if(!(r[typeof p]))return s",c:"s.push(l)",f:true}),Gr=$r?function(n){return kt(n)?Kr.enumPrototypes&&typeof n=="function"||Kr.nonEnumArgs&&n.length&&yt(n)?Ur(n):$r(n):[]}:Ur,Hr={"&":"&","<":"<",">":">",'"':""","'":"'"},Jr=jt(Hr),Qr=fr("("+Gr(Jr).join("|")+")","g"),Xr=fr("["+Gr(Hr).join("")+"]","g"),Yr=ct({a:"p,b,x",b:"p",e:"b=b&&typeof x=='undefined'?b:a(b,x,3)",c:"if(b(p[l],l,p)===false)return s",f:false});Kr.dom||(xt=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!Zr(n)||false +}),Ct(/x/)&&(Ct=function(n){return typeof n=="function"&&dr.call(n)==L});var Zr=Cr?function(n){if(!n||dr.call(n)!=z||!Kr.argsClass&&yt(n))return false;var t=n.valueOf,r=gt(t)&&(r=Cr(t))&&Cr(r);return r?n==r||Cr(n)==r:ht(n)}:ht,ne=ft(function(n,t,r){kr.call(n,r)?n[r]++:n[r]=1}),te=ft(function(n,t,r){(kr.call(n,r)?n[r]:n[r]=[]).push(t)}),re=ft(function(n,t,r){n[r]=t}),ee=Dt,ue=gt(ue=er.now)&&ue||function(){return(new er).getTime()},oe=8==Br(w+"08")?Br:function(n,t){return Br(Et(n)?n.replace(I,""):n,t||0) +};return v.after=function(n,t){if(!Ct(t))throw new cr;return function(){return 1>--n?t.apply(this,arguments):void 0}},v.assign=mt,v.at=function(n){var t=arguments,r=-1,e=et(t,true,false,1),t=t[2]&&t[2][t[1]]===n?1:e.length,u=tr(t);for(Kr.unindexedChars&&Et(n)&&(n=n.split(""));++r=b&&o(e?r[e]:s)))}var l=r[0],h=-1,v=l?l.length:0,y=[];n:for(;++h(m?t(m,g):f(s,g))){for(e=u,(m||s).push(g);--e;)if(m=a[e],0>(m?t(m,g):f(r[e],g)))continue n;y.push(g) +}}for(;u--;)(m=a[u])&&p(m);return c(a),c(s),y},v.invert=jt,v.invoke=function(n,t){var r=s(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,a=tr(typeof o=="number"?o:0);return Pt(n,function(n){a[++e]=(u?t:n[t]).apply(n,r)}),a},v.keys=Gr,v.map=Dt,v.mapValues=function(n,t,r){var e={};return t=v.createCallback(t,r,3),bt(n,function(n,r,u){e[r]=t(n,r,u)}),e},v.max=$t,v.memoize=function(n,t){if(!Ct(n))throw new cr;var r=function(){var e=r.cache,u=t?t.apply(this,arguments):d+arguments[0];return kr.call(e,u)?e[u]:e[u]=n.apply(this,arguments) +};return r.cache={},r},v.merge=function(n){var t=arguments,r=2;if(!kt(n))return n;if("number"!=typeof t[2]&&(r=t.length),3r?Fr(0,e+r):qr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},v.mixin=Xt,v.noConflict=function(){return r._=mr,this},v.noop=Yt,v.now=ue,v.parseInt=oe,v.random=function(n,t,r){var e=null==n,u=null==t;return null==r&&(typeof n=="boolean"&&u?(r=n,n=1):u||typeof t!="boolean"||(r=t,u=true)),e&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,r||n%1||t%1?(r=Lr(),qr(n+r*(t-n+parseFloat("1e-"+((r+"").length-1))),t)):at(n,t) +},v.reduce=Ft,v.reduceRight=qt,v.result=function(n,t){if(n){var r=n[t];return Ct(r)?n[t]():r}},v.runInContext=g,v.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Gr(n).length},v.some=Lt,v.sortedIndex=Mt,v.template=function(n,t,r){var e=v.templateSettings;n=lr(n||""),r=dt({},r,e);var u,o=dt({},r.imports,e.imports),e=Gr(o),o=St(o),i=0,f=r.interpolate||A,l="__p+='",f=fr((r.escape||A).source+"|"+f.source+"|"+(f===S?k:A).source+"|"+(r.evaluate||A).source+"|$","g");n.replace(f,function(t,r,e,o,f,c){return e||(e=o),l+=n.slice(i,c).replace(R,a),r&&(l+="'+__e("+r+")+'"),f&&(u=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),i=c+t.length,t +}),l+="';",f=r=r.variable,f||(r="obj",l="with("+r+"){"+l+"}"),l=(u?l.replace(j,""):l).replace(x,"$1").replace(C,"$1;"),l="function("+r+"){"+(f?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=ur(e,"return "+l).apply(h,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},v.unescape=function(n){return null==n?"":(n=lr(n),0>n.indexOf(";")?n:n.replace(Qr,vt))},v.uniqueId=function(n){var t=++m; +return lr(null==n?"":n)+t},v.all=At,v.any=Lt,v.detect=Rt,v.findWhere=Rt,v.foldl=Ft,v.foldr=qt,v.include=It,v.inject=Ft,Xt(function(){var n={};return bt(v,function(t,r){v.prototype[r]||(n[r]=t)}),n}(),false),v.first=Wt,v.last=function(n,t,r){var e=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=u;for(t=v.createCallback(t,r,3);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n?n[u-1]:h;return s(n,Fr(0,u-e))},v.sample=function(n,t,r){return n&&typeof n.length!="number"?n=St(n):Kr.unindexedChars&&Et(n)&&(n=n.split("")),null==t||r?n?n[at(0,n.length-1)]:h:(n=Bt(n),n.length=qr(Fr(0,t),n.length),n) +},v.take=Wt,v.head=Wt,bt(v,function(n,t){var r="sample"!==t;v.prototype[t]||(v.prototype[t]=function(t,e){var u=this.__chain__,o=n(this.__wrapped__,t,e);return u||null!=t&&(!e||r&&typeof t=="function")?new y(o,u):o})}),v.VERSION="2.4.1",v.prototype.chain=function(){return this.__chain__=true,this},v.prototype.toString=function(){return lr(this.__wrapped__)},v.prototype.value=nr,v.prototype.valueOf=nr,rt(["join","pop","shift"],function(n){var t=pr[n];v.prototype[n]=function(){var n=this.__chain__,r=t.apply(this.__wrapped__,arguments); +return n?new y(r,n):r}}),rt(["push","reverse","sort","unshift"],function(n){var t=pr[n];v.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),rt(["concat","slice","splice"],function(n){var t=pr[n];v.prototype[n]=function(){return new y(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Kr.spliceObjects||rt(["pop","shift","splice"],function(n){var t=pr[n],r="splice"==n;v.prototype[n]=function(){var n=this.__chain__,e=this.__wrapped__,u=t.apply(e,arguments);return 0===e.length&&delete e[0],n||r?new y(u,n):u +}}),v}var h,v=[],y=[],m=0,d=+new Date+"",b=75,_=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,x=/\b(__p\+=)''\+/g,C=/(__e\(.*?\)|\b__t\))\+'';/g,k=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,O=/\w*$/,E=/^\s*function[ \n\r\t]+\w/,S=/<%=([\s\S]+?)%>/g,I=RegExp("^["+w+"]*0+(?=.$)"),A=/($^)/,N=/\bthis\b/,R=/['\n\r\t\u2028\u2029\\]/g,P="Array Boolean Date Error Function Math Number Object RegExp String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),T="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),D="[object Arguments]",$="[object Array]",F="[object Boolean]",q="[object Date]",B="[object Error]",L="[object Function]",W="[object Number]",z="[object Object]",K="[object RegExp]",M="[object String]",V={}; +V[L]=false,V[D]=V[$]=V[F]=V[q]=V[W]=V[z]=V[K]=V[M]=true;var U={leading:false,maxWait:0,trailing:false},G={configurable:false,enumerable:false,value:null,writable:false},H={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},J={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Q=H[typeof window]&&window||this,X=H[typeof exports]&&exports&&!exports.nodeType&&exports,Y=H[typeof module]&&module&&!module.nodeType&&module,Z=Y&&Y.exports===X&&X,nt=H[typeof global]&&global;!nt||nt.global!==nt&&nt.window!==nt||(Q=nt); +var tt=g();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Q._=tt, define(function(){return tt})):X&&Y?Z?(Y.exports=tt)._=tt:X._=tt:Q._=tt}).call(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index f2fcd170c..7576f972f 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -1602,14 +1602,14 @@ * @returns {Array} Returns an array of property names. */ var shimKeys = function(object) { - var index, iterable = object, result = []; - if (!iterable) return result; + var result = []; + if (!(object && objectTypes[typeof object])) return result; if (!(objectTypes[typeof object])) return result; - for (index in iterable) { - if (hasOwnProperty.call(iterable, index)) { - result.push(index); + for (var key in object) { + if (hasOwnProperty.call(object, key)) { + result.push(key); } - } + } return result }; @@ -1667,7 +1667,6 @@ * * @static * @memberOf _ - * @type Function * @alias extend * @category Objects * @param {Object} object The destination object. @@ -1853,7 +1852,6 @@ * * @static * @memberOf _ - * @type Function * @category Objects * @param {Object} object The destination object. * @param {...Object} [source] The source objects. @@ -2026,14 +2024,13 @@ * }); * // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments) */ - var forIn = function(collection, callback, thisArg) { - var index, iterable = collection, result = iterable; - if (!iterable) return result; - if (!objectTypes[typeof iterable]) return result; + var forIn = function(object, callback, thisArg) { + var result = object; + if (!(object && objectTypes[typeof object])) return result; callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); - for (index in iterable) { - if (callback(iterable[index], index, collection) === false) return result; - } + for (var key in object) { + if (callback(object[key], key, object) === false) return result; + } return result }; @@ -2090,7 +2087,6 @@ * * @static * @memberOf _ - * @type Function * @category Objects * @param {Object} object The object to iterate over. * @param {Function} [callback=identity] The function called per iteration. diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 4da3c2a6b..67edceb8d 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -3,53 +3,53 @@ * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.5.2 underscorejs.org/LICENSE * Build: `lodash modern -o ./dist/lodash.js` */ -;(function(){function n(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++ea||typeof i=="undefined")return 1;if(ie?0:e);++ra||typeof i=="undefined")return 1;if(ie?0:e);++r=b&&i===n,l=[]; -if(f){var p=o(r);p?(i=t,r=p):f=false}for(;++ui(r,p)&&l.push(p);return f&&c(r),l}function tt(n,t,e,r){r=(r||0)-1;for(var u=n?n.length:0,o=[];++r=b&&f===n,h=u||v?a():s;for(v&&(h=o(h),f=t);++if(h,y))&&((u||v)&&h.push(y),s.push(g)) -}return v?(l(h.k),c(h)):u&&l(h),s}function it(n){return function(t,e,r){var u={};e=d.createCallback(e,r,3),r=-1;var o=t?t.length:0;if(typeof o=="number")for(;++r=b&&i===n,l=[]; +if(f){var p=o(r);p?(i=t,r=p):f=false}for(;++ui(r,p)&&l.push(p);return f&&c(r),l}function tt(n,t,e,r){r=(r||0)-1;for(var u=n?n.length:0,o=[];++r=b&&f===n,v=u||h?a():s;for(h&&(v=o(v),f=t);++if(v,y))&&((u||h)&&v.push(y),s.push(g)) +}return h?(l(v.g),c(v)):u&&l(v),s}function it(n){return function(t,e,r){var u={};e=d.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=-1e?Se(0,o+e):e)||0,We(n)?i=-1o&&(o=a)}}else t=null==t&&xt(n)?r:d.createCallback(t,e,3),Rt(n,function(n,e,r){e=t(n,e,r),e>u&&(u=e,o=n)});return o}function Dt(n,t,e,r){if(!n)return e;var u=3>arguments.length;t=d.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length;return t=d.createCallback(t,r,4),St(n,function(n,r,o){e=u?(u=false,n):t(e,n,r,o) -}),e}function Ft(n){var t=-1,e=n?n.length:0,r=Yt(typeof e=="number"?e:0);return Rt(n,function(n){var e=ut(0,++t);r[t]=r[e],r[e]=n}),r}function Bt(n,t,e){var r;t=d.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++er?Se(0,u+r):r||0}else if(r)return r=Pt(t,e),t[r]===e?r:-1;return n(t,e,r)}function zt(n,t,e){if(typeof t!="number"&&null!=t){var r=0,u=-1,o=n?n.length:0;for(t=d.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++t=v;m?(i&&(i=ye(i)),s=f,a=n.apply(l,o)):i||(i=je(r,v))}return m&&c?c=ye(c):c||t===h||(c=je(u,t)),e&&(m=true,a=n.apply(l,o)),!m||c||i||(o=l=null),a}}function Gt(n){return n}function Ht(n,t,e){var r=true,u=t&&bt(t); -t&&(e||u.length)||(null==e&&(e=t),o=U,t=n,n=d,u=bt(t)),false===e?r=false:jt(e)&&"chain"in e&&(r=e.chain);var o=n,i=wt(o);Rt(u,function(e){var u=n[e]=t[e];i&&(o.prototype[e]=function(){var t=this.__chain__,e=this.__wrapped__,i=[e];if(we.apply(i,arguments),i=u.apply(n,i),r||t){if(e===i&&jt(i))return this;i=new o(i),i.__chain__=t}return i})})}function Jt(){}function Qt(n){return function(t){return t[n]}}function Xt(){return this.__wrapped__}e=e?Y.defaults(G.Object(),e,Y.pick(G,T)):G;var Yt=e.Array,Zt=e.Boolean,ne=e.Date,te=e.Function,ee=e.Math,re=e.Number,ue=e.Object,oe=e.RegExp,ie=e.String,ae=e.TypeError,fe=[],le=ue.prototype,ce=e.window,pe=ce&&ce.document,se=e._,ve=le.toString,he=oe("^"+ie(ve).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),ge=ee.ceil,ye=e.clearTimeout,me=ee.floor,be=te.prototype.toString,de=ct(de=ue.getPrototypeOf)&&de,_e=le.hasOwnProperty,we=fe.push,je=e.setTimeout,ke=fe.splice,xe=fe.unshift,Ce=function(){try{var n={},t=ct(t=ue.defineProperty)&&t,e=t(n,n,n)&&t -}catch(r){}return e}(),Oe=ct(Oe=ue.create)&&Oe,Ee=ct(Ee=Yt.isArray)&&Ee,Ne=e.isFinite,Ie=e.isNaN,Re=ct(Re=ue.keys)&&Re,Se=ee.max,Te=ee.min,Ae=e.parseInt,De=ee.random,$e={};$e[D]=Yt,$e[$]=Zt,$e[F]=ne,$e[B]=te,$e[q]=ue,$e[W]=re,$e[z]=oe,$e[P]=ie,U.prototype=d.prototype;var Fe=d.support={};Fe.dom=!!pe&&typeof pe=="object"&&he.test(ye)&&he.test(je),Fe.funcDecomp=!ct(e.WinRTError)&&R.test(s),Fe.funcNames=typeof te.name=="string",d.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:E,variable:"",imports:{_:d}},Oe||(Q=function(){function n(){}return function(t){if(jt(t)){n.prototype=t; -var r=new n;n.prototype=null}return r||e.Object()}}());var Be=Ce?function(n,t){M.value=t,Ce(n,"__bindData__",M)}:Jt,We=Ee||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&ve.call(n)==D||false},qe=Re?function(n){return jt(n)?Re(n):[]}:g,ze={"&":"&","<":"<",">":">",'"':""","'":"'"},Pe=dt(ze),Ke=oe("("+qe(Pe).join("|")+")","g"),Le=oe("["+qe(ze).join("")+"]","g");Fe.dom||(_t=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!Me(n)||false});var Me=de?function(n){if(!n||ve.call(n)!=q)return false; -var t=n.valueOf,e=ct(t)&&(e=de(t))&&de(e);return e?n==e||de(n)==e:pt(n)}:pt,Ve=it(function(n,t,e){_e.call(n,e)?n[e]++:n[e]=1}),Ue=it(function(n,t,e){(_e.call(n,e)?n[e]:n[e]=[]).push(t)}),Ge=it(function(n,t,e){n[e]=t}),He=Tt,Je=ct(Je=ne.now)&&Je||function(){return(new ne).getTime()},Qe=8==Ae(_+"08")?Ae:function(n,t){return Ae(xt(n)?n.replace(N,""):n,t||0)};return d.after=function(n,t){if(!wt(t))throw new ae;return function(){return 1>--n?t.apply(this,arguments):void 0}},d.assign=ht,d.at=function(n){for(var t=arguments,e=-1,r=tt(t,true,false,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Yt(t);++ee?0:e);++t=h;m?(i&&(i=ye(i)),s=f,a=n.apply(l,o)):i||(i=je(r,h))}return m&&c?c=ye(c):c||t===v||(c=je(u,t)),e&&(m=true,a=n.apply(l,o)),!m||c||i||(o=l=null),a}}function Gt(n){return n}function Ht(n,t,e){var r=true,u=t&&bt(t); +t&&(e||u.length)||(null==e&&(e=t),o=U,t=n,n=d,u=bt(t)),false===e?r=false:jt(e)&&"chain"in e&&(r=e.chain);var o=n,i=wt(o);Rt(u,function(e){var u=n[e]=t[e];i&&(o.prototype[e]=function(){var t=this.__chain__,e=this.__wrapped__,i=[e];if(we.apply(i,arguments),i=u.apply(n,i),r||t){if(e===i&&jt(i))return this;i=new o(i),i.__chain__=t}return i})})}function Jt(){}function Qt(n){return function(t){return t[n]}}function Xt(){return this.__wrapped__}e=e?Y.defaults(G.Object(),e,Y.pick(G,T)):G;var Yt=e.Array,Zt=e.Boolean,ne=e.Date,te=e.Function,ee=e.Math,re=e.Number,ue=e.Object,oe=e.RegExp,ie=e.String,ae=e.TypeError,fe=[],le=ue.prototype,ce=e.window,pe=ce&&ce.document,se=e._,he=le.toString,ve=oe("^"+ie(he).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),ge=ee.ceil,ye=e.clearTimeout,me=ee.floor,be=te.prototype.toString,de=ct(de=ue.getPrototypeOf)&&de,_e=le.hasOwnProperty,we=fe.push,je=e.setTimeout,ke=fe.splice,xe=fe.unshift,Ce=function(){try{var n={},t=ct(t=ue.defineProperty)&&t,e=t(n,n,n)&&t +}catch(r){}return e}(),Oe=ct(Oe=ue.create)&&Oe,Ee=ct(Ee=Yt.isArray)&&Ee,Ne=e.isFinite,Ie=e.isNaN,Re=ct(Re=ue.keys)&&Re,Se=ee.max,Te=ee.min,Ae=e.parseInt,De=ee.random,$e={};$e[D]=Yt,$e[$]=Zt,$e[F]=ne,$e[B]=te,$e[q]=ue,$e[W]=re,$e[z]=oe,$e[P]=ie,U.prototype=d.prototype;var Fe=d.support={};Fe.dom=!!pe&&typeof pe=="object"&&ve.test(ye)&&ve.test(je),Fe.funcDecomp=!ct(e.WinRTError)&&R.test(s),Fe.funcNames=typeof te.name=="string",d.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:E,variable:"",imports:{_:d}},Oe||(Q=function(){function n(){}return function(t){if(jt(t)){n.prototype=t; +var r=new n;n.prototype=null}return r||e.Object()}}());var Be=Ce?function(n,t){M.value=t,Ce(n,"__bindData__",M)}:Jt,We=Ee||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&he.call(n)==D||false},qe=Re?function(n){return jt(n)?Re(n):[]}:g,ze={"&":"&","<":"<",">":">",'"':""","'":"'"},Pe=dt(ze),Ke=oe("("+qe(Pe).join("|")+")","g"),Le=oe("["+qe(ze).join("")+"]","g");Fe.dom||(_t=function(n){return n&&typeof n=="object"&&1===n.nodeType&&!Me(n)||false});var Me=de?function(n){if(!n||he.call(n)!=q)return false; +var t=n.valueOf,e=ct(t)&&(e=de(t))&&de(e);return e?n==e||de(n)==e:pt(n)}:pt,Ve=it(function(n,t,e){_e.call(n,e)?n[e]++:n[e]=1}),Ue=it(function(n,t,e){(_e.call(n,e)?n[e]:n[e]=[]).push(t)}),Ge=it(function(n,t,e){n[e]=t}),He=Tt,Je=ct(Je=ne.now)&&Je||function(){return(new ne).getTime()},Qe=8==Ae(_+"08")?Ae:function(n,t){return Ae(xt(n)?n.replace(N,""):n,t||0)};return d.after=function(n,t){if(!wt(t))throw new ae;return function(){return 1>--n?t.apply(this,arguments):void 0}},d.assign=vt,d.at=function(n){for(var t=arguments,e=-1,r=tt(t,true,false,1),t=t[2]&&t[2][t[1]]===n?1:r.length,u=Yt(t);++e=b&&o(r?e[r]:s)))}var p=e[0],h=-1,g=p?p.length:0,y=[];n:for(;++h(m?t(m,v):f(s,v))){for(r=u,(m||s).push(v);--r;)if(m=i[r],0>(m?t(m,v):f(e[r],v)))continue n;y.push(v)}}for(;u--;)(m=i[u])&&c(m);return l(i),l(s),y},d.invert=dt,d.invoke=function(n,t){var e=p(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,i=Yt(typeof o=="number"?o:0);return Rt(n,function(n){i[++r]=(u?t:n[t]).apply(n,e)}),i},d.keys=qe,d.map=Tt,d.mapValues=function(n,t,e){var r={}; +return function(){for(var t=arguments,e=n.length;e--;)t=[n[e].apply(this,t)];return t[0]}},d.constant=function(n){return function(){return n}},d.countBy=Ve,d.create=function(n,t){var e=Q(n);return t?vt(e,t):e},d.createCallback=function(n,t,e){var r=typeof n;if(null==n||"function"==r)return X(n,t,e);if("object"!=r)return Qt(n);var u=qe(n),o=u[0],i=n[o];return 1!=u.length||i!==i||jt(i)?function(t){for(var e=u.length,r=false;e--&&(r=et(t[u[e]],n[u[e]],null,true)););return r}:function(n){return n=n[o],i===n&&(0!==i||1/i==1/n) +}},d.curry=function(n,t){return t=typeof t=="number"?t:+t||n.length,at(n,4,null,null,null,t)},d.debounce=Ut,d.defaults=gt,d.defer=function(n){if(!wt(n))throw new ae;var t=p(arguments,1);return je(function(){n.apply(h,t)},1)},d.delay=function(n,t){if(!wt(n))throw new ae;var e=p(arguments,2);return je(function(){n.apply(h,e)},t)},d.difference=function(n){return nt(n,tt(arguments,true,true,1))},d.filter=Nt,d.flatten=function(n,t,e,r){return typeof t!="boolean"&&null!=t&&(r=e,e=typeof t!="function"&&r&&r[t]===n?null:t,t=false),null!=e&&(n=Tt(n,e,r)),tt(n,t) +},d.forEach=Rt,d.forEachRight=St,d.forIn=v,d.forInRight=function(n,t,e){var r=[];v(n,function(n,t){r.push(t,n)});var u=r.length;for(t=X(t,e,3);u--&&false!==t(r[u--],r[u],n););return n},d.forOwn=yt,d.forOwnRight=mt,d.functions=bt,d.groupBy=Ue,d.indexBy=Ge,d.initial=function(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=u;for(t=d.createCallback(t,e,3);o--&&t(n[o],o,n);)r++}else r=null==t||e?1:t||r;return p(n,0,Te(Se(0,u-r),u))},d.intersection=function(){for(var e=[],r=-1,u=arguments.length,i=a(),f=lt(),p=f===n,s=a();++r=b&&o(r?e[r]:s)))}var p=e[0],v=-1,g=p?p.length:0,y=[];n:for(;++v(m?t(m,h):f(s,h))){for(r=u,(m||s).push(h);--r;)if(m=i[r],0>(m?t(m,h):f(e[r],h)))continue n;y.push(h)}}for(;u--;)(m=i[u])&&c(m);return l(i),l(s),y},d.invert=dt,d.invoke=function(n,t){var e=p(arguments,2),r=-1,u=typeof t=="function",o=n?n.length:0,i=Yt(typeof o=="number"?o:0);return Rt(n,function(n){i[++r]=(u?t:n[t]).apply(n,e)}),i},d.keys=qe,d.map=Tt,d.mapValues=function(n,t,e){var r={}; return t=d.createCallback(t,e,3),yt(n,function(n,e,u){r[e]=t(n,e,u)}),r},d.max=At,d.memoize=function(n,t){function e(){var r=e.cache,u=t?t.apply(this,arguments):m+arguments[0];return _e.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}if(!wt(n))throw new ae;return e.cache={},e},d.merge=function(n){var t=arguments,e=2;if(!jt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3e?Se(0,r+e):Te(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},d.mixin=Ht,d.noConflict=function(){return e._=se,this},d.noop=Jt,d.now=Je,d.parseInt=Qe,d.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=true)),r&&u&&(t=1),n=+n||0,u?(t=n,n=0):t=+t||0,e||n%1||t%1?(e=De(),Te(n+e*(t-n+parseFloat("1e-"+((e+"").length-1))),t)):ut(n,t) },d.reduce=Dt,d.reduceRight=$t,d.result=function(n,t){if(n){var e=n[t];return wt(e)?n[t]():e}},d.runInContext=s,d.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:qe(n).length},d.some=Bt,d.sortedIndex=Pt,d.template=function(n,t,e){var r=d.templateSettings;n=ie(n||""),e=gt({},e,r);var u,o=gt({},e.imports,r.imports),r=qe(o),o=Ct(o),a=0,f=e.interpolate||I,l="__p+='",f=oe((e.escape||I).source+"|"+f.source+"|"+(f===E?x:I).source+"|"+(e.evaluate||I).source+"|$","g");n.replace(f,function(t,e,r,o,f,c){return r||(r=o),l+=n.slice(a,c).replace(S,i),e&&(l+="'+__e("+e+")+'"),f&&(u=true,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(w,""):l).replace(j,"$1").replace(k,"$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=te(r,"return "+l).apply(v,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},d.unescape=function(n){return null==n?"":(n=ie(n),0>n.indexOf(";")?n:n.replace(Ke,st))},d.uniqueId=function(n){var t=++y; -return ie(null==n?"":n)+t},d.all=Et,d.any=Bt,d.detect=It,d.findWhere=It,d.foldl=Dt,d.foldr=$t,d.include=Ot,d.inject=Dt,Ht(function(){var n={};return yt(d,function(t,e){d.prototype[e]||(n[e]=t)}),n}(),false),d.first=Wt,d.last=function(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=u;for(t=d.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 p(n,Se(0,u-r))},d.sample=function(n,t,e){return n&&typeof n.length!="number"&&(n=Ct(n)),null==t||e?n?n[ut(0,n.length-1)]:v:(n=Ft(n),n.length=Te(Se(0,t),n.length),n) +}),l+="';",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(w,""):l).replace(j,"$1").replace(k,"$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=te(r,"return "+l).apply(h,o)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},d.unescape=function(n){return null==n?"":(n=ie(n),0>n.indexOf(";")?n:n.replace(Ke,st))},d.uniqueId=function(n){var t=++y; +return ie(null==n?"":n)+t},d.all=Et,d.any=Bt,d.detect=It,d.findWhere=It,d.foldl=Dt,d.foldr=$t,d.include=Ot,d.inject=Dt,Ht(function(){var n={};return yt(d,function(t,e){d.prototype[e]||(n[e]=t)}),n}(),false),d.first=Wt,d.last=function(n,t,e){var r=0,u=n?n.length:0;if(typeof t!="number"&&null!=t){var o=u;for(t=d.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 p(n,Se(0,u-r))},d.sample=function(n,t,e){return n&&typeof n.length!="number"&&(n=Ct(n)),null==t||e?n?n[ut(0,n.length-1)]:h:(n=Ft(n),n.length=Te(Se(0,t),n.length),n) },d.take=Wt,d.head=Wt,yt(d,function(n,t){var e="sample"!==t;d.prototype[t]||(d.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 U(o,u):o})}),d.VERSION="2.4.1",d.prototype.chain=function(){return this.__chain__=true,this},d.prototype.toString=function(){return ie(this.__wrapped__)},d.prototype.value=Xt,d.prototype.valueOf=Xt,Rt(["join","pop","shift"],function(n){var t=fe[n];d.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments); -return n?new U(e,n):e}}),Rt(["push","reverse","sort","unshift"],function(n){var t=fe[n];d.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Rt(["concat","slice","splice"],function(n){var t=fe[n];d.prototype[n]=function(){return new U(t.apply(this.__wrapped__,arguments),this.__chain__)}}),d}var v,h=[],g=[],y=0,m=+new Date+"",b=75,d=40,_=" \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",w=/\b__p\+='';/g,j=/\b(__p\+=)''\+/g,k=/(__e\(.*?\)|\b__t\))\+'';/g,x=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,C=/\w*$/,O=/^\s*function[ \n\r\t]+\w/,E=/<%=([\s\S]+?)%>/g,N=RegExp("^["+_+"]*0+(?=.$)"),I=/($^)/,R=/\bthis\b/,S=/['\n\r\t\u2028\u2029\\]/g,T="Array Boolean Date Function Math Number Object RegExp String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),A="[object Arguments]",D="[object Array]",$="[object Boolean]",F="[object Date]",B="[object Function]",W="[object Number]",q="[object Object]",z="[object RegExp]",P="[object String]",K={}; +return n?new U(e,n):e}}),Rt(["push","reverse","sort","unshift"],function(n){var t=fe[n];d.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Rt(["concat","slice","splice"],function(n){var t=fe[n];d.prototype[n]=function(){return new U(t.apply(this.__wrapped__,arguments),this.__chain__)}}),d}var h,v=[],g=[],y=0,m=+new Date+"",b=75,d=40,_=" \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",w=/\b__p\+='';/g,j=/\b(__p\+=)''\+/g,k=/(__e\(.*?\)|\b__t\))\+'';/g,x=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,C=/\w*$/,O=/^\s*function[ \n\r\t]+\w/,E=/<%=([\s\S]+?)%>/g,N=RegExp("^["+_+"]*0+(?=.$)"),I=/($^)/,R=/\bthis\b/,S=/['\n\r\t\u2028\u2029\\]/g,T="Array Boolean Date Function Math Number Object RegExp String _ clearTimeout document isFinite isNaN parseInt setTimeout TypeError window WinRTError".split(" "),A="[object Arguments]",D="[object Array]",$="[object Boolean]",F="[object Date]",B="[object Function]",W="[object Number]",q="[object Object]",z="[object RegExp]",P="[object String]",K={}; K[B]=false,K[A]=K[D]=K[$]=K[F]=K[W]=K[q]=K[z]=K[P]=true;var L={leading:false,maxWait:0,trailing:false},M={configurable:false,enumerable:false,value:null,writable:false},V={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},U={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},G=V[typeof window]&&window||this,H=V[typeof exports]&&exports&&!exports.nodeType&&exports,J=V[typeof module]&&module&&!module.nodeType&&module,Q=J&&J.exports===H&&H,X=V[typeof global]&&global;!X||X.global!==X&&X.window!==X||(G=X); var Y=s();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(G._=Y, define(function(){return Y})):H&&J?Q?(J.exports=Y)._=Y:H._=Y:G._=Y}).call(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index e452ad5fd..78b4412bf 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -949,14 +949,14 @@ * @returns {Array} Returns an array of property names. */ var shimKeys = function(object) { - var index, iterable = object, result = []; - if (!iterable) return result; + var result = []; + if (!(object && objectTypes[typeof object])) return result; if (!(objectTypes[typeof object])) return result; - for (index in iterable) { - if (hasOwnProperty.call(iterable, index)) { - result.push(index); + for (var key in object) { + if (hasOwnProperty.call(object, key)) { + result.push(key); } - } + } return result }; @@ -1014,7 +1014,6 @@ * * @static * @memberOf _ - * @type Function * @alias extend * @category Objects * @param {Object} object The destination object. @@ -1040,10 +1039,10 @@ return object; } for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) { - var iterable = arguments[argsIndex]; - if (iterable) { - for (var key in iterable) { - object[key] = iterable[key]; + var source = arguments[argsIndex]; + if (source) { + for (var key in source) { + object[key] = source[key]; } } } @@ -1103,7 +1102,6 @@ * * @static * @memberOf _ - * @type Function * @category Objects * @param {Object} object The destination object. * @param {...Object} [source] The source objects. @@ -1121,11 +1119,11 @@ return object; } for (var argsIndex = 1, argsLength = arguments.length; argsIndex < argsLength; argsIndex++) { - var iterable = arguments[argsIndex]; - if (iterable) { - for (var key in iterable) { + var source = arguments[argsIndex]; + if (source) { + for (var key in source) { if (typeof object[key] == 'undefined') { - object[key] = iterable[key]; + object[key] = source[key]; } } } @@ -1164,13 +1162,12 @@ * }); * // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments) */ - var forIn = function(collection, callback) { - var index, iterable = collection, result = iterable; - if (!iterable) return result; - if (!objectTypes[typeof iterable]) return result; - for (index in iterable) { - if (callback(iterable[index], index, collection) === indicatorObject) return result; - } + var forIn = function(object, callback) { + var result = object; + if (!(object && objectTypes[typeof object])) return result; + for (var key in object) { + if (callback(object[key], key, object) === indicatorObject) return result; + } return result }; @@ -1182,7 +1179,6 @@ * * @static * @memberOf _ - * @type Function * @category Objects * @param {Object} object The object to iterate over. * @param {Function} [callback=identity] The function called per iteration. diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index f70a8911e..161428762 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -3,37 +3,37 @@ * Lo-Dash 2.4.1 (Custom Build) lodash.com/license | Underscore.js 1.5.2 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;++tf||typeof i=="undefined")return 1;if(it?0:t);++ef||typeof i=="undefined")return 1;if(it?0:t);++ee(r,i)&&o.push(i)}return o}function p(n,r,t,e){e=(e||0)-1;for(var u=n?n.length:0,o=[];++eu(f,l))&&(t&&f.push(l),i.push(a))}return i}function h(n){return function(r,t,e){var u={};t=Y(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=Y(t,e,3),e=-1;var o=r?r.length:0;if(typeof o=="number")for(;++eu&&(u=t);else r=Y(r,t,3),I(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});return u}function z(n,r,t,e){if(!n)return t;var u=3>arguments.length;r=Y(r,e,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(t=n[++o]);++oarguments.length; -return r=Y(r,e,4),M(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function P(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return I(n,function(n){var t;t=++r,t=0+Nr(Cr()*(t-0+1)),e[r]=e[t],e[t]=n}),e}function U(n,r,t){var e;r=Y(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++te?Wr(0,u+e):e||0}else if(e)return e=K(r,t),r[e]===t?e:-1;return n(r,t,e)}function J(n,r,t){if(typeof r!="number"&&null!=r){var u=0,o=-1,i=n?n.length:0;for(r=Y(r,t,3);++o>>1,t(n[e])=y;m?(u&&(u=clearTimeout(u)),c=i,o=n.apply(f,e)):u||(u=setTimeout(v,y))}return m&&a?a=clearTimeout(a):a||r===p||(a=setTimeout(h,r)),t&&(m=true,o=n.apply(f,e)),!m||a||u||(e=f=null),o}}function Y(n,r,t){var e=typeof n;if(null==n||"function"==e)return a(n,r,t);if("object"!=e)return rr(n);var u=Gr(n); return function(r){for(var t=u.length,e=false;t--&&(e=r[u[t]]===n[u[t]]););return e}}function Z(n){return n}function nr(n){I(T(n),function(r){var t=u[r]=n[r];u.prototype[r]=function(){var n=[this.__wrapped__];return Fr.apply(n,arguments),n=t.apply(u,n),this.__chain__?new o(n,true):n}})}function rr(n){return function(r){return r[n]}}var tr,er=0,ur={},or=+new Date+"",ir=/($^)/,fr=/['\n\r\t\u2028\u2029\\]/g,ar="[object Arguments]",lr="[object Array]",cr="[object Boolean]",pr="[object Date]",sr="[object Number]",gr="[object Object]",hr="[object RegExp]",vr="[object String]",yr={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},mr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},_r=yr[typeof window]&&window||this,dr=yr[typeof exports]&&exports&&!exports.nodeType&&exports,br=yr[typeof module]&&module&&!module.nodeType&&module,wr=br&&br.exports===dr&&dr,jr=yr[typeof global]&&global; -!jr||jr.global!==jr&&jr.window!==jr||(_r=jr);var xr=[],Tr=Object.prototype,Er=_r._,Ar=Tr.toString,Or=RegExp("^"+(Ar+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Sr=Math.ceil,Nr=Math.floor,Rr=Function.prototype.toString,kr=Tr.hasOwnProperty,Fr=xr.push,Br=Tr.propertyIsEnumerable,qr=_(qr=Object.create)&&qr,Dr=_(Dr=Array.isArray)&&Dr,Ir=_r.isFinite,Mr=_r.isNaN,$r=_($r=Object.keys)&&$r,Wr=Math.max,zr=Math.min,Cr=Math.random;o.prototype=u.prototype;var Pr={};!function(){var n={0:1,length:1}; -Pr.spliceObjects=(xr.splice.call(n,0,1),!n[0])}(1),u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},qr||(f=function(){function n(){}return function(r){if(S(r)){n.prototype=r;var t=new n;n.prototype=null}return t||_r.Object()}}()),b(arguments)||(b=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&kr.call(n,"callee")&&!Br.call(n,"callee")||false});var Ur=Dr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ar.call(n)==lr||false -},Vr=function(n){var r,t=[];if(!n||!yr[typeof n])return t;for(r in n)kr.call(n,r)&&t.push(r);return t},Gr=$r?function(n){return S(n)?$r(n):[]}:Vr,Hr={"&":"&","<":"<",">":">",'"':""","'":"'"},Jr=E(Hr),Kr=RegExp("("+Gr(Jr).join("|")+")","g"),Lr=RegExp("["+Gr(Hr).join("")+"]","g"),Qr=function(n,r){var t;if(!n||!yr[typeof n])return n;for(t in n)if(r(n[t],t,n)===ur)break;return n};O(/x/)&&(O=function(n){return typeof n=="function"&&"[object Function]"==Ar.call(n)});var Xr=h(function(n,r,t){kr.call(n,t)?n[t]++:n[t]=1 -}),Yr=h(function(n,r,t){(kr.call(n,t)?n[t]:n[t]=[]).push(r)}),Zr=h(function(n,r,t){n[t]=r}),nt=$,rt=_(rt=Date.now)&&rt||function(){return(new Date).getTime()};u.after=function(n,r){if(!O(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=Q,u.bindAll=function(n){for(var r=1/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},qr||(f=function(){function n(){}return function(r){if(S(r)){n.prototype=r;var t=new n;n.prototype=null}return t||_r.Object()}}()),b(arguments)||(b=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Rr.call(n,"callee")&&!Br.call(n,"callee")||false});var Ur=Dr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Ar.call(n)==lr||false +},Vr=function(n){var r=[];if(!n||!yr[typeof n]||!yr[typeof n])return r;for(var t in n)Rr.call(n,t)&&r.push(t);return r},Gr=$r?function(n){return S(n)?$r(n):[]}:Vr,Hr={"&":"&","<":"<",">":">",'"':""","'":"'"},Jr=E(Hr),Kr=RegExp("("+Gr(Jr).join("|")+")","g"),Lr=RegExp("["+Gr(Hr).join("")+"]","g"),Qr=function(n,r){if(!n||!yr[typeof n])return n;for(var t in n)if(r(n[t],t,n)===ur)break;return n};O(/x/)&&(O=function(n){return typeof n=="function"&&"[object Function]"==Ar.call(n)});var Xr=h(function(n,r,t){Rr.call(n,t)?n[t]++:n[t]=1 +}),Yr=h(function(n,r,t){(Rr.call(n,t)?n[t]:n[t]=[]).push(r)}),Zr=h(function(n,r,t){n[t]=r}),nt=$,rt=_(rt=Date.now)&&rt||function(){return(new Date).getTime()};u.after=function(n,r){if(!O(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},u.bind=Q,u.bindAll=function(n){for(var r=1i(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n; -a.push(e)}return a},u.invert=E,u.invoke=function(n,r){var t=e(arguments,2),u=-1,o=typeof r=="function",i=n?n.length:0,f=Array(typeof i=="number"?i:0);return I(n,function(n){f[++u]=(o?r:n[r]).apply(n,t)}),f},u.keys=Gr,u.map=$,u.max=W,u.memoize=function(n,r){var t={};return function(){var e=r?r.apply(this,arguments):or+arguments[0];return kr.call(t,e)?t[e]:t[e]=n.apply(this,arguments)}},u.min=function(n,r,t){var e=1/0,u=e;typeof r!="function"&&t&&t[r]===n&&(r=null);var o=-1,i=n?n.length:0;if(null==r&&typeof i=="number")for(;++or?0:r);++nt?Wr(0,e+t):zr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=nr,u.noConflict=function(){return _r._=Er,this},u.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Nr(Cr()*(r-n+1)) +},u.pick=function(n){for(var r=-1,t=p(arguments,true,false,1),e=t.length,u={};++rr?0:r);++nt?Wr(0,e+t):zr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},u.mixin=nr,u.noConflict=function(){return _r._=Er,this},u.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+kr(Cr()*(r-n+1)) },u.reduce=z,u.reduceRight=C,u.result=function(n,r){if(n){var t=n[r];return O(t)?n[r]():t}},u.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:Gr(n).length},u.some=U,u.sortedIndex=K,u.template=function(n,r,e){var o=u,i=o.templateSettings;n=(n||"")+"",e=j({},e,i);var f=0,a="__p+='",i=e.variable;n.replace(RegExp((e.escape||ir).source+"|"+(e.interpolate||ir).source+"|"+(e.evaluate||ir).source+"|$","g"),function(r,e,u,o,i){return a+=n.slice(f,i).replace(fr,t),e&&(a+="'+_.escape("+e+")+'"),o&&(a+="';"+o+";\n__p+='"),u&&(a+="'+((__t=("+u+"))==null?'':__t)+'"),f=i+r.length,r }),a+="';",i||(i="obj",a="with("+i+"||{}){"+a+"}"),a="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+a+"return __p}";try{var l=Function("_","return "+a)(o)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},u.unescape=function(n){return null==n?"":(n+="",0>n.indexOf(";")?n:n.replace(Kr,d))},u.uniqueId=function(n){var r=++er+"";return n?n+r:r},u.all=B,u.any=U,u.detect=D,u.findWhere=function(n,r){return V(n,r,true)},u.foldl=z,u.foldr=C,u.include=F,u.inject=z,u.first=G,u.last=function(n,r,t){var u=0,o=n?n.length:0; -if(typeof r!="number"&&null!=r){var i=o;for(r=Y(r,t,3);i--&&r(n[i],i,n);)u++}else if(u=r,null==u||t)return n?n[o-1]:tr;return e(n,Wr(0,o-u))},u.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=k(n)),null==r||t?n?n[0+Nr(Cr()*(n.length-1-0+1))]:tr:(n=P(n),n.length=zr(Wr(0,r),n.length),n)},u.take=G,u.head=G,nr(w({},u)),u.VERSION="2.4.1",u.prototype.chain=function(){return this.__chain__=true,this},u.prototype.value=function(){return this.__wrapped__},I("pop push reverse shift sort splice unshift".split(" "),function(n){var r=xr[n]; +if(typeof r!="number"&&null!=r){var i=o;for(r=Y(r,t,3);i--&&r(n[i],i,n);)u++}else if(u=r,null==u||t)return n?n[o-1]:tr;return e(n,Wr(0,o-u))},u.sample=function(n,r,t){return n&&typeof n.length!="number"&&(n=R(n)),null==r||t?n?n[0+kr(Cr()*(n.length-1-0+1))]:tr:(n=P(n),n.length=zr(Wr(0,r),n.length),n)},u.take=G,u.head=G,nr(w({},u)),u.VERSION="2.4.1",u.prototype.chain=function(){return this.__chain__=true,this},u.prototype.value=function(){return this.__wrapped__},I("pop push reverse shift sort splice unshift".split(" "),function(n){var r=xr[n]; u.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),Pr.spliceObjects||0!==n.length||delete n[0],this}}),I(["concat","join","slice"],function(n){var r=xr[n];u.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new o(n),n.__chain__=true),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(_r._=u, define(function(){return u})):dr&&br?wr?(br.exports=u)._=u:dr._=u:_r._=u}).call(this); \ No newline at end of file diff --git a/lodash.js b/lodash.js index 5f8d8edaa..61d167f7f 100644 --- a/lodash.js +++ b/lodash.js @@ -125,21 +125,6 @@ 'writable': false }; - /** Used as the data object for `iteratorTemplate` */ - var iteratorData = { - 'args': '', - 'array': null, - 'bottom': '', - 'firstArg': '', - 'init': '', - 'keys': null, - 'loop': '', - 'shadowedProps': null, - 'support': null, - 'top': '', - 'useHas': false - }; - /** Used to determine if values are of the language type Object */ var objectTypes = { 'boolean': false, @@ -890,110 +875,72 @@ * @returns {string} Returns the interpolated text. */ var iteratorTemplate = template( - // the `iterable` may be reassigned by the `top` snippet - 'var index, iterable = <%= firstArg %>, ' + // assign the `result` variable an initial value - 'result = <%= init %>;\n' + - // exit early if the first argument is falsey - 'if (!iterable) return result;\n' + + 'var result = <%= init %>;\n' + + // exit early if the first argument is not an object + 'if (!(object && objectTypes[typeof object])) return result;\n' + // add code before the iteration branches '<%= top %>;' + - // array-like iteration: - '<% if (array) { %>\n' + - 'var length = iterable.length; index = -1;\n' + - 'if (<%= array %>) {' + - - // add support for accessing string characters by index if needed - ' <% if (support.unindexedChars) { %>\n' + - ' if (isString(iterable)) {\n' + - " iterable = iterable.split('')\n" + - ' }' + - ' <% } %>\n' + - - // iterate over the array-like value - ' while (++index < length) {\n' + + // add support for iterating over `arguments` objects if needed + '<% if (support.nonEnumArgs) { %>\n' + + 'var length = object.length;\n' + + 'if (length && isArguments(object)) {\n' + + ' key = -1;\n' + + ' while (++key < length) {\n' + + " key += '';\n" + ' <%= loop %>;\n' + ' }\n' + - '}\n' + - 'else {' + - - // object iteration: - // add support for iterating over `arguments` objects if needed - ' <% } else if (support.nonEnumArgs) { %>\n' + - ' var length = iterable.length; index = -1;\n' + - ' if (length && isArguments(iterable)) {\n' + - ' while (++index < length) {\n' + - " index += '';\n" + - ' <%= loop %>;\n' + - ' }\n' + - ' } else {' + - ' <% } %>' + + ' return result\n' + + '}' + + '<% } %>' + // avoid iterating over `prototype` properties in older Firefox, Opera, and Safari - ' <% if (support.enumPrototypes) { %>\n' + - " var skipProto = typeof iterable == 'function';\n" + - ' <% } %>' + + '<% if (support.enumPrototypes) { %>\n' + + "var skipProto = typeof object == 'function';\n" + + '<% } %>' + // avoid iterating over `Error.prototype` properties in older IE and Safari - ' <% if (support.enumErrorProps) { %>\n' + - ' var skipErrorProps = iterable === errorProto || iterable instanceof Error;\n' + - ' <% } %>' + + '<% if (support.enumErrorProps) { %>\n' + + 'var skipErrorProps = object === errorProto || object instanceof Error;\n' + + '<% } %>' + // define conditions used in the loop - ' <%' + - ' var conditions = [];' + - ' if (support.enumPrototypes) { conditions.push(\'!(skipProto && index == "prototype")\'); }' + - ' if (support.enumErrorProps) { conditions.push(\'!(skipErrorProps && (index == "message" || index == "name"))\'); }' + - ' %>' + - - // iterate own properties using `Object.keys` - ' <% if (useHas && keys) { %>\n' + - ' var ownIndex = -1,\n' + - ' ownProps = keys(iterable),\n' + - ' length = ownProps.length;\n\n' + - ' while (++ownIndex < length) {\n' + - ' index = ownProps[ownIndex];\n<%' + - " if (conditions.length) { %> if (<%= conditions.join(' && ') %>) {\n <% } %>" + - ' <%= loop %>;' + - ' <% if (conditions.length) { %>\n }<% } %>\n' + - ' }' + + '<%' + + 'var conditions = [];\n' + + "if (support.enumPrototypes) { conditions.push('!(skipProto && key == \\'prototype\\')'); }\n" + + "if (support.enumErrorProps) { conditions.push('!(skipErrorProps && (key == \\'message\\' || key == \\'name\\'))'); }" + + '%>\n' + // else using a for-in loop - ' <% } else { %>\n' + - ' for (index in iterable) {\n<%' + - ' if (useHas) { conditions.push("hasOwnProperty.call(iterable, index)"); }' + - " if (conditions.length) { %> if (<%= conditions.join(' && ') %>) {\n <% } %>" + - ' <%= loop %>;' + - ' <% if (conditions.length) { %>\n }<% } %>\n' + - ' }' + + 'for (var key in object) {\n<%' + + " if (useHas) { conditions.push('hasOwnProperty.call(object, key)'); }\n" + + " if (conditions.length) { %> if (<%= conditions.join(' && ') %>) {\n <% } %>" + + ' <%= loop %>;' + + ' <% if (conditions.length) { %>\n }<% } %>\n' + + '}\n' + // Because IE < 9 can't set the `[[Enumerable]]` attribute of an // existing property and the `constructor` property of a prototype // defaults to non-enumerable, Lo-Dash skips the `constructor` // property when it infers it's iterating over a `prototype` object. - ' <% if (support.nonEnumShadows) { %>\n\n' + - ' if (iterable !== objectProto) {\n' + - " var ctor = iterable.constructor,\n" + - ' isProto = iterable === (ctor && ctor.prototype),\n' + - ' className = iterable === stringProto ? stringClass : iterable === errorProto ? errorClass : toString.call(iterable),\n' + - ' nonEnum = nonEnumProps[className];\n' + - ' <% for (k = 0; k < 7; k++) { %>\n' + - " index = '<%= shadowedProps[k] %>';\n" + - ' if ((!(isProto && nonEnum[index]) && hasOwnProperty.call(iterable, index))<%' + - ' if (!useHas) { %> || (!nonEnum[index] && iterable[index] !== objectProto[index])<% }' + - ' %>) {\n' + - ' <%= loop %>;\n' + - ' }' + - ' <% } %>\n' + + '<% if (support.nonEnumShadows) { %>\n' + + 'if (object !== objectProto) {\n' + + " var ctor = object.constructor,\n" + + ' isProto = object === (ctor && ctor.prototype),\n' + + ' className = object === stringProto ? stringClass : object === errorProto ? errorClass : toString.call(object),\n' + + ' nonEnum = nonEnumProps[className];\n' + + ' <% for (var index = 0; index < 7; index++) { %>\n' + + " key = '<%= shadowedProps[index] %>';\n" + + ' if ((!(isProto && nonEnum[key]) && hasOwnProperty.call(object, key))<%' + + ' if (!useHas) { %> || (!nonEnum[key] && object[key] !== objectProto[key])<% }' + + ' %>) {\n' + + ' <%= loop %>;\n' + ' }' + - ' <% } %>' + - ' <% } %>' + - ' <% if (array || support.nonEnumArgs) { %>\n}<% } %>\n' + + ' <% } %>\n' + + '}' + + '<% } %>\n' + - // add code to the bottom of the iteration function - '<%= bottom %>;\n' + - // finally, return the `result` 'return result' ); @@ -1301,6 +1248,41 @@ return result; } + + /** + * Iterates `arguments` objects, arrays, objects, and strings consistently + * across environments, executing the callback for each element in the + * collection. The callback is bound to `thisArg` and invoked with three + * arguments; (value, index|key, collection). Callbacks may exit iteration + * early by explicitly returning `false`. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {*} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|string} Returns `collection`. + */ + function baseEach(collection, callback, thisArg) { + var index = -1, + iterable = collection, + length = collection ? collection.length : 0; + + callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); + if (typeof length == 'number') { + if (support.unindexedChars && isString(iterable)) { + iterable = iterable.split(''); + } + while (++index < length) { + if (callback(iterable[index], index, collection) === false) { + break; + } + } + } else { + forOwn(collection, callback); + } + return collection; + } + /** * The base implementation of `_.flatten` without support for callback * shorthands or `thisArg` binding. @@ -1757,48 +1739,28 @@ * Creates compiled iteration functions. * * @private - * @param {...Object} [options] The compile options object(s). - * @param {string} [options.array] Code to determine if the iterable is an array or array-like. - * @param {boolean} [options.useHas] Specify using `hasOwnProperty` checks in the object loop. - * @param {Function} [options.keys] A reference to `_.keys` for use in own property iteration. + * @param {Object} [options] The compile options object. * @param {string} [options.args] A comma separated string of iteration function arguments. * @param {string} [options.top] Code to execute before the iteration branches. * @param {string} [options.loop] Code to execute in the object loop. - * @param {string} [options.bottom] Code to execute after the iteration branches. + * @param {boolean} [options.useHas] Specify using `hasOwnProperty` checks in the object loop. * @returns {Function} Returns the compiled function. */ - function createIterator() { - // data properties - iteratorData.shadowedProps = shadowedProps; - iteratorData.support = support; - - // iterator options - iteratorData.array = iteratorData.bottom = iteratorData.loop = iteratorData.top = ''; - iteratorData.init = 'iterable'; - iteratorData.useHas = true; - - // merge options into a template data object - for (var object, index = 0; object = arguments[index]; index++) { - for (var key in object) { - iteratorData[key] = object[key]; - } - } - var args = iteratorData.args; - iteratorData.firstArg = /^[^,]+/.exec(args)[0]; + function createIterator(options) { + options.shadowedProps = shadowedProps; + options.support = support; // create the function factory var factory = Function( - 'baseCreateCallback, errorClass, errorProto, hasOwnProperty, ' + - 'indicatorObject, isArguments, isArray, isString, keys, objectProto, ' + - 'objectTypes, nonEnumProps, stringClass, stringProto, toString', - 'return function(' + args + ') {\n' + iteratorTemplate(iteratorData) + '\n}' + 'baseCreateCallback, errorClass, errorProto, hasOwnProperty, isArguments, ' + + 'objectProto, objectTypes, nonEnumProps, stringClass, stringProto, toString', + 'return function(' + options.args + ') {\n' + iteratorTemplate(options) + '\n}' ); // return the compiled function return factory( - baseCreateCallback, errorClass, errorProto, hasOwnProperty, - indicatorObject, isArguments, isArray, isString, iteratorData.keys, objectProto, - objectTypes, nonEnumProps, stringClass, stringProto, toString + baseCreateCallback, errorClass, errorProto, hasOwnProperty, isArguments, + objectProto, objectTypes, nonEnumProps, stringClass, stringProto, toString ); } @@ -1965,7 +1927,8 @@ 'args': 'object', 'init': '[]', 'top': 'if (!(objectTypes[typeof object])) return result', - 'loop': 'result.push(index)' + 'loop': 'result.push(key)', + 'useHas': true }); /** @@ -1992,15 +1955,6 @@ return nativeKeys(object); }; - /** Reusable iterator options shared by `each`, `forIn`, and `forOwn` */ - var eachIteratorOptions = { - 'args': 'collection, callback, thisArg', - 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)", - 'array': "typeof length == 'number'", - 'keys': keys, - 'loop': 'if (callback(iterable[index], index, collection) === false) return result' - }; - /** * Used to convert characters to HTML entities: * @@ -2024,22 +1978,6 @@ var reEscapedHtml = RegExp('(' + keys(htmlUnescapes).join('|') + ')', 'g'), reUnescapedHtml = RegExp('[' + keys(htmlEscapes).join('') + ']', 'g'); - /** - * A function compiled to iterate `arguments` objects, arrays, objects, and - * strings consistenly across environments, executing the callback for each - * element in the collection. The callback is bound to `thisArg` and invoked - * with three arguments; (value, index|key, collection). Callbacks may exit - * iteration early by explicitly returning `false`. - * - * @private - * @type Function - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function} [callback=identity] The function called per iteration. - * @param {*} [thisArg] The `this` binding of `callback`. - * @returns {Array|Object|string} Returns `collection`. - */ - var baseEach = createIterator(eachIteratorOptions); - /*--------------------------------------------------------------------------*/ /** @@ -2051,7 +1989,6 @@ * * @static * @memberOf _ - * @type Function * @alias extend * @category Objects * @param {Object} object The destination object. @@ -2237,7 +2174,6 @@ * * @static * @memberOf _ - * @type Function * @category Objects * @param {Object} object The destination object. * @param {...Object} [source] The source objects. @@ -2410,9 +2346,11 @@ * }); * // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments) */ - var forIn = createIterator(eachIteratorOptions, { - 'top': 'if (!objectTypes[typeof iterable]) return result;\n' + eachIteratorOptions.top, - 'array': false, + var forIn = createIterator({ + 'args': 'object, callback, thisArg', + 'init': 'object', + 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3)", + 'loop': 'if (callback(object[key], key, object) === false) return result', 'useHas': false }); @@ -2469,7 +2407,6 @@ * * @static * @memberOf _ - * @type Function * @category Objects * @param {Object} object The object to iterate over. * @param {Function} [callback=identity] The function called per iteration. @@ -3768,7 +3705,7 @@ } else if (support.unindexedChars && isString(collection)) { iterable = collection.split(''); } - baseEach(collection, function(value, key, collection) { + baseEach(iterable, function(value, key) { key = props ? props[--length] : --length; return callback(iterable[key], key, collection); }); @@ -7238,7 +7175,6 @@ } // add pseudo private property to be used and removed during the build process - lodash._baseEach = baseEach; lodash._iteratorTemplate = iteratorTemplate; lodash._shimKeys = shimKeys;