diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index a663746b0..43c890950 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -15,11 +15,8 @@ /** Used to generate unique IDs */ var idCounter = 0; - /** Used internally to indicate various things */ - var indicatorObject = {}; - - /** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */ - var keyPrefix = '__1335248838000__'; + /** Used by methods to exit iteration */ + var breakIndicator = '__lodash_break_1335248838000__'; /** Used to match HTML entities and HTML characters */ var reEscapedHtml = /&(?:amp|lt|gt|quot|#x27);/g, @@ -145,8 +142,7 @@ } /** - * The base implementation of `_.indexOf` without support for binary searches - * or `fromIndex` constraints. + * The base implementation of `_.indexOf` without support for binary searches. * * @private * @param {Array} array The array to search. @@ -331,7 +327,7 @@ * * @private * @param {*} value The value to wrap in a `lodash` instance. - * @param {boolean} chainAll A flag to enable chaining for all methods + * @param {boolean} [chainAll=false] A flag to enable chaining for all methods * @returns {Object} Returns a `lodash` instance. */ function lodashWrapper(value, chainAll) { @@ -458,7 +454,7 @@ * @param {Object} prototype The object to inherit from. * @returns {Object} Returns the new object. */ - function baseCreate(prototype, properties) { + function baseCreate(prototype) { return isObject(prototype) ? nativeCreate(prototype) : {}; } // fallback for environments without `Object.create` @@ -735,14 +731,14 @@ forIn(b, function(value, key, b) { if (hasOwnProperty.call(b, key)) { size++; - return !(result = hasOwnProperty.call(a, key) && baseIsEqual(a[key], value, stackA, stackB)) && indicatorObject; + return !(result = hasOwnProperty.call(a, key) && baseIsEqual(a[key], value, stackA, stackB)) && breakIndicator; } }); if (result) { forIn(a, function(value, key, a) { if (hasOwnProperty.call(a, key)) { - return !(result = --size > -1) && indicatorObject; + return !(result = --size > -1) && breakIndicator; } }); } @@ -1927,7 +1923,7 @@ result = indexOf(collection, target) > -1; } else { forOwn(collection, function(value) { - return (result = value === target) && indicatorObject; + return (result = value === target) && breakIndicator; }); } return result; @@ -2027,7 +2023,7 @@ } } else { forOwn(collection, function(value, index, collection) { - return !(result = !!callback(value, index, collection)) && indicatorObject; + return !(result = !!callback(value, index, collection)) && breakIndicator; }); } return result; @@ -2158,7 +2154,7 @@ forOwn(collection, function(value, index, collection) { if (callback(value, index, collection)) { result = value; - return indicatorObject; + return breakIndicator; } }); return result; @@ -2225,7 +2221,7 @@ callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3); if (typeof length == 'number') { while (++index < length) { - if (callback(collection[index], index, collection) === indicatorObject) { + if (callback(collection[index], index, collection) === breakIndicator) { break; } } @@ -2264,7 +2260,7 @@ length = props.length; forOwn(collection, function(value, key, collection) { key = props ? props[--length] : --length; - return callback(collection[key], key, collection) === false && indicatorObject; + return callback(collection[key], key, collection) === false && breakIndicator; }); } } @@ -2367,7 +2363,7 @@ * @param {Array|Object|string} collection The collection to iterate over. * @param {Function|string} methodName The name of the method to invoke or * the function invoked per iteration. - * @param {...*} [arg] Arguments to invoke the method with. + * @param {...*} [args] Arguments to invoke the method with. * @returns {Array} Returns a new array of the results of each invoked method. * @example * @@ -2886,7 +2882,7 @@ } } else { forOwn(collection, function(value, index, collection) { - return (result = callback(value, index, collection)) && indicatorObject; + return (result = callback(value, index, collection)) && breakIndicator; }); } return !!result; @@ -3067,7 +3063,7 @@ * @category Functions * @param {Function} func The function to bind. * @param {*} [thisArg] The `this` binding of `func`. - * @param {...*} [arg] Arguments to be partially applied. + * @param {...*} [args] Arguments to be partially applied. * @returns {Function} Returns the new bound function. * @example * @@ -3321,7 +3317,7 @@ * @memberOf _ * @category Functions * @param {Function} func The function to defer. - * @param {...*} [arg] Arguments to invoke the function with. + * @param {...*} [args] Arguments to invoke the function with. * @returns {number} Returns the timer id. * @example * @@ -3345,7 +3341,7 @@ * @category Functions * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay execution. - * @param {...*} [arg] Arguments to invoke the function with. + * @param {...*} [args] Arguments to invoke the function with. * @returns {number} Returns the timer id. * @example * @@ -3456,7 +3452,7 @@ * @memberOf _ * @category Functions * @param {Function} func The function to partially apply arguments to. - * @param {...*} [arg] Arguments to be partially applied. + * @param {...*} [args] Arguments to be partially applied. * @returns {Function} Returns the new partially applied function. * @example * @@ -3719,7 +3715,7 @@ return result; } for (var key in object) { - if (callback(object[key], key, object) === indicatorObject) { + if (callback(object[key], key, object) === breakIndicator) { return result; } } @@ -3753,7 +3749,7 @@ while (++index < length) { var key = props[index]; - if (callback(object[key], key, object) === indicatorObject) { + if (callback(object[key], key, object) === breakIndicator) { break; } } @@ -3829,26 +3825,15 @@ * _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true); * // => { 'fred': ['first', 'third'], 'barney': ['second'] } */ - function invert(object, multiValue) { + function invert(object) { var index = -1, props = keys(object), length = props.length, result = {}; while (++index < length) { - var key = props[index], - value = object[key]; - - if (multiValue) { - if (hasOwnProperty.call(result, value)) { - result[value].push(key); - } else { - result[value] = [key]; - } - } - else { - result[value] = key; - } + var key = props[index]; + result[object[key]] = key; } return result; } diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 60b40f71a..2b59f14b3 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -12,28 +12,28 @@ for(var u=n?n.length:0,o=[];++ee?Vr(0,u+e):e||0}else if(e)return e=T(r,t),r[e]===t?e:-1;return n(r,t,e)}function j(n,r,t){if(typeof r!="number"&&null!=r){var e=0,u=-1,o=n?n.length:0;for(r=X(r,t,3);++ur?r=Vr(u+r,0):r>u&&(r=u),typeof t=="undefined"?t=u:0>t?t=Vr(u+t,0):t>u&&(t=u),u=t-r||0,t=Array(u);++e>>1,t(n[e])u&&(u=t); else r=X(r,t,3),N(n,function(n,t,o){t=r(n,t,o),t>e&&(e=t,u=n)});return u}function R(n,r,t,e){var u=3>arguments.length;r=X(r,e,4);var o=-1,i=n?n.length:0;if(typeof i=="number")for(u&&i&&(t=n[++o]);++oarguments.length;return r=X(r,e,4),q(n,function(n,e,o){t=u?(u=false,n):r(t,n,e,o)}),t}function I(n){var r=-1,t=n?n.length:0,e=Array(typeof t=="number"?t:0);return N(n,function(n){var t;t=++r,t=0+Br(Hr()*(t-0+1)),e[r]=e[t],e[t]=n -}),e}function M(n,r,t){var e;r=X(r,t,3),t=-1;var u=n?n.length:0;if(typeof u=="number")for(;++t=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 C(n,r,t){if(!n)return n;for(var e=arguments,u=0,o=dr[typeof t]&&e[3]&&e[3][t]===r?2:e.length;++u"']/g,fr=/($^)/,ar=/['\n\r\t\u2028\u2029\\]/g,lr="[object Arguments]",cr="[object Array]",pr="[object Boolean]",sr="[object Date]",gr="[object Number]",hr="[object Object]",vr="[object RegExp]",yr="[object String]",mr={"&":"&","<":"<",">":">",'"':""","'":"'"},_r={"&":"&","<":"<",">":">",""":'"',"'":"'"},dr={"boolean":false,"function":false,object:false,number:true,string:true,undefined:false},br={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},wr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},jr=br[typeof window]&&window||this,xr=br[typeof exports]&&exports&&!exports.nodeType&&exports,Tr=br[typeof global]&&global; -!Tr||Tr.global!==Tr&&Tr.window!==Tr||(jr=Tr);var Ar=br[typeof module]&&module&&!module.nodeType&&module,Er=Ar&&Ar.exports===xr&&xr,Or=Array.prototype,Sr=Object.prototype,kr=jr._,Nr=Sr.toString,qr=RegExp("^"+(Nr+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Fr=Math.ceil,Br=Math.floor,Rr=Function.prototype.toString,$r=Sr.hasOwnProperty,Ir=Or.push,Mr=Sr.propertyIsEnumerable,Dr=Or.splice,Wr=_(Wr=Object.create)&&Wr,zr=_(zr=Array.isArray)&&zr,Cr=jr.isFinite,Pr=jr.isNaN,Ur=_(Ur=Object.keys)&&Ur,Vr=Math.max,Gr=Math.min,Hr=Math.random; +}function Y(n){return n}function Z(n){n||(n={});var r=rt(n);return function(t){for(var e=r.length,u=false;e--&&(u=t[r[e]]===n[r[e]]););return u}}function nr(n){for(var r=-1,t=V(n),e=t.length;++r"']/g,fr=/($^)/,ar=/['\n\r\t\u2028\u2029\\]/g,lr="[object Arguments]",cr="[object Array]",pr="[object Boolean]",sr="[object Date]",gr="[object Number]",hr="[object Object]",vr="[object RegExp]",yr="[object String]",mr={"&":"&","<":"<",">":">",'"':""","'":"'"},_r={"&":"&","<":"<",">":">",""":'"',"'":"'"},dr={"boolean":false,"function":false,object:false,number:true,string:true,undefined:false},br={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false},wr={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},jr=br[typeof window]&&window||this,xr=br[typeof exports]&&exports&&!exports.nodeType&&exports,Tr=br[typeof global]&&global; +!Tr||Tr.global!==Tr&&Tr.window!==Tr||(jr=Tr);var Ar=br[typeof module]&&module&&!module.nodeType&&module,Er=Ar&&Ar.exports===xr&&xr,Or=Array.prototype,kr=Object.prototype,Sr=jr._,Nr=kr.toString,qr=RegExp("^"+(Nr+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Fr=Math.ceil,Br=Math.floor,Rr=Function.prototype.toString,$r=kr.hasOwnProperty,Ir=Or.push,Mr=kr.propertyIsEnumerable,Dr=Or.splice,Wr=_(Wr=Object.create)&&Wr,zr=_(zr=Array.isArray)&&zr,Pr=jr.isFinite,Cr=jr.isNaN,Ur=_(Ur=Object.keys)&&Ur,Vr=Math.max,Gr=Math.min,Hr=Math.random; i.prototype=o.prototype;var Jr={};!function(){var n={0:1,length:1};Jr.spliceObjects=(Dr.call(n,0,1),!n[0])}(1),o.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Wr||(a=function(){function n(){}return function(r){if(J(r)){n.prototype=r;var t=new n;n.prototype=null}return t||jr.Object()}}()),d(arguments)||(d=function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&$r.call(n,"callee")&&!Mr.call(n,"callee")||false});var Kr=function(n){var r=[]; if(!n||!br[typeof n])return r;for(var t in n)$r.call(n,t)&&r.push(t);return r},Lr=v(function(n,r,t){$r.call(n,t)?n[t]++:n[t]=1}),Qr=v(function(n,r,t){$r.call(n,t)?n[t].push(r):n[t]=[r]}),Xr=v(function(n,r,t){n[t]=r}),Yr=F,Zr=function(n,r){if(!n||!br[typeof n])return n;for(var t in n)if(r(n[t],t,n)===ur)break;return n},nt=zr||function(n){return n&&typeof n=="object"&&typeof n.length=="number"&&Nr.call(n)==cr||false};H(/x/)&&(H=function(n){return typeof n=="function"&&"[object Function]"==Nr.call(n)}); var rt=Ur?function(n){return J(n)?Ur(n):[]}:Kr,tt=_(tt=Date.now)&&tt||function(){return(new Date).getTime()};o.after=function(n,r){if(!H(r))throw new TypeError;return function(){return 1>--n?r.apply(this,arguments):void 0}},o.bind=W,o.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},o.invert=function(n,r){for(var t=-1,e=rt(n),u=e.length,o={};++tr?0:r);++nt?Vr(0,e+t):Gr(t,e-1))+1);e--;)if(n[e]===r)return e; -return-1},o.mixin=nr,o.noConflict=function(){return jr._=kr,this},o.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Br(Hr()*(r-n+1))},o.reduce=R,o.reduceRight=$,o.result=function(n,r){if(n){var t=n[r];return H(t)?n[r]():t}},o.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:rt(n).length},o.some=M,o.sortedIndex=T,o.template=function(n,r,t){var u=o,i=u.templateSettings;n=(n||"")+"",t=P({},t,i);var f=0,a="__p+='",i=t.variable;n.replace(RegExp((t.escape||fr).source+"|"+(t.interpolate||fr).source+"|"+(t.evaluate||fr).source+"|$","g"),function(r,t,u,o,i){return a+=n.slice(f,i).replace(ar,e),t&&(a+="'+_.escape("+t+")+'"),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)(u)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},o.unescape=function(n){return null==n?"":(n+="",0>n.indexOf(";")?n:n.replace(or,u))},o.uniqueId=function(n){var r=++er+"";return n?n+r:r},o.all=O,o.any=M,o.detect=k,o.findWhere=function(n,r){return D(n,r,true)},o.foldl=R,o.foldr=$,o.include=E,o.inject=R,o.first=b,o.last=function(n,r,t){var e=0,u=n?n.length:0; -if(typeof r!="number"&&null!=r){var o=u;for(r=X(r,t,3);o--&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n?n[u-1]:tr;return e=u-e,x(n,0i(a,e)){for(r=t;--r;)if(0>i(n[r],e))continue n; +a.push(e)}return a},o.invert=function(n){for(var r=-1,t=rt(n),e=t.length,u={};++rr?0:r);++nt?Vr(0,e+t):Gr(t,e-1))+1);e--;)if(n[e]===r)return e;return-1},o.mixin=nr,o.noConflict=function(){return jr._=Sr,this},o.random=function(n,r){return null==n&&null==r&&(r=1),n=+n||0,null==r?(r=n,n=0):r=+r||0,n+Br(Hr()*(r-n+1)) +},o.reduce=R,o.reduceRight=$,o.result=function(n,r){if(n){var t=n[r];return H(t)?n[r]():t}},o.size=function(n){var r=n?n.length:0;return typeof r=="number"?r:rt(n).length},o.some=M,o.sortedIndex=T,o.template=function(n,r,t){var u=o,i=u.templateSettings;n=(n||"")+"",t=C({},t,i);var f=0,a="__p+='",i=t.variable;n.replace(RegExp((t.escape||fr).source+"|"+(t.interpolate||fr).source+"|"+(t.evaluate||fr).source+"|$","g"),function(r,t,u,o,i){return a+=n.slice(f,i).replace(ar,e),t&&(a+="'+_.escape("+t+")+'"),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)(u)}catch(c){throw c.source=a,c}return r?l(r):(l.source=a,l)},o.unescape=function(n){return null==n?"":(n+="",0>n.indexOf(";")?n:n.replace(or,u))},o.uniqueId=function(n){var r=++er+"";return n?n+r:r},o.all=O,o.any=M,o.detect=S,o.findWhere=function(n,r){return D(n,r,true)},o.foldl=R,o.foldr=$,o.include=E,o.inject=R,o.first=b,o.last=function(n,r,t){var e=0,u=n?n.length:0; +if(typeof r!="number"&&null!=r){var o=u;for(r=X(r,t,3);o--&&r(n[o],o,n);)e++}else if(e=r,null==e||t)return n?n[u-1]:tr;return e=u-e,x(n,0