diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 4c77260c8..f5d596e89 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -642,80 +642,25 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a function optimized to search large arrays for a given `value`, - * starting at `fromIndex`, using strict equality for comparisons, i.e. `===`. + * A basic version of `_.indexOf` without support for binary searches + * or `fromIndex` constraints. * * @private * @param {Array} array The array to search. * @param {Mixed} value The value to search for. - * @returns {Boolean} Returns `true`, if `value` is found, else `false`. + * @param {Number} [fromIndex=0] The index to search from. + * @returns {Number} Returns the index of the matched value or `-1`. */ - function createCache(array) { - var bailout, - index = -1, - length = array.length, - isLarge = length >= largeArraySize, - objCache = {}; + function basicIndexOf(array, value, fromIndex) { + var index = (fromIndex || 0) - 1, + length = array.length; - var caches = { - 'false': false, - 'function': false, - 'null': false, - 'number': {}, - 'object': objCache, - 'string': {}, - 'true': false, - 'undefined': false - }; - - function cacheContains(value) { - var type = typeof value; - if (type == 'boolean' || value == null) { - return caches[value]; - } - var cache = caches[type] || (type = 'object', objCache), - key = type == 'number' ? value : keyPrefix + value; - - return type == 'object' - ? (cache[key] ? indexOf(cache[key], value) > -1 : false) - : !!cache[key]; - } - - function cachePush(value) { - var type = typeof value; - if (type == 'boolean' || value == null) { - caches[value] = true; - } else { - var cache = caches[type] || (type = 'object', objCache), - key = type == 'number' ? value : keyPrefix + value; - - if (type == 'object') { - bailout = (cache[key] || (cache[key] = [])).push(value) == length; - } else { - cache[key] = true; - } + while (++index < length) { + if (array[index] === value) { + return index; } } - - function simpleContains(value) { - return indexOf(array, value) > -1; - } - - function simplePush(value) { - array.push(value); - } - - if (isLarge) { - while (++index < length) { - cachePush(array[index]); - } - if (bailout) { - isLarge = caches = objCache = null; - } - } - return isLarge - ? { 'contains': cacheContains, 'push': cachePush } - : { 'push': simplePush, 'contains' : simpleContains }; + return -1; } /** @@ -817,6 +762,85 @@ return bound; } + /** + * Creates a function optimized to search large arrays for a given `value`, + * starting at `fromIndex`, using strict equality for comparisons, i.e. `===`. + * + * @private + * @param {Array} [array=[]] The array to search. + * @param {Mixed} value The value to search for. + * @returns {Boolean} Returns `true`, if `value` is found, else `false`. + */ + function createCache(array) { + array || (array = []); + + var bailout, + index = -1, + length = array.length, + isLarge = length >= largeArraySize, + objCache = {}; + + var caches = { + 'false': false, + 'function': false, + 'null': false, + 'number': {}, + 'object': objCache, + 'string': {}, + 'true': false, + 'undefined': false + }; + + function basicContains(value) { + return basicIndexOf(array, value) > -1; + } + + function basicPush(value) { + array.push(value); + } + + function cacheContains(value) { + var type = typeof value; + if (type == 'boolean' || value == null) { + return caches[value]; + } + var cache = caches[type] || (type = 'object', objCache), + key = type == 'number' ? value : keyPrefix + value; + + return type == 'object' + ? (cache[key] ? basicIndexOf(cache[key], value) > -1 : false) + : !!cache[key]; + } + + function cachePush(value) { + var type = typeof value; + if (type == 'boolean' || value == null) { + caches[value] = true; + } else { + var cache = caches[type] || (type = 'object', objCache), + key = type == 'number' ? value : keyPrefix + value; + + if (type == 'object') { + bailout = (cache[key] || (cache[key] = [])).push(value) == length; + } else { + cache[key] = true; + } + } + } + + if (isLarge) { + while (++index < length) { + cachePush(array[index]); + } + if (bailout) { + isLarge = caches = objCache = null; + } + } + return isLarge + ? { 'contains': cacheContains, 'push': cachePush } + : { 'contains': basicContains, 'push': basicPush }; + } + /** * Creates compiled iteration functions. * @@ -891,6 +915,17 @@ }; } + /** + * Used by `escape` to convert characters to HTML entities. + * + * @private + * @param {String} match The matched character to escape. + * @returns {String} Returns the escaped character. + */ + function escapeHtmlChar(match) { + return htmlEscapes[match]; + } + /** * Used by `template` to escape characters for inclusion in compiled * string literals. @@ -903,17 +938,6 @@ return '\\' + stringEscapes[match]; } - /** - * Used by `escape` to convert characters to HTML entities. - * - * @private - * @param {String} match The matched character to escape. - * @returns {String} Returns the escaped character. - */ - function escapeHtmlChar(match) { - return htmlEscapes[match]; - } - /** * Checks if `value` is a DOM node in IE < 9. * @@ -949,6 +973,29 @@ // no operation performed } + /** + * Creates a function that juggles arguments, allowing argument overloading + * for `_.flatten` and `_.uniq`, before passing them to the given `func`. + * + * @private + * @param {Function} func The function to wrap. + * @returns {Function} Returns the new function. + */ + function overloadWrapper(func) { + return function(array, flag, callback, thisArg) { + // juggle arguments + if (typeof flag != 'boolean' && flag != null) { + thisArg = callback; + callback = !(thisArg && thisArg[flag] === array) ? flag : undefined; + flag = false; + } + if (callback != null) { + callback = lodash.createCallback(callback, thisArg); + } + return func(array, flag, callback, thisArg); + }; + } + /** * A fallback implementation of `isPlainObject` which checks if a given `value` * is an object created by the `Object` constructor, assuming objects created @@ -1131,7 +1178,7 @@ * @param {Mixed} [thisArg] The `this` binding of `callback`. * @returns {Array|Object|String} Returns `collection`. */ - var each = createIterator(eachIteratorOptions); + var basicEach = createIterator(eachIteratorOptions); /** * Used to convert characters to HTML entities: @@ -1316,7 +1363,7 @@ stackB.push(result); // recursively populate clone (susceptible to call stack limits) - (isArr ? each : forOwn)(value, function(objValue, key) { + (isArr ? basicEach : forOwn)(value, function(objValue, key) { result[key] = clone(objValue, deep, callback, undefined, stackA, stackB); }); @@ -2246,7 +2293,7 @@ forIn(object, function(value, key, object) { if (isFunc ? !callback(value, key, object) - : indexOf(props, key) < 0 + : basicIndexOf(props, key) < 0 ) { result[key] = value; } @@ -2374,7 +2421,7 @@ accumulator = createObject(proto); } } - (isArr ? each : forOwn)(object, function(value, index, object) { + (isArr ? basicEach : forOwn)(object, function(value, index, object) { return callback(accumulator, value, index, object); }); return accumulator; @@ -2476,13 +2523,13 @@ result = false; fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0; - if (typeof length == 'number') { + if (length && typeof length == 'number') { result = (isString(collection) ? collection.indexOf(target, fromIndex) - : indexOf(collection, target, fromIndex) + : basicIndexOf(collection, target, fromIndex) ) > -1; } else { - each(collection, function(value) { + basicEach(collection, function(value) { if (++index >= fromIndex) { return !(result = value === target); } @@ -2590,7 +2637,7 @@ } } } else { - each(collection, function(value, index, collection) { + basicEach(collection, function(value, index, collection) { return (result = !!callback(value, index, collection)); }); } @@ -2652,7 +2699,7 @@ } } } else { - each(collection, function(value, index, collection) { + basicEach(collection, function(value, index, collection) { if (callback(value, index, collection)) { result.push(value); } @@ -2719,7 +2766,7 @@ } } else { var result; - each(collection, function(value, index, collection) { + basicEach(collection, function(value, index, collection) { if (callback(value, index, collection)) { result = value; return false; @@ -2762,7 +2809,7 @@ } } } else { - each(collection, callback, thisArg); + basicEach(collection, callback, thisArg); } return collection; } @@ -2897,7 +2944,7 @@ result[index] = callback(collection[index], index, collection); } } else { - each(collection, function(value, key, collection) { + basicEach(collection, function(value, key, collection) { result[++index] = callback(value, key, collection); }); } @@ -2962,7 +3009,7 @@ ? charAtCallback : lodash.createCallback(callback, thisArg); - each(collection, function(value, index, collection) { + basicEach(collection, function(value, index, collection) { var current = callback(value, index, collection); if (current > computed) { computed = current; @@ -3031,7 +3078,7 @@ ? charAtCallback : lodash.createCallback(callback, thisArg); - each(collection, function(value, index, collection) { + basicEach(collection, function(value, index, collection) { var current = callback(value, index, collection); if (current < computed) { computed = current; @@ -3109,7 +3156,7 @@ accumulator = callback(accumulator, collection[index], index, collection); } } else { - each(collection, function(value, index, collection) { + basicEach(collection, function(value, index, collection) { accumulator = noaccum ? (noaccum = false, value) : callback(accumulator, value, index, collection) @@ -3312,7 +3359,7 @@ } } } else { - each(collection, function(value, index, collection) { + basicEach(collection, function(value, index, collection) { return !(result = callback(value, index, collection)); }); } @@ -3637,20 +3684,11 @@ * _.flatten(stooges, 'quotes'); * // => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!'] */ - function flatten(array, isShallow, callback, thisArg) { + var flatten = overloadWrapper(function flatten(array, isShallow, callback) { var index = -1, length = array ? array.length : 0, result = []; - // juggle arguments - if (typeof isShallow != 'boolean' && isShallow != null) { - thisArg = callback; - callback = !(thisArg && thisArg[isShallow] === array) ? isShallow : undefined; - isShallow = false; - } - if (callback != null) { - callback = lodash.createCallback(callback, thisArg); - } while (++index < length) { var value = array[index]; if (callback) { @@ -3664,7 +3702,7 @@ } } return result; - } + }); /** * Gets the index at which the first occurrence of `value` is found using @@ -3691,21 +3729,14 @@ * // => 2 */ function indexOf(array, value, fromIndex) { - var index = -1, - length = array ? array.length : 0; - if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0) - 1; + var length = array ? array.length : 0; + fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0); } else if (fromIndex) { - index = sortedIndex(array, value); + var index = sortedIndex(array, value); return array[index] === value ? index : -1; } - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; + return array ? basicIndexOf(array, value, fromIndex) : -1; } /** @@ -3801,7 +3832,7 @@ function intersection(array) { var args = arguments, argsLength = args.length, - cache = createCache([]), + cache = createCache(), caches = {}, index = -1, length = array ? array.length : 0, @@ -4150,7 +4181,7 @@ * Creates a duplicate-value-free version of the `array` using strict equality * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` * for `isSorted` will run a faster algorithm. If `callback` is passed, each - * element of `array` is passed through a `callback` before uniqueness is computed. + * element of `array` is passed through the `callback` before uniqueness is computed. * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is passed for `callback`, the created "_.pluck" style @@ -4179,44 +4210,30 @@ * _.uniq([1, 1, 2, 2, 3], true); * // => [1, 2, 3] * - * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); }); - * // => [1, 2, 3] + * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); + * // => ['A', 'b', 'C'] * - * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); - * // => [1, 2, 3] + * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); + * // => [1, 2.5, 3] * * // using "_.pluck" callback shorthand * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ - function uniq(array, isSorted, callback, thisArg) { + var uniq = overloadWrapper(function(array, isSorted, callback) { var index = -1, length = array ? array.length : 0, + isLarge = !isSorted && length >= largeArraySize, result = [], - seen = result; + seen = isLarge ? createCache() : (callback ? [] : result); - // juggle arguments - if (typeof isSorted != 'boolean' && isSorted != null) { - thisArg = callback; - callback = !(thisArg && thisArg[isSorted] === array) ? isSorted : undefined; - isSorted = false; - } - // init value cache for large arrays - var isLarge = !isSorted && length >= largeArraySize; - if (callback != null) { - seen = []; - callback = lodash.createCallback(callback, thisArg); - } - if (isLarge) { - seen = createCache([]); - } while (++index < length) { var value = array[index], computed = callback ? callback(value, index, array) : value; if (isSorted ? !index || seen[seen.length - 1] !== computed - : (isLarge ? !seen.contains(computed) : indexOf(seen, computed) < 0) + : (isLarge ? !seen.contains(computed) : basicIndexOf(seen, computed) < 0) ) { if (callback || isLarge) { seen.push(computed); @@ -4225,7 +4242,7 @@ } } return result; - } + }); /** * The inverse of `_.zip`, this method splits groups of elements into arrays @@ -5608,7 +5625,7 @@ lodash.prototype.valueOf = wrapperValueOf; // add `Array` functions that return unwrapped values - each(['join', 'pop', 'shift'], function(methodName) { + basicEach(['join', 'pop', 'shift'], function(methodName) { var func = arrayProto[methodName]; lodash.prototype[methodName] = function() { return func.apply(this.__wrapped__, arguments); @@ -5616,7 +5633,7 @@ }); // add `Array` functions that return the wrapped value - each(['push', 'reverse', 'sort', 'unshift'], function(methodName) { + basicEach(['push', 'reverse', 'sort', 'unshift'], function(methodName) { var func = arrayProto[methodName]; lodash.prototype[methodName] = function() { func.apply(this.__wrapped__, arguments); @@ -5625,7 +5642,7 @@ }); // add `Array` functions that return new wrapped values - each(['concat', 'slice', 'splice'], function(methodName) { + basicEach(['concat', 'slice', 'splice'], function(methodName) { var func = arrayProto[methodName]; lodash.prototype[methodName] = function() { return new lodashWrapper(func.apply(this.__wrapped__, arguments)); @@ -5635,7 +5652,7 @@ // avoid array-like object bugs with `Array#shift` and `Array#splice` // in Firefox < 10 and IE < 9 if (!support.spliceObjects) { - each(['pop', 'shift', 'splice'], function(methodName) { + basicEach(['pop', 'shift', 'splice'], function(methodName) { var func = arrayProto[methodName], isSplice = methodName == 'splice'; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index fe35378b6..672016f21 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,46 +4,46 @@ * Build: `lodash -o ./dist/lodash.compat.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;!function(n){function t(e){function a(n){return n&&typeof n=="object"&&!Sr(n)&&er.call(n,"__wrapped__")?n:new Q(n)}function T(n){function t(n){var t=typeof n;if("boolean"==t||null==n)return s[n];var r=s[t]||(t="object",p),e="number"==t?n:l+n;return"object"==t?r[e]?-1=c,p={},s={"false":!1,"function":!1,"null":!1,number:{},object:p,string:{},"true":!1,undefined:!1};if(f){for(;++ot||typeof n=="undefined")return 1;if(nk;k++)e+="m='"+t.g[k]+"';if((!(p&&v[m])&&l.call(r,m))",t.i||(e+="||(!v[m]&&r[m]!==y[m])"),e+="){"+t.f+"}"; -e+="}"}return(t.b||kr.nonEnumArgs)&&(e+="}"),e+=t.c+";return C",n("i,j,l,n,o,q,t,u,y,z,w,G,H,J",r+e+"}")(I,Mt,er,nt,Sr,lt,Ir,a,Ut,q,wr,F,Vt,lr)}function K(n){return ot(n)?fr(n):{}}function M(n){return"\\"+D[n]}function U(n){return Nr[n]}function V(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function Q(n){this.__wrapped__=n}function W(){}function X(n){var t=!1;if(!n||lr.call(n)!=P||!kr.argsClass&&nt(n))return t;var r=n.constructor;return(at(r)?r instanceof r:kr.nodeClass||!V(n))?kr.ownLast?($r(n,function(n,r,e){return t=er.call(e,r),!1 -}),!0===t):($r(n,function(n,r){t=r}),!1===t||er.call(n,t)):t}function Y(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=Ft(0>r?0:r);++er?hr(0,u+r):r)||0,typeof u=="number"?a=-1<(lt(n)?n.indexOf(t,r):kt(n,t,r)):Br(n,function(n){return++eu&&(u=i)}}else t=!t&<(n)?L:a.createCallback(t,r),Br(n,function(n,r,a){r=t(n,r,a),r>e&&(e=r,u=n) -});return u}function dt(n,t,r,e){var u=3>arguments.length;if(t=a.createCallback(t,e,4),Sr(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var l=Ir(n),o=l.length;else kr.unindexedChars&<(n)&&(u=n.split(""));return t=a.createCallback(t,e,4),ht(n,function(n,e,a){e=l?l[--o]:--o,r=i?(i=!1,u[e]):t(r,u[e],e,a)}),r}function _t(n,t,r){var e; -if(t=a.createCallback(t,r),Sr(n)){r=-1;for(var u=n.length;++rr?hr(0,u+r):r||0)-1;else if(r)return e=Et(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])=c;for(null!=e&&(f=[],e=a.createCallback(e,u)),p&&(f=T([]));++or?0:r);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:y,variable:"",imports:{_:a}};var xr={a:"x,F,k",h:"var a=arguments,b=0,c=typeof k=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Pr=et(Nr),zr=J(xr,{h:xr.h.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=u.createCallback(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){d=a[--c]}"),f:"C[m]=d?d(C[m],r[m]):r[m]"}),Fr=J(xr),$r=J(Er,Or,{i:!1}),qr=J(Er,Or); -at(/x/)&&(at=function(n){return typeof n=="function"&&lr.call(n)==B});var Dr=rr?function(n){if(!n||lr.call(n)!=P||!kr.argsClass&&nt(n))return!1;var t=n.valueOf,r=typeof t=="function"&&(r=rr(t))&&rr(r);return r?n==r||rr(n)==r:X(n)}:X,Rr=yt;Cr&&u&&typeof or=="function"&&(Bt=It(or,e));var Tr=8==mr(d+"08")?mr:function(n,t){return mr(lt(n)?n.replace(b,""):n,t||0)};return a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=zr,a.at=function(n){var t=-1,r=Zt.apply(Kt,br.call(arguments,1)),e=r.length,u=Ft(e); -for(kr.unindexedChars&<(n)&&(n=n.split(""));++t++i&&(a=n.apply(o,u)),l=ir(e,t),a}},a.defaults=Fr,a.defer=Bt,a.delay=function(n,t){var e=br.call(arguments,2);return ir(function(){n.apply(r,e)},t)},a.difference=Ct,a.filter=gt,a.flatten=wt,a.forEach=ht,a.forIn=$r,a.forOwn=qr,a.functions=rt,a.groupBy=function(n,t,r){var e={}; -return t=a.createCallback(t,r),ht(n,function(n,r,u){r=Ht(t(n,r,u)),(er.call(e,r)?e[r]:e[r]=[]).push(n)}),e},a.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,r);o--&&t(n[o],o,n);)e++}else e=null==t||r?1:t||e;return Y(n,0,yr(hr(0,u-e),u))},a.intersection=function(n){var t=arguments,r=t.length,e=T([]),u={},a=-1,o=n?n.length:0,i=[];n:for(;++akt(o,r))&&(u[r]=n)}),u},a.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},a.pairs=function(n){for(var t=-1,r=Ir(n),e=r.length,u=Ft(e);++tr?hr(0,e+r):yr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},a.mixin=Pt,a.noConflict=function(){return e._=Qt,this},a.parseInt=Tr,a.random=function(n,t){null==n&&null==t&&(t=1),n=+n||0,null==t?(t=n,n=0):t=+t||0;var r=dr();return n%1||t%1?n+yr(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+nr(r*(t-n+1))},a.reduce=dt,a.reduceRight=bt,a.result=function(n,t){var e=n?n[t]:r; -return at(e)?n[t]():e},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Ir(n).length},a.some=_t,a.sortedIndex=Et,a.template=function(n,t,e){var u=a.templateSettings;n||(n=""),e=Fr({},e,u);var o,i=Fr({},e.imports,u.imports),u=Ir(i),i=ft(i),l=0,c=e.interpolate||_,g="__p+='",c=Gt((e.escape||_).source+"|"+c.source+"|"+(c===y?v:_).source+"|"+(e.evaluate||_).source+"|$","g");n.replace(c,function(t,r,e,u,a,i){return e||(e=u),g+=n.slice(l,i).replace(j,M),r&&(g+="'+__e("+r+")+'"),a&&(o=!0,g+="';"+a+";__p+='"),e&&(g+="'+((__t=("+e+"))==null?'':__t)+'"),l=i+t.length,t -}),g+="';\n",c=e=e.variable,c||(e="obj",g="with("+e+"){"+g+"}"),g=(o?g.replace(f,""):g).replace(p,"$1").replace(s,"$1;"),g="function("+e+"){"+(c?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+g+"return __p}";try{var h=Dt(u,"return "+g).apply(r,i)}catch(m){throw m.source=g,m}return t?h(t):(h.source=g,h)},a.unescape=function(n){return null==n?"":Ht(n).replace(g,Z)},a.uniqueId=function(n){var t=++o;return Ht(null==n?"":n)+t -},a.all=st,a.any=_t,a.detect=vt,a.foldl=dt,a.foldr=bt,a.include=pt,a.inject=dt,qr(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return ur.apply(t,arguments),n.apply(a,t)})}),a.first=jt,a.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n[u-1];return Y(n,hr(0,u-e))}},a.take=jt,a.head=jt,qr(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,r){var e=n(this.__wrapped__,t,r); -return null==t||r&&typeof t!="function"?e:new Q(e)})}),a.VERSION="1.2.1",a.prototype.toString=function(){return Ht(this.__wrapped__)},a.prototype.value=zt,a.prototype.valueOf=zt,Br(["join","pop","shift"],function(n){var t=Kt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Br(["push","reverse","sort","unshift"],function(n){var t=Kt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Br(["concat","slice","splice"],function(n){var t=Kt[n];a.prototype[n]=function(){return new Q(t.apply(this.__wrapped__,arguments)) -}}),kr.spliceObjects||Br(["pop","shift","splice"],function(n){var t=Kt[n],r="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,e=t.apply(n,arguments);return 0===n.length&&delete n[0],r?new Q(e):e}}),a}var r,e=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==e&&module,a=typeof global=="object"&&global;(a.global===a||a.window===a)&&(n=a);var o=0,i={},l=+new Date+"",c=75,f=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,g=/&(?:amp|lt|gt|quot|#39);/g,v=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/\w*$/,y=/<%=([\s\S]+?)%>/g,m=(m=/\bthis\b/)&&m.test(t)&&m,d=" \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",b=RegExp("^["+d+"]*0+(?=.$)"),_=/($^)/,C=/[&<>"']/g,j=/['\n\r\t\u2028\u2029\\]/g,w="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),E="[object Arguments]",O="[object Array]",S="[object Boolean]",A="[object Date]",I="[object Error]",B="[object Function]",N="[object Number]",P="[object Object]",z="[object RegExp]",F="[object String]",$={}; +;!function(n){function t(e){function a(n){return n&&typeof n=="object"&&!Or(n)&&rr.call(n,"__wrapped__")?n:new W(n)}function T(n,t,r){r=(r||0)-1;for(var e=n.length;++rt||typeof n=="undefined")return 1;if(n=l,p={},s={"false":!1,"function":!1,"null":!1,number:{},object:p,string:{},"true":!1,undefined:!1}; +if(f){for(;++ok;k++)e+="m='"+t.g[k]+"';if((!(p&&v[m])&&l.call(r,m))",t.i||(e+="||(!v[m]&&r[m]!==y[m])"),e+="){"+t.f+"}"; +e+="}"}return(t.b||wr.nonEnumArgs)&&(e+="}"),e+=t.c+";return C",n("i,j,l,n,o,q,t,u,y,z,w,G,H,J",r+e+"}")(I,Kt,rr,rt,Or,ft,Ar,a,Mt,q,jr,F,Ut,ir)}function M(n){return ct(n)?lr(n):{}}function U(n){return Br[n]}function V(n){return"\\"+D[n]}function Q(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function W(n){this.__wrapped__=n}function X(){}function Y(n){return function(t,e,u,o){return typeof e!="boolean"&&null!=e&&(o=u,u=o&&o[e]===t?r:e,e=!1),null!=u&&(u=a.createCallback(u,o)),n(t,e,u,o) +}}function Z(n){var t=!1;if(!n||ir.call(n)!=P||!wr.argsClass&&rt(n))return t;var r=n.constructor;return(it(r)?r instanceof r:wr.nodeClass||!Q(n))?wr.ownLast?(Fr(n,function(n,r,e){return t=rr.call(e,r),!1}),!0===t):(Fr(n,function(n,r){t=r}),!1===t||rr.call(n,t)):t}function nt(n,t,r){t||(t=0),typeof r=="undefined"&&(r=n?n.length:0);var e=-1;r=r-t||0;for(var u=zt(0>r?0:r);++er?vr(0,u+r):r)||0,u&&typeof u=="number"?a=-1<(ft(n)?n.indexOf(t,r):T(n,t,r)):Ir(n,function(n){return++eu&&(u=i)}}else t=!t&&ft(n)?L:a.createCallback(t,r),Ir(n,function(n,r,a){r=t(n,r,a),r>e&&(e=r,u=n)});return u}function _t(n,t,r,e){var u=3>arguments.length;if(t=a.createCallback(t,e,4),Or(n)){var o=-1,i=n.length;for(u&&(r=n[++o]);++oarguments.length;if(typeof o!="number")var c=Ar(n),o=c.length;else wr.unindexedChars&&ft(n)&&(u=n.split(""));return t=a.createCallback(t,e,4),mt(n,function(n,e,a){e=c?c[--o]:--o,r=i?(i=!1,u[e]):t(r,u[e],e,a)}),r}function jt(n,t,r){var e;if(t=a.createCallback(t,r),Or(n)){r=-1;for(var u=n.length;++r>>1,r(n[e])r?0:r);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:y,variable:"",imports:{_:a}};var kr={a:"x,F,k",h:"var a=arguments,b=0,c=typeof k=='number'?2:a.length;while(++b":">",'"':""","'":"'"},Nr=at(Br),Pr=K(kr,{h:kr.h.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=u.createCallback(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){d=a[--c]}"),f:"C[m]=d?d(C[m],r[m]):r[m]"}),zr=K(kr),Fr=K(xr,Er,{i:!1}),$r=K(xr,Er); +it(/x/)&&(it=function(n){return typeof n=="function"&&ir.call(n)==B});var qr=tr?function(n){if(!n||ir.call(n)!=P||!wr.argsClass&&rt(n))return!1;var t=n.valueOf,r=typeof t=="function"&&(r=tr(t))&&tr(r);return r?n==r||tr(n)==r:Z(n)}:Z,Dr=dt,Rr=Y(function Gr(n,t,r){for(var e=-1,u=n?n.length:0,a=[];++e=l,o=[],i=a?J():r?[]:o;++en?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=Pr,a.at=function(n){var t=-1,r=Yt.apply(Jt,dr.call(arguments,1)),e=r.length,u=zt(e);for(wr.unindexedChars&&ft(n)&&(n=n.split(""));++t++i&&(a=n.apply(o,u)),c=or(e,t),a}},a.defaults=zr,a.defer=It,a.delay=function(n,t){var e=dr.call(arguments,2);return or(function(){n.apply(r,e)},t)},a.difference=wt,a.filter=ht,a.flatten=Rr,a.forEach=mt,a.forIn=Fr,a.forOwn=$r,a.functions=ut,a.groupBy=function(n,t,r){var e={};return t=a.createCallback(t,r),mt(n,function(n,r,u){r=Gt(t(n,r,u)),(rr.call(e,r)?e[r]:e[r]=[]).push(n) +}),e},a.initial=function(n,t,r){if(!n)return[];var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,r);o--&&t(n[o],o,n);)e++}else e=null==t||r?1:t||e;return nt(n,0,hr(vr(0,u-e),u))},a.intersection=function(n){var t=arguments,r=t.length,e=J(),u={},a=-1,o=n?n.length:0,i=[];n:for(;++aT(o,r))&&(u[r]=n)}),u},a.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},a.pairs=function(n){for(var t=-1,r=Ar(n),e=r.length,u=zt(e);++tr?vr(0,e+r):r||0}else if(r)return r=Et(n,t),n[r]===t?r:-1;return n?T(n,t,r):-1},a.isArguments=rt,a.isArray=Or,a.isBoolean=function(n){return!0===n||!1===n||ir.call(n)==S},a.isDate=function(n){return n?typeof n=="object"&&ir.call(n)==A:!1 +},a.isElement=function(n){return n?1===n.nodeType:!1},a.isEmpty=function(n){var t=!0;if(!n)return t;var r=ir.call(n),e=n.length;return r==O||r==F||(wr.argsClass?r==E:rt(n))||r==P&&typeof e=="number"&&it(n.splice)?!e:($r(n,function(){return t=!1}),t)},a.isEqual=ot,a.isFinite=function(n){return pr(n)&&!sr(parseFloat(n))},a.isFunction=it,a.isNaN=function(n){return lt(n)&&n!=+n},a.isNull=function(n){return null===n},a.isNumber=lt,a.isObject=ct,a.isPlainObject=qr,a.isRegExp=function(n){return!(!n||!q[typeof n])&&ir.call(n)==z +},a.isString=ft,a.isUndefined=function(n){return typeof n=="undefined"},a.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?vr(0,e+r):hr(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},a.mixin=Nt,a.noConflict=function(){return e._=Vt,this},a.parseInt=Lr,a.random=function(n,t){null==n&&null==t&&(t=1),n=+n||0,null==t?(t=n,n=0):t=+t||0;var r=mr();return n%1||t%1?n+hr(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+Zt(r*(t-n+1))},a.reduce=_t,a.reduceRight=Ct,a.result=function(n,t){var e=n?n[t]:r; +return it(e)?n[t]():e},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Ar(n).length},a.some=jt,a.sortedIndex=Et,a.template=function(n,t,e){var u=a.templateSettings;n||(n=""),e=zr({},e,u);var o,i=zr({},e.imports,u.imports),u=Ar(i),i=st(i),c=0,l=e.interpolate||_,g="__p+='",l=Lt((e.escape||_).source+"|"+l.source+"|"+(l===y?v:_).source+"|"+(e.evaluate||_).source+"|$","g");n.replace(l,function(t,r,e,u,a,i){return e||(e=u),g+=n.slice(c,i).replace(j,V),r&&(g+="'+__e("+r+")+'"),a&&(o=!0,g+="';"+a+";__p+='"),e&&(g+="'+((__t=("+e+"))==null?'':__t)+'"),c=i+t.length,t +}),g+="';\n",l=e=e.variable,l||(e="obj",g="with("+e+"){"+g+"}"),g=(o?g.replace(f,""):g).replace(p,"$1").replace(s,"$1;"),g="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+g+"return __p}";try{var h=qt(u,"return "+g).apply(r,i)}catch(m){throw m.source=g,m}return t?h(t):(h.source=g,h)},a.unescape=function(n){return null==n?"":Gt(n).replace(g,tt)},a.uniqueId=function(n){var t=++o;return Gt(null==n?"":n)+t +},a.all=vt,a.any=jt,a.detect=yt,a.foldl=_t,a.foldr=Ct,a.include=gt,a.inject=_t,$r(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return er.apply(t,arguments),n.apply(a,t)})}),a.first=kt,a.last=function(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n[u-1];return nt(n,vr(0,u-e))}},a.take=kt,a.head=kt,$r(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,r){var e=n(this.__wrapped__,t,r); +return null==t||r&&typeof t!="function"?e:new W(e)})}),a.VERSION="1.2.1",a.prototype.toString=function(){return Gt(this.__wrapped__)},a.prototype.value=Pt,a.prototype.valueOf=Pt,Ir(["join","pop","shift"],function(n){var t=Jt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Ir(["push","reverse","sort","unshift"],function(n){var t=Jt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ir(["concat","slice","splice"],function(n){var t=Jt[n];a.prototype[n]=function(){return new W(t.apply(this.__wrapped__,arguments)) +}}),wr.spliceObjects||Ir(["pop","shift","splice"],function(n){var t=Jt[n],r="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,e=t.apply(n,arguments);return 0===n.length&&delete n[0],r?new W(e):e}}),a}var r,e=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==e&&module,a=typeof global=="object"&&global;(a.global===a||a.window===a)&&(n=a);var o=0,i={},c=+new Date+"",l=75,f=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,g=/&(?:amp|lt|gt|quot|#39);/g,v=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/\w*$/,y=/<%=([\s\S]+?)%>/g,m=(m=/\bthis\b/)&&m.test(t)&&m,d=" \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",b=RegExp("^["+d+"]*0+(?=.$)"),_=/($^)/,C=/[&<>"']/g,j=/['\n\r\t\u2028\u2029\\]/g,w="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),E="[object Arguments]",O="[object Array]",S="[object Boolean]",A="[object Date]",I="[object Error]",B="[object Function]",N="[object Number]",P="[object Object]",z="[object RegExp]",F="[object String]",$={}; $[B]=!1,$[E]=$[O]=$[S]=$[A]=$[N]=$[P]=$[z]=$[F]=!0;var q={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},D={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},R=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=R, define(function(){return R})):e&&!e.nodeType?u?(u.exports=R)._=R:e._=R:n._=R}(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index dc0889f24..12edb8893 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -372,80 +372,25 @@ /*--------------------------------------------------------------------------*/ /** - * Creates a function optimized to search large arrays for a given `value`, - * starting at `fromIndex`, using strict equality for comparisons, i.e. `===`. + * A basic version of `_.indexOf` without support for binary searches + * or `fromIndex` constraints. * * @private * @param {Array} array The array to search. * @param {Mixed} value The value to search for. - * @returns {Boolean} Returns `true`, if `value` is found, else `false`. + * @param {Number} [fromIndex=0] The index to search from. + * @returns {Number} Returns the index of the matched value or `-1`. */ - function createCache(array) { - var bailout, - index = -1, - length = array.length, - isLarge = length >= largeArraySize, - objCache = {}; + function basicIndexOf(array, value, fromIndex) { + var index = (fromIndex || 0) - 1, + length = array.length; - var caches = { - 'false': false, - 'function': false, - 'null': false, - 'number': {}, - 'object': objCache, - 'string': {}, - 'true': false, - 'undefined': false - }; - - function cacheContains(value) { - var type = typeof value; - if (type == 'boolean' || value == null) { - return caches[value]; - } - var cache = caches[type] || (type = 'object', objCache), - key = type == 'number' ? value : keyPrefix + value; - - return type == 'object' - ? (cache[key] ? indexOf(cache[key], value) > -1 : false) - : !!cache[key]; - } - - function cachePush(value) { - var type = typeof value; - if (type == 'boolean' || value == null) { - caches[value] = true; - } else { - var cache = caches[type] || (type = 'object', objCache), - key = type == 'number' ? value : keyPrefix + value; - - if (type == 'object') { - bailout = (cache[key] || (cache[key] = [])).push(value) == length; - } else { - cache[key] = true; - } + while (++index < length) { + if (array[index] === value) { + return index; } } - - function simpleContains(value) { - return indexOf(array, value) > -1; - } - - function simplePush(value) { - array.push(value); - } - - if (isLarge) { - while (++index < length) { - cachePush(array[index]); - } - if (bailout) { - isLarge = caches = objCache = null; - } - } - return isLarge - ? { 'contains': cacheContains, 'push': cachePush } - : { 'push': simplePush, 'contains' : simpleContains }; + return -1; } /** @@ -547,6 +492,85 @@ return bound; } + /** + * Creates a function optimized to search large arrays for a given `value`, + * starting at `fromIndex`, using strict equality for comparisons, i.e. `===`. + * + * @private + * @param {Array} [array=[]] The array to search. + * @param {Mixed} value The value to search for. + * @returns {Boolean} Returns `true`, if `value` is found, else `false`. + */ + function createCache(array) { + array || (array = []); + + var bailout, + index = -1, + length = array.length, + isLarge = length >= largeArraySize, + objCache = {}; + + var caches = { + 'false': false, + 'function': false, + 'null': false, + 'number': {}, + 'object': objCache, + 'string': {}, + 'true': false, + 'undefined': false + }; + + function basicContains(value) { + return basicIndexOf(array, value) > -1; + } + + function basicPush(value) { + array.push(value); + } + + function cacheContains(value) { + var type = typeof value; + if (type == 'boolean' || value == null) { + return caches[value]; + } + var cache = caches[type] || (type = 'object', objCache), + key = type == 'number' ? value : keyPrefix + value; + + return type == 'object' + ? (cache[key] ? basicIndexOf(cache[key], value) > -1 : false) + : !!cache[key]; + } + + function cachePush(value) { + var type = typeof value; + if (type == 'boolean' || value == null) { + caches[value] = true; + } else { + var cache = caches[type] || (type = 'object', objCache), + key = type == 'number' ? value : keyPrefix + value; + + if (type == 'object') { + bailout = (cache[key] || (cache[key] = [])).push(value) == length; + } else { + cache[key] = true; + } + } + } + + if (isLarge) { + while (++index < length) { + cachePush(array[index]); + } + if (bailout) { + isLarge = caches = objCache = null; + } + } + return isLarge + ? { 'contains': cacheContains, 'push': cachePush } + : { 'contains': basicContains, 'push': basicPush }; + } + /** * Creates a new object with the specified `prototype`. * @@ -558,6 +582,17 @@ return isObject(prototype) ? nativeCreate(prototype) : {}; } + /** + * Used by `escape` to convert characters to HTML entities. + * + * @private + * @param {String} match The matched character to escape. + * @returns {String} Returns the escaped character. + */ + function escapeHtmlChar(match) { + return htmlEscapes[match]; + } + /** * Used by `template` to escape characters for inclusion in compiled * string literals. @@ -570,17 +605,6 @@ return '\\' + stringEscapes[match]; } - /** - * Used by `escape` to convert characters to HTML entities. - * - * @private - * @param {String} match The matched character to escape. - * @returns {String} Returns the escaped character. - */ - function escapeHtmlChar(match) { - return htmlEscapes[match]; - } - /** * A fast path for creating `lodash` wrapper objects. * @@ -603,6 +627,29 @@ // no operation performed } + /** + * Creates a function that juggles arguments, allowing argument overloading + * for `_.flatten` and `_.uniq`, before passing them to the given `func`. + * + * @private + * @param {Function} func The function to wrap. + * @returns {Function} Returns the new function. + */ + function overloadWrapper(func) { + return function(array, flag, callback, thisArg) { + // juggle arguments + if (typeof flag != 'boolean' && flag != null) { + thisArg = callback; + callback = !(thisArg && thisArg[flag] === array) ? flag : undefined; + flag = false; + } + if (callback != null) { + callback = lodash.createCallback(callback, thisArg); + } + return func(array, flag, callback, thisArg); + }; + } + /** * A fallback implementation of `isPlainObject` which checks if a given `value` * is an object created by the `Object` constructor, assuming objects created @@ -1915,7 +1962,7 @@ forIn(object, function(value, key, object) { if (isFunc ? !callback(value, key, object) - : indexOf(props, key) < 0 + : basicIndexOf(props, key) < 0 ) { result[key] = value; } @@ -2142,10 +2189,10 @@ result = false; fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0; - if (typeof length == 'number') { + if (length && typeof length == 'number') { result = (isString(collection) ? collection.indexOf(target, fromIndex) - : indexOf(collection, target, fromIndex) + : basicIndexOf(collection, target, fromIndex) ) > -1; } else { forOwn(collection, function(value) { @@ -3313,20 +3360,11 @@ * _.flatten(stooges, 'quotes'); * // => ['Oh, a wise guy, eh?', 'Poifect!', 'Spread out!', 'You knucklehead!'] */ - function flatten(array, isShallow, callback, thisArg) { + var flatten = overloadWrapper(function flatten(array, isShallow, callback) { var index = -1, length = array ? array.length : 0, result = []; - // juggle arguments - if (typeof isShallow != 'boolean' && isShallow != null) { - thisArg = callback; - callback = !(thisArg && thisArg[isShallow] === array) ? isShallow : undefined; - isShallow = false; - } - if (callback != null) { - callback = lodash.createCallback(callback, thisArg); - } while (++index < length) { var value = array[index]; if (callback) { @@ -3340,7 +3378,7 @@ } } return result; - } + }); /** * Gets the index at which the first occurrence of `value` is found using @@ -3367,21 +3405,14 @@ * // => 2 */ function indexOf(array, value, fromIndex) { - var index = -1, - length = array ? array.length : 0; - if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0) - 1; + var length = array ? array.length : 0; + fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0); } else if (fromIndex) { - index = sortedIndex(array, value); + var index = sortedIndex(array, value); return array[index] === value ? index : -1; } - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; + return array ? basicIndexOf(array, value, fromIndex) : -1; } /** @@ -3477,7 +3508,7 @@ function intersection(array) { var args = arguments, argsLength = args.length, - cache = createCache([]), + cache = createCache(), caches = {}, index = -1, length = array ? array.length : 0, @@ -3826,7 +3857,7 @@ * Creates a duplicate-value-free version of the `array` using strict equality * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` * for `isSorted` will run a faster algorithm. If `callback` is passed, each - * element of `array` is passed through a `callback` before uniqueness is computed. + * element of `array` is passed through the `callback` before uniqueness is computed. * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is passed for `callback`, the created "_.pluck" style @@ -3855,44 +3886,30 @@ * _.uniq([1, 1, 2, 2, 3], true); * // => [1, 2, 3] * - * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); }); - * // => [1, 2, 3] + * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); + * // => ['A', 'b', 'C'] * - * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); - * // => [1, 2, 3] + * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); + * // => [1, 2.5, 3] * * // using "_.pluck" callback shorthand * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); * // => [{ 'x': 1 }, { 'x': 2 }] */ - function uniq(array, isSorted, callback, thisArg) { + var uniq = overloadWrapper(function(array, isSorted, callback) { var index = -1, length = array ? array.length : 0, + isLarge = !isSorted && length >= largeArraySize, result = [], - seen = result; + seen = isLarge ? createCache() : (callback ? [] : result); - // juggle arguments - if (typeof isSorted != 'boolean' && isSorted != null) { - thisArg = callback; - callback = !(thisArg && thisArg[isSorted] === array) ? isSorted : undefined; - isSorted = false; - } - // init value cache for large arrays - var isLarge = !isSorted && length >= largeArraySize; - if (callback != null) { - seen = []; - callback = lodash.createCallback(callback, thisArg); - } - if (isLarge) { - seen = createCache([]); - } while (++index < length) { var value = array[index], computed = callback ? callback(value, index, array) : value; if (isSorted ? !index || seen[seen.length - 1] !== computed - : (isLarge ? !seen.contains(computed) : indexOf(seen, computed) < 0) + : (isLarge ? !seen.contains(computed) : basicIndexOf(seen, computed) < 0) ) { if (callback || isLarge) { seen.push(computed); @@ -3901,7 +3918,7 @@ } } return result; - } + }); /** * The inverse of `_.zip`, this method splits groups of elements into arrays diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 2d198d4dd..73046f97f 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,42 +4,42 @@ * Build: `lodash modern -o ./dist/lodash.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;!function(n){function t(o){function f(n){if(!n||ie.call(n)!=B)return a;var t=n.valueOf,e=typeof t=="function"&&(e=ee(t))&&ee(e);return e?n==e||ee(n)==e:Z(n)}function P(n,t,e){if(!n||!q[typeof n])return n;t=t&&typeof e=="undefined"?t:G.createCallback(t,e);for(var r=-1,u=q[typeof n]?je(n):[],o=u.length;++r=s,g={},y={"false":a,"function":a,"null":a,number:{},object:g,string:{},"true":a,undefined:a};if(v){for(;++ct||typeof n=="undefined")return 1;if(ne?0:e);++re?ge(0,u+e):e)||0,typeof u=="number"?o=-1<(ct(n)?n.indexOf(t,e):Ot(n,t,e)):P(n,function(n){return++ru&&(u=o) -}}else t=!t&&ct(n)?J:G.createCallback(t,e),ht(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function dt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=qt(r);++earguments.length;t=G.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length; -if(typeof u!="number")var i=je(n),u=i.length;return t=G.createCallback(t,r,4),ht(n,function(r,f,c){f=i?i[--u]:--u,e=o?(o=a,n[f]):t(e,n[f],f,c)}),e}function jt(n,t,e){var r;t=G.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++ee?ge(0,u+e):e||0)-1;else if(e)return r=St(n,t),n[r]===t?r:-1; -for(;++r>>1,e(n[r])=s;for(r!=u&&(l=[],r=G.createCallback(r,o)),p&&(l=H([]));++ie?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:G}},Y.prototype=G.prototype;var ke=le,je=ve?function(n){return it(n)?ve(n):[]}:V,we={"&":"&","<":"<",">":">",'"':""","'":"'"},Ce=ut(we);return Kt&&i&&typeof ae=="function"&&(Bt=$t(ae,o)),Dt=8==he(k+"08")?he:function(n,t){return he(ct(n)?n.replace(j,""):n,t||0) -},G.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},G.assign=U,G.at=function(n){for(var t=-1,e=Zt.apply(Jt,me.call(arguments,1)),r=e.length,u=qt(r);++t++l&&(f=n.apply(c,i)),p=oe(o,t),f}},G.defaults=M,G.defer=Bt,G.delay=function(n,t){var r=me.call(arguments,2); -return oe(function(){n.apply(e,r)},t)},G.difference=wt,G.filter=gt,G.flatten=xt,G.forEach=ht,G.forIn=K,G.forOwn=P,G.functions=rt,G.groupBy=function(n,t,e){var r={};return t=G.createCallback(t,e),ht(n,function(n,e,u){e=Gt(t(n,e,u)),(re.call(r,e)?r[e]:r[e]=[]).push(n)}),r},G.initial=function(n,t,e){if(!n)return[];var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=G.createCallback(t,e);o--&&t(n[o],o,n);)r++}else r=t==u||e?1:t||r;return nt(n,0,ye(ge(0,a-r),a))},G.intersection=function(n){var t=arguments,e=t.length,r=H([]),u={},a=-1,o=n?n.length:0,i=[]; -n:for(;++aOt(a,e))&&(u[e]=n)}),u},G.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e) -}},G.pairs=function(n){for(var t=-1,e=je(n),r=e.length,u=qt(r);++te?ge(0,r+e):ye(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},G.mixin=Rt,G.noConflict=function(){return o._=Qt,this},G.parseInt=Dt,G.random=function(n,t){n==u&&t==u&&(t=1),n=+n||0,t==u?(t=n,n=0):t=+t||0; -var e=be();return n%1||t%1?n+ye(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+ne(e*(t-n+1))},G.reduce=_t,G.reduceRight=kt,G.result=function(n,t){var r=n?n[t]:e;return ot(r)?n[t]():r},G.runInContext=t,G.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:je(n).length},G.some=jt,G.sortedIndex=St,G.template=function(n,t,u){var a=G.templateSettings;n||(n=""),u=M({},u,a);var o,i=M({},u.imports,a.imports),a=je(i),i=pt(i),f=0,c=u.interpolate||w,l="__p+='",c=Vt((u.escape||w).source+"|"+c.source+"|"+(c===d?b:w).source+"|"+(u.evaluate||w).source+"|$","g"); -n.replace(c,function(t,e,u,a,i,c){return u||(u=a),l+=n.slice(f,c).replace(x,W),e&&(l+="'+__e("+e+")+'"),i&&(o=r,l+="';"+i+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),f=c+t.length,t}),l+="';\n",c=u=u.variable,c||(u="obj",l="with("+u+"){"+l+"}"),l=(o?l.replace(v,""):l).replace(g,"$1").replace(y,"$1;"),l="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var p=Pt(a,"return "+l).apply(e,i) -}catch(s){throw s.source=l,s}return t?p(t):(p.source=l,p)},G.unescape=function(n){return n==u?"":Gt(n).replace(h,tt)},G.uniqueId=function(n){var t=++c;return Gt(n==u?"":n)+t},G.all=vt,G.any=jt,G.detect=yt,G.foldl=_t,G.foldr=kt,G.include=st,G.inject=_t,P(G,function(n,t){G.prototype[t]||(G.prototype[t]=function(){var t=[this.__wrapped__];return ue.apply(t,arguments),n.apply(G,t)})}),G.first=Ct,G.last=function(n,t,e){if(n){var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=G.createCallback(t,e);o--&&t(n[o],o,n);)r++ -}else if(r=t,r==u||e)return n[a-1];return nt(n,ge(0,a-r))}},G.take=Ct,G.head=Ct,P(G,function(n,t){G.prototype[t]||(G.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return t==u||e&&typeof t!="function"?r:new Y(r)})}),G.VERSION="1.2.1",G.prototype.toString=function(){return Gt(this.__wrapped__)},G.prototype.value=Tt,G.prototype.valueOf=Tt,ht(["join","pop","shift"],function(n){var t=Jt[n];G.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),ht(["push","reverse","sort","unshift"],function(n){var t=Jt[n]; -G.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),ht(["concat","slice","splice"],function(n){var t=Jt[n];G.prototype[n]=function(){return new Y(t.apply(this.__wrapped__,arguments))}}),G}var e,r=!0,u=null,a=!1,o=typeof exports=="object"&&exports,i=typeof module=="object"&&module&&module.exports==o&&module,f=typeof global=="object"&&global;(f.global===f||f.window===f)&&(n=f);var c=0,l={},p=+new Date+"",s=75,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,y=/(__e\(.*?\)|\b__t\))\+'';/g,h=/&(?:amp|lt|gt|quot|#39);/g,b=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,m=/\w*$/,d=/<%=([\s\S]+?)%>/g,_=(_=/\bthis\b/)&&_.test(t)&&_,k=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",j=RegExp("^["+k+"]*0+(?=.$)"),w=/($^)/,C=/[&<>"']/g,x=/['\n\r\t\u2028\u2029\\]/g,O="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),E="[object Arguments]",S="[object Array]",I="[object Boolean]",N="[object Date]",A="[object Function]",$="[object Number]",B="[object Object]",F="[object RegExp]",R="[object String]",T={}; +;!function(n){function t(o){function f(n){if(!n||oe.call(n)!=B)return a;var t=n.valueOf,e=typeof t=="function"&&(e=te(t))&&te(e);return e?n==e||te(n)==e:tt(n)}function P(n,t,e){if(!n||!q[typeof n])return n;t=t&&typeof e=="undefined"?t:G.createCallback(t,e);for(var r=-1,u=q[typeof n]?ke(n):[],o=u.length;++rt||typeof n=="undefined")return 1;if(n=s,g={},y={"false":a,"function":a,"null":a,number:{},object:g,string:{},"true":a,undefined:a};if(v){for(;++ce?0:e);++re?ve(0,u+e):e)||0,u&&typeof u=="number"?o=-1<(pt(n)?n.indexOf(t,e):H(n,t,e)):P(n,function(n){return++ru&&(u=o) +}}else t=!t&&pt(n)?J:G.createCallback(t,e),mt(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function kt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Tt(r);++earguments.length;t=G.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length; +if(typeof u!="number")var i=ke(n),u=i.length;return t=G.createCallback(t,r,4),mt(n,function(r,f,c){f=i?i[--u]:--u,e=o?(o=a,n[f]):t(e,n[f],f,c)}),e}function Ct(n,t,e){var r;t=G.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e>>1,e(n[r])e?0:e);++t/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:G}},Z.prototype=G.prototype;var _e=ce,ke=se?function(n){return ct(n)?se(n):[]}:V,je={"&":"&","<":"<",">":">",'"':""","'":"'"},we=ot(je),qt=nt(function xe(n,t,e){for(var r=-1,u=n?n.length:0,a=[];++r=s,o=[],i=a?W():e?[]:o;++rn?t():function(){return 1>--n?t.apply(this,arguments):void 0}},G.assign=U,G.at=function(n){for(var t=-1,e=Yt.apply(Ht,be.call(arguments,1)),r=e.length,u=Tt(r);++t++l&&(f=n.apply(c,i)),p=ae(o,t),f}},G.defaults=M,G.defer=$t,G.delay=function(n,t){var r=be.call(arguments,2);return ae(function(){n.apply(e,r)},t)},G.difference=xt,G.filter=ht,G.flatten=qt,G.forEach=mt,G.forIn=K,G.forOwn=P,G.functions=at,G.groupBy=function(n,t,e){var r={};return t=G.createCallback(t,e),mt(n,function(n,e,u){e=Vt(t(n,e,u)),(ee.call(r,e)?r[e]:r[e]=[]).push(n) +}),r},G.initial=function(n,t,e){if(!n)return[];var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=G.createCallback(t,e);o--&&t(n[o],o,n);)r++}else r=t==u||e?1:t||r;return et(n,0,ge(ve(0,a-r),a))},G.intersection=function(n){var t=arguments,e=t.length,r=W(),u={},a=-1,o=n?n.length:0,i=[];n:for(;++aH(a,e))&&(u[e]=n)}),u},G.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e)}},G.pairs=function(n){for(var t=-1,e=ke(n),r=e.length,u=Tt(r);++te?ve(0,r+e):e||0}else if(e)return e=St(n,t),n[e]===t?e:-1;return n?H(n,t,e):-1},G.isArguments=function(n){return oe.call(n)==E},G.isArray=_e,G.isBoolean=function(n){return n===r||n===a||oe.call(n)==I +},G.isDate=function(n){return n?typeof n=="object"&&oe.call(n)==N:a},G.isElement=function(n){return n?1===n.nodeType:a},G.isEmpty=function(n){var t=r;if(!n)return t;var e=oe.call(n),u=n.length;return e==S||e==R||e==E||e==B&&typeof u=="number"&&ft(n.splice)?!u:(P(n,function(){return t=a}),t)},G.isEqual=it,G.isFinite=function(n){return le(n)&&!pe(parseFloat(n))},G.isFunction=ft,G.isNaN=function(n){return lt(n)&&n!=+n},G.isNull=function(n){return n===u},G.isNumber=lt,G.isObject=ct,G.isPlainObject=f,G.isRegExp=function(n){return n?typeof n=="object"&&oe.call(n)==F:a +},G.isString=pt,G.isUndefined=function(n){return typeof n=="undefined"},G.lastIndexOf=function(n,t,e){var r=n?n.length:0;for(typeof e=="number"&&(r=(0>e?ve(0,r+e):ge(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},G.mixin=Ft,G.noConflict=function(){return o._=Lt,this},G.parseInt=ue,G.random=function(n,t){n==u&&t==u&&(t=1),n=+n||0,t==u?(t=n,n=0):t=+t||0;var e=he();return n%1||t%1?n+ge(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+Zt(e*(t-n+1))},G.reduce=jt,G.reduceRight=wt,G.result=function(n,t){var r=n?n[t]:e; +return ft(r)?n[t]():r},G.runInContext=t,G.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ke(n).length},G.some=Ct,G.sortedIndex=St,G.template=function(n,t,u){var a=G.templateSettings;n||(n=""),u=M({},u,a);var o,i=M({},u.imports,a.imports),a=ke(i),i=vt(i),f=0,c=u.interpolate||w,l="__p+='",c=Ut((u.escape||w).source+"|"+c.source+"|"+(c===d?b:w).source+"|"+(u.evaluate||w).source+"|$","g");n.replace(c,function(t,e,u,a,i,c){return u||(u=a),l+=n.slice(f,c).replace(x,Y),e&&(l+="'+__e("+e+")+'"),i&&(o=r,l+="';"+i+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),f=c+t.length,t +}),l+="';\n",c=u=u.variable,c||(u="obj",l="with("+u+"){"+l+"}"),l=(o?l.replace(v,""):l).replace(g,"$1").replace(y,"$1;"),l="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var p=zt(a,"return "+l).apply(e,i)}catch(s){throw s.source=l,s}return t?p(t):(p.source=l,p)},G.unescape=function(n){return n==u?"":Vt(n).replace(h,rt)},G.uniqueId=function(n){var t=++c;return Vt(n==u?"":n)+t +},G.all=yt,G.any=Ct,G.detect=bt,G.foldl=jt,G.foldr=wt,G.include=gt,G.inject=jt,P(G,function(n,t){G.prototype[t]||(G.prototype[t]=function(){var t=[this.__wrapped__];return re.apply(t,arguments),n.apply(G,t)})}),G.first=Ot,G.last=function(n,t,e){if(n){var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=G.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,r==u||e)return n[a-1];return et(n,ve(0,a-r))}},G.take=Ot,G.head=Ot,P(G,function(n,t){G.prototype[t]||(G.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); +return t==u||e&&typeof t!="function"?r:new Z(r)})}),G.VERSION="1.2.1",G.prototype.toString=function(){return Vt(this.__wrapped__)},G.prototype.value=Rt,G.prototype.valueOf=Rt,mt(["join","pop","shift"],function(n){var t=Ht[n];G.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),mt(["push","reverse","sort","unshift"],function(n){var t=Ht[n];G.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),mt(["concat","slice","splice"],function(n){var t=Ht[n];G.prototype[n]=function(){return new Z(t.apply(this.__wrapped__,arguments)) +}}),G}var e,r=!0,u=null,a=!1,o=typeof exports=="object"&&exports,i=typeof module=="object"&&module&&module.exports==o&&module,f=typeof global=="object"&&global;(f.global===f||f.window===f)&&(n=f);var c=0,l={},p=+new Date+"",s=75,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,y=/(__e\(.*?\)|\b__t\))\+'';/g,h=/&(?:amp|lt|gt|quot|#39);/g,b=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,m=/\w*$/,d=/<%=([\s\S]+?)%>/g,_=(_=/\bthis\b/)&&_.test(t)&&_,k=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",j=RegExp("^["+k+"]*0+(?=.$)"),w=/($^)/,C=/[&<>"']/g,x=/['\n\r\t\u2028\u2029\\]/g,O="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),E="[object Arguments]",S="[object Array]",I="[object Boolean]",N="[object Date]",A="[object Function]",$="[object Number]",B="[object Object]",F="[object RegExp]",R="[object String]",T={}; T[A]=a,T[E]=T[S]=T[I]=T[N]=T[$]=T[B]=T[F]=T[R]=r;var q={"boolean":a,"function":r,object:r,number:a,string:a,undefined:a},D={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},z=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=z, define(function(){return z})):o&&!o.nodeType?i?(i.exports=z)._=z:o._=z:n._=z}(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 625d5b051..beeaaae7f 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -295,6 +295,28 @@ /*--------------------------------------------------------------------------*/ + /** + * A basic version of `_.indexOf` without support for binary searches + * or `fromIndex` constraints. + * + * @private + * @param {Array} array The array to search. + * @param {Mixed} value The value to search for. + * @param {Number} [fromIndex=0] The index to search from. + * @returns {Number} Returns the index of the matched value or `-1`. + */ + function basicIndexOf(array, value, fromIndex) { + var index = (fromIndex || 0) - 1, + length = array.length; + + while (++index < length) { + if (array[index] === value) { + return index; + } + } + return -1; + } + /** * Used by `_.max` and `_.min` as the default `callback` when a given * `collection` is a string value. @@ -394,6 +416,85 @@ return bound; } + /** + * Creates a function optimized to search large arrays for a given `value`, + * starting at `fromIndex`, using strict equality for comparisons, i.e. `===`. + * + * @private + * @param {Array} [array=[]] The array to search. + * @param {Mixed} value The value to search for. + * @returns {Boolean} Returns `true`, if `value` is found, else `false`. + */ + function createCache(array) { + array || (array = []); + + var bailout, + index = -1, + length = array.length, + isLarge = length >= largeArraySize, + objCache = {}; + + var caches = { + 'false': false, + 'function': false, + 'null': false, + 'number': {}, + 'object': objCache, + 'string': {}, + 'true': false, + 'undefined': false + }; + + function basicContains(value) { + return basicIndexOf(array, value) > -1; + } + + function basicPush(value) { + array.push(value); + } + + function cacheContains(value) { + var type = typeof value; + if (type == 'boolean' || value == null) { + return caches[value]; + } + var cache = caches[type] || (type = 'object', objCache), + key = type == 'number' ? value : keyPrefix + value; + + return type == 'object' + ? (cache[key] ? basicIndexOf(cache[key], value) > -1 : false) + : !!cache[key]; + } + + function cachePush(value) { + var type = typeof value; + if (type == 'boolean' || value == null) { + caches[value] = true; + } else { + var cache = caches[type] || (type = 'object', objCache), + key = type == 'number' ? value : keyPrefix + value; + + if (type == 'object') { + bailout = (cache[key] || (cache[key] = [])).push(value) == length; + } else { + cache[key] = true; + } + } + } + + if (isLarge) { + while (++index < length) { + cachePush(array[index]); + } + if (bailout) { + isLarge = caches = objCache = null; + } + } + return isLarge + ? { 'contains': cacheContains, 'push': cachePush } + : { 'contains': basicContains, 'push': basicPush }; + } + /** * Creates a new object with the specified `prototype`. * @@ -416,6 +517,17 @@ }; } + /** + * Used by `escape` to convert characters to HTML entities. + * + * @private + * @param {String} match The matched character to escape. + * @returns {String} Returns the escaped character. + */ + function escapeHtmlChar(match) { + return htmlEscapes[match]; + } + /** * Used by `template` to escape characters for inclusion in compiled * string literals. @@ -428,17 +540,6 @@ return '\\' + stringEscapes[match]; } - /** - * Used by `escape` to convert characters to HTML entities. - * - * @private - * @param {String} match The matched character to escape. - * @returns {String} Returns the escaped character. - */ - function escapeHtmlChar(match) { - return htmlEscapes[match]; - } - /** * A fast path for creating `lodash` wrapper objects. * @@ -461,6 +562,29 @@ // no operation performed } + /** + * Creates a function that juggles arguments, allowing argument overloading + * for `_.flatten` and `_.uniq`, before passing them to the given `func`. + * + * @private + * @param {Function} func The function to wrap. + * @returns {Function} Returns the new function. + */ + function overloadWrapper(func) { + return function(array, flag, callback, thisArg) { + // juggle arguments + if (typeof flag != 'boolean' && flag != null) { + thisArg = callback; + callback = !(thisArg && thisArg[flag] === array) ? flag : undefined; + flag = false; + } + if (callback != null) { + callback = createCallback(callback, thisArg); + } + return func(array, flag, callback, thisArg); + }; + } + /** * Used by `unescape` to convert HTML entities to characters. * @@ -1312,7 +1436,7 @@ result = {}; forIn(object, function(value, key) { - if (indexOf(props, key) < 0) { + if (basicIndexOf(props, key) < 0) { result[key] = value; } }); @@ -1443,8 +1567,8 @@ function contains(collection, target) { var length = collection ? collection.length : 0, result = false; - if (typeof length == 'number') { - result = indexOf(collection, target) > -1; + if (length && typeof length == 'number') { + result = basicIndexOf(collection, target) > -1; } else { forOwn(collection, function(value) { return (result = value === target) && indicatorObject; @@ -2478,7 +2602,7 @@ while (++index < length) { var value = array[index]; - if (indexOf(flattened, value) < 0) { + if (basicIndexOf(flattened, value) < 0) { result.push(value); } } @@ -2645,21 +2769,14 @@ * // => 2 */ function indexOf(array, value, fromIndex) { - var index = -1, - length = array ? array.length : 0; - if (typeof fromIndex == 'number') { - index = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0) - 1; + var length = array ? array.length : 0; + fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0); } else if (fromIndex) { - index = sortedIndex(array, value); + var index = sortedIndex(array, value); return array[index] === value ? index : -1; } - while (++index < length) { - if (array[index] === value) { - return index; - } - } - return -1; + return array ? basicIndexOf(array, value, fromIndex) : -1; } /** @@ -2762,10 +2879,10 @@ outer: while (++index < length) { var value = array[index]; - if (indexOf(result, value) < 0) { + if (basicIndexOf(result, value) < 0) { var argsIndex = argsLength; while (--argsIndex) { - if (indexOf(args[argsIndex], value) < 0) { + if (basicIndexOf(args[argsIndex], value) < 0) { continue outer; } } @@ -3100,7 +3217,7 @@ * Creates a duplicate-value-free version of the `array` using strict equality * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` * for `isSorted` will run a faster algorithm. If `callback` is passed, each - * element of `array` is passed through a `callback` before uniqueness is computed. + * element of `array` is passed through the `callback` before uniqueness is computed. * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is passed for `callback`, the created "_.pluck" style @@ -3129,11 +3246,11 @@ * _.uniq([1, 1, 2, 2, 3], true); * // => [1, 2, 3] * - * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); }); - * // => [1, 2, 3] + * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); + * // => ['A', 'b', 'C'] * - * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); - * // => [1, 2, 3] + * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); + * // => [1, 2.5, 3] * * // using "_.pluck" callback shorthand * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); @@ -3160,7 +3277,7 @@ if (isSorted ? !index || seen[seen.length - 1] !== computed - : indexOf(seen, computed) < 0 + : basicIndexOf(seen, computed) < 0 ) { if (callback) { seen.push(computed); diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index 3df50eeb5..85c7df7e8 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -4,32 +4,31 @@ * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;!function(n){function t(n){return n instanceof t?n:new a(n)}function r(n,t){var r=n.b,e=t.b;if(n=n.a,t=t.a,n!==t){if(n>t||typeof n=="undefined")return 1;if(ne&&(e=r,u=n)});else for(;++ou&&(u=r);return u}function B(n,t){var r=-1,e=n?n.length:0; -if(typeof e=="number")for(var u=Array(e);++rarguments.length;t=U(t,e,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(r=n[++o]);++oarguments.length;if(typeof u!="number")var i=Mt(n),u=i.length;return t=U(t,e,4),E(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=!1,n[a]):t(r,n[a],a,f)}),r}function q(n,t,r){var e; -t=U(t,r),r=-1;var u=n?n.length:0;if(typeof u=="number")for(;++r$(e,o)&&u.push(o)}return u}function M(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&null!=t){var o=-1;for(t=U(t,r);++or?Nt(0,u+r):r||0)-1;else if(r)return e=z(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])$(a,f))&&(r&&a.push(f),i.push(e))}return i}function P(n,t){return Rt.fastBind||wt&&2"']/g,nt=/['\n\r\t\u2028\u2029\\]/g,tt="[object Arguments]",rt="[object Array]",et="[object Boolean]",ut="[object Date]",ot="[object Number]",it="[object Object]",at="[object RegExp]",ft="[object String]",lt={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},ct={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},pt=Array.prototype,J=Object.prototype,st=n._,vt=RegExp("^"+(J.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),gt=Math.ceil,ht=n.clearTimeout,yt=pt.concat,mt=Math.floor,_t=J.hasOwnProperty,bt=pt.push,dt=n.setTimeout,jt=J.toString,wt=vt.test(wt=jt.bind)&&wt,At=vt.test(At=Object.create)&&At,xt=vt.test(xt=Array.isArray)&&xt,Ot=n.isFinite,Et=n.isNaN,St=vt.test(St=Object.keys)&&St,Nt=Math.max,Bt=Math.min,Ft=Math.random,kt=pt.slice,J=vt.test(n.attachEvent),qt=wt&&!/\n|true/.test(wt+J),Rt={}; -!function(){var n={0:1,length:1};Rt.fastBind=wt&&!qt,Rt.spliceObjects=(pt.splice.call(n,0,1),!n[0])}(1),t.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},At||(u=function(n){if(_(n)){f.prototype=n;var t=new f;f.prototype=null}return t||{}}),a.prototype=t.prototype,c(arguments)||(c=function(n){return n?_t.call(n,"callee"):!1});var Dt=xt||function(n){return n?typeof n=="object"&&jt.call(n)==rt:!1},xt=function(n){var t,r=[];if(!n||!lt[typeof n])return r; -for(t in n)_t.call(n,t)&&r.push(t);return r},Mt=St?function(n){return _(n)?St(n):[]}:xt,Tt={"&":"&","<":"<",">":">",'"':""","'":"'"},$t=g(Tt),It=function(n,t){var r;if(!n||!lt[typeof n])return n;for(r in n)if(t(n[r],r,n)===L)break;return n},zt=function(n,t){var r;if(!n||!lt[typeof n])return n;for(r in n)if(_t.call(n,r)&&t(n[r],r,n)===L)break;return n};m(/x/)&&(m=function(n){return typeof n=="function"&&"[object Function]"==jt.call(n)}),t.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0 -}},t.bind=P,t.bindAll=function(n){for(var t=1$(o,i)){for(var a=r;--a;)if(0>$(t[a],i))continue n;o.push(i)}}return o},t.invert=g,t.invoke=function(n,t){var r=kt.call(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); -return E(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},t.keys=Mt,t.map=S,t.max=N,t.memoize=function(n,t){var r={};return function(){var e=Q+(t?t.apply(this,arguments):arguments[0]);return _t.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},t.min=function(n,t,r){var e=1/0,u=e,o=-1,i=n?n.length:0;if(t||typeof i!="number")t=U(t,r),E(n,function(n,r,o){r=t(n,r,o),r$(t,e)&&(r[e]=n) -}),r},t.once=function(n){var t,r;return function(){return t?r:(t=!0,r=n.apply(this,arguments),n=null,r)}},t.pairs=function(n){for(var t=-1,r=Mt(n),e=r.length,u=Array(e);++tr?0:r);++tr?Nt(0,e+r):Bt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},t.mixin=W,t.noConflict=function(){return n._=st,this},t.random=function(n,t){null==n&&null==t&&(t=1),n=+n||0,null==t?(t=n,n=0):t=+t||0;var r=Ft();return n%1||t%1?n+Bt(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+mt(r*(t-n+1)) -},t.reduce=F,t.reduceRight=k,t.result=function(n,t){var r=n?n[t]:null;return m(r)?n[t]():r},t.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Mt(n).length},t.some=q,t.sortedIndex=z,t.template=function(n,r,e){n||(n=""),e=s({},e,t.templateSettings);var u=0,i="__p+='",a=e.variable;n.replace(RegExp((e.escape||Y).source+"|"+(e.interpolate||Y).source+"|"+(e.evaluate||Y).source+"|$","g"),function(t,r,e,a,f){return i+=n.slice(u,f).replace(nt,o),r&&(i+="'+_['escape']("+r+")+'"),a&&(i+="';"+a+";__p+='"),e&&(i+="'+((__t=("+e+"))==null?'':__t)+'"),u=f+t.length,t -}),i+="';\n",a||(a="obj",i="with("+a+"||{}){"+i+"}"),i="function("+a+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+i+"return __p}";try{var f=Function("_","return "+i)(t)}catch(l){throw l.source=i,l}return r?f(r):(f.source=i,f)},t.unescape=function(n){return null==n?"":(n+"").replace(X,l)},t.uniqueId=function(n){var t=++K+"";return n?n+t:t},t.all=A,t.any=q,t.detect=O,t.foldl=F,t.foldr=k,t.include=w,t.inject=F,t.first=M,t.last=function(n,t,r){if(n){var e=0,u=n.length; -if(typeof t!="number"&&null!=t){var o=u;for(t=U(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,null==e||r)return n[u-1];return kt.call(n,Nt(0,u-e))}},t.take=M,t.head=M,t.VERSION="1.2.1",W(t),t.prototype.chain=function(){return this.__chain__=!0,this},t.prototype.value=function(){return this.__wrapped__},E("pop push reverse shift sort splice unshift".split(" "),function(n){var r=pt[n];t.prototype[n]=function(){var n=this.__wrapped__;return r.apply(n,arguments),!Rt.spliceObjects&&0===n.length&&delete n[0],this -}}),E(["concat","join","slice"],function(n){var r=pt[n];t.prototype[n]=function(){var n=r.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new a(n),n.__chain__=!0),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=t, define(function(){return t})):G&&!G.nodeType?H?(H.exports=t)._=t:G._=t:n._=t}(this); \ No newline at end of file +;!function(n){function t(n,t){var r;if(n&&ht[typeof n])for(r in n)if(xt.call(n,r)&&t(n[r],r,n)===tt)break}function r(n,t){var r;if(n&&ht[typeof n])for(r in n)if(t(n[r],r,n)===tt)break}function e(n){var t,r=[];if(!n||!ht[typeof n])return r;for(t in n)xt.call(n,t)&&r.push(t);return r}function u(n){return n instanceof u?n:new p(n)}function o(n,t,r){r=(r||0)-1;for(var e=n.length;++rt||typeof n=="undefined")return 1; +if(ne&&(e=r,u=n)});else for(;++ou&&(u=r);return u}function R(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++rarguments.length;r=G(r,u,4);var i=-1,a=n.length; +if(typeof a=="number")for(o&&(e=n[++i]);++iarguments.length;if(typeof u!="number")var i=Pt(n),u=i.length;return t=G(t,e,4),B(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=Q,n[a]):t(r,n[a],a,f)}),r}function T(n,r,e){var u;r=G(r,e),e=-1;var o=n?n.length:0;if(typeof o=="number")for(;++eo(e,i)&&u.push(i)}return u}function z(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=L){var o=-1;for(t=G(t,r);++o>>1,r(n[e])o(f,c))&&(r&&f.push(c),a.push(e))}return a}function W(n,t){return zt.fastBind||Nt&&2"']/g,it=/['\n\r\t\u2028\u2029\\]/g,at="[object Arguments]",ft="[object Array]",ct="[object Boolean]",lt="[object Date]",pt="[object Number]",st="[object Object]",vt="[object RegExp]",gt="[object String]",ht={"boolean":Q,"function":K,object:K,number:Q,string:Q,undefined:Q},yt={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},mt=Array.prototype,Z=Object.prototype,_t=n._,bt=RegExp("^"+(Z.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),dt=Math.ceil,jt=n.clearTimeout,wt=mt.concat,At=Math.floor,xt=Z.hasOwnProperty,Ot=mt.push,Et=n.setTimeout,St=Z.toString,Nt=bt.test(Nt=St.bind)&&Nt,kt=bt.test(kt=Object.create)&&kt,Bt=bt.test(Bt=Array.isArray)&&Bt,Ft=n.isFinite,qt=n.isNaN,Rt=bt.test(Rt=Object.keys)&&Rt,Dt=Math.max,Mt=Math.min,Tt=Math.random,$t=mt.slice,Z=bt.test(n.attachEvent),It=Nt&&!/\n|true/.test(Nt+Z),zt={}; +!function(){var n={0:1,length:1};zt.fastBind=Nt&&!It,zt.spliceObjects=(mt.splice.call(n,0,1),!n[0])}(1),u.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},kt||(f=function(n){if(w(n)){s.prototype=n;var t=new s;s.prototype=L}return t||{}}),p.prototype=u.prototype,g(arguments)||(g=function(n){return n?xt.call(n,"callee"):Q});var Ct=Bt||function(n){return n?typeof n=="object"&&St.call(n)==ft:Q},Pt=Rt?function(n){return w(n)?Rt(n):[]}:e,Ut={"&":"&","<":"<",">":">",'"':""","'":"'"},Vt=_(Ut); +j(/x/)&&(j=function(n){return typeof n=="function"&&"[object Function]"==St.call(n)}),u.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},u.bind=W,u.bindAll=function(n){for(var t=1o(i,a)){for(var f=r;--f;)if(0>o(t[f],a))continue n;i.push(a)}}return i},u.invert=_,u.invoke=function(n,t){var r=$t.call(arguments,2),e=-1,u=typeof t=="function",o=n?n.length:0,i=Array(typeof o=="number"?o:0); +return B(n,function(n){i[++e]=(u?t:n[t]).apply(n,r)}),i},u.keys=Pt,u.map=F,u.max=q,u.memoize=function(n,t){var r={};return function(){var e=rt+(t?t.apply(this,arguments):arguments[0]);return xt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},u.min=function(n,t,r){var e=1/0,u=e,o=-1,i=n?n.length:0;if(t||typeof i!="number")t=G(t,r),B(n,function(n,r,o){r=t(n,r,o),ro(t,r)&&(e[r]=n) +}),e},u.once=function(n){var t,r;return function(){return t?r:(t=K,r=n.apply(this,arguments),n=L,r)}},u.pairs=function(n){for(var t=-1,r=Pt(n),e=r.length,u=Array(e);++tr?0:r);++tr?Dt(0,e+r):r||0}else if(r)return r=U(n,t),n[r]===t?r:-1;return n?o(n,t,r):-1},u.isArguments=g,u.isArray=Ct,u.isBoolean=function(n){return n===K||n===Q||St.call(n)==ct},u.isDate=function(n){return n?typeof n=="object"&&St.call(n)==lt:Q},u.isElement=function(n){return n?1===n.nodeType:Q},u.isEmpty=b,u.isEqual=d,u.isFinite=function(n){return Ft(n)&&!qt(parseFloat(n)) +},u.isFunction=j,u.isNaN=function(n){return A(n)&&n!=+n},u.isNull=function(n){return n===L},u.isNumber=A,u.isObject=w,u.isRegExp=function(n){return!(!n||!ht[typeof n])&&St.call(n)==vt},u.isString=x,u.isUndefined=function(n){return typeof n=="undefined"},u.lastIndexOf=function(n,t,r){var e=n?n.length:0;for(typeof r=="number"&&(e=(0>r?Dt(0,e+r):Mt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},u.mixin=J,u.noConflict=function(){return n._=_t,this},u.random=function(n,t){n==L&&t==L&&(t=1),n=+n||0,t==L?(t=n,n=0):t=+t||0; +var r=Tt();return n%1||t%1?n+Mt(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+At(r*(t-n+1))},u.reduce=D,u.reduceRight=M,u.result=function(n,t){var r=n?n[t]:L;return j(r)?n[t]():r},u.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Pt(n).length},u.some=T,u.sortedIndex=U,u.template=function(n,t,r){n||(n=""),r=y({},r,u.templateSettings);var e=0,o="__p+='",i=r.variable;n.replace(RegExp((r.escape||ut).source+"|"+(r.interpolate||ut).source+"|"+(r.evaluate||ut).source+"|$","g"),function(t,r,u,i,a){return o+=n.slice(e,a).replace(it,l),r&&(o+="'+_['escape']("+r+")+'"),i&&(o+="';"+i+";__p+='"),u&&(o+="'+((__t=("+u+"))==null?'':__t)+'"),e=a+t.length,t +}),o+="';\n",i||(i="obj",o="with("+i+"||{}){"+o+"}"),o="function("+i+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+o+"return __p}";try{var a=Function("_","return "+o)(u)}catch(f){throw f.source=o,f}return t?a(t):(a.source=o,a)},u.unescape=function(n){return n==L?"":(n+"").replace(et,v)},u.uniqueId=function(n){var t=++nt+"";return n?n+t:t},u.all=S,u.any=T,u.detect=k,u.foldl=D,u.foldr=M,u.include=E,u.inject=D,u.first=z,u.last=function(n,t,r){if(n){var e=0,u=n.length; +if(typeof t!="number"&&t!=L){var o=u;for(t=G(t,r);o--&&t(n[o],o,n);)e++}else if(e=t,e==L||r)return n[u-1];return $t.call(n,Dt(0,u-e))}},u.take=z,u.head=z,u.VERSION="1.2.1",J(u),u.prototype.chain=function(){return this.__chain__=K,this},u.prototype.value=function(){return this.__wrapped__},B("pop push reverse shift sort splice unshift".split(" "),function(n){var t=mt[n];u.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),!zt.spliceObjects&&0===n.length&&delete n[0],this}}),B(["concat","join","slice"],function(n){var t=mt[n]; +u.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new p(n),n.__chain__=K),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=u, define(function(){return u})):X&&!X.nodeType?Y?(Y.exports=u)._=u:X._=u:n._=u}(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 2a13d5840..86ee4604d 100644 --- a/doc/README.md +++ b/doc/README.md @@ -217,7 +217,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3460 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3508 "View in source") [Ⓣ][1] Creates an array with all falsey values of `array` removed. The values `false`, `null`, `0`, `""`, `undefined` and `NaN` are all falsey. @@ -241,7 +241,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3490 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3538 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -266,7 +266,7 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.findIndex(array [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3526 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3574 "View in source") [Ⓣ][1] This method is similar to `_.find`, except that it returns the index of the element that passes the callback check, instead of the element itself. @@ -294,7 +294,7 @@ _.findIndex(['apple', 'banana', 'beet'], function(food) { ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3596 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3644 "View in source") [Ⓣ][1] Gets the first element of the `array`. If a number `n` is passed, the first `n` elements of the `array` are returned. If a `callback` function is passed, elements at the beginning of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -354,7 +354,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array [, isShallow=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3658 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3706 "View in source") [Ⓣ][1] Flattens a nested array *(the nesting can be to any depth)*. If `isShallow` is truthy, `array` will only be flattened a single level. If `callback` is passed, each element of `array` is passed through a `callback` before flattening. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -397,7 +397,7 @@ _.flatten(stooges, 'quotes'); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3711 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3750 "View in source") [Ⓣ][1] Gets the index at which the first occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `fromIndex` will run a faster binary search. @@ -429,7 +429,7 @@ _.indexOf([1, 1, 2, 2, 3, 3], 2, true); ### `_.initial(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3785 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3817 "View in source") [Ⓣ][1] Gets all but the last element of `array`. If a number `n` is passed, the last `n` elements are excluded from the result. If a `callback` function is passed, elements at the end of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -486,7 +486,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3819 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3851 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -510,7 +510,7 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.last(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3903 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3935 "View in source") [Ⓣ][1] Gets the last element of the `array`. If a number `n` is passed, the last `n` elements of the `array` are returned. If a `callback` function is passed, elements at the end of the array are returned as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments;(value, index, array). @@ -567,7 +567,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3944 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3976 "View in source") [Ⓣ][1] Gets the index at which the last occurrence of `value` is found using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -596,7 +596,7 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3985 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4017 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. @@ -634,7 +634,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4064 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4096 "View in source") [Ⓣ][1] The opposite of `_.initial`, this method gets all but the first value of `array`. If a number `n` is passed, the first `n` values are excluded from the result. If a `callback` function is passed, elements at the beginning of the array are excluded from the result as long as the `callback` returns truthy. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -694,7 +694,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4128 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4160 "View in source") [Ⓣ][1] Uses a binary search to determine the smallest index at which the `value` should be inserted into `array` in order to maintain the sort order of the sorted `array`. If `callback` is passed, it will be executed for `value` and each element in `array` to compute their sort ranking. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -743,7 +743,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4160 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4192 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -767,9 +767,9 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); ### `_.uniq(array [, isSorted=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4210 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4242 "View in source") [Ⓣ][1] -Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through a `callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. +Creates a duplicate-value-free version of the `array` using strict equality for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` for `isSorted` will run a faster algorithm. If `callback` is passed, each element of `array` is passed through the `callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. @@ -795,11 +795,11 @@ _.uniq([1, 2, 1, 3, 1]); _.uniq([1, 1, 2, 2, 3], true); // => [1, 2, 3] -_.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); }); -// => [1, 2, 3] +_.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); +// => ['A', 'b', 'C'] -_.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); -// => [1, 2, 3] +_.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); +// => [1, 2.5, 3] // using "_.pluck" callback shorthand _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); @@ -814,7 +814,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.unzip(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4280 "View in source") [Ⓣ][1] The inverse of `_.zip`, this method splits groups of elements into arrays composed of elements from each group at their corresponding indexes. @@ -838,7 +838,7 @@ _.unzip([['moe', 30, true], ['larry', 40, false]]); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4288 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4306 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -863,7 +863,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4308 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4326 "View in source") [Ⓣ][1] Groups the elements of each array at their corresponding indexes. Useful for separate data sources that are coordinated through matching array indexes. For a matrix of nested arrays, `_.zip.apply(...)` can transpose the matrix in a similar fashion. @@ -887,7 +887,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_.zipObject(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4330 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4348 "View in source") [Ⓣ][1] Creates an object composed from arrays of `keys` and `values`. Pass either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`, or two arrays, one of `keys` and one of corresponding `values`. @@ -978,7 +978,7 @@ _.isArray(squares.value()); ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5407 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5425 "View in source") [Ⓣ][1] Invokes `interceptor` with the `value` as the first argument, and then returns `value`. The purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. @@ -1008,7 +1008,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5424 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5442 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1029,7 +1029,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5441 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5459 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1060,7 +1060,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2449 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2497 "View in source") [Ⓣ][1] Creates an array of elements from the specified indexes, or keys, of the `collection`. Indexes may be specified as individual arguments or as arrays of indexes. @@ -1088,7 +1088,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2491 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2539 "View in source") [Ⓣ][1] Checks if a given `target` element is present in a `collection` using strict equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the offset from the end of the collection. @@ -1126,7 +1126,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2545 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2593 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the given `callback`. The corresponding value of each key is the number of times the key was returned by the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1162,7 +1162,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2597 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2645 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **all** elements of a `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1208,7 +1208,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2658 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2706 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1254,7 +1254,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2725 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2773 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning the first that the `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1303,7 +1303,7 @@ _.find(food, 'organic'); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2772 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2820 "View in source") [Ⓣ][1] Iterates over a `collection`, 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`. @@ -1335,7 +1335,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2822 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2870 "View in source") [Ⓣ][1] Creates an object composed of keys returned from running each element of the `collection` through the `callback`. The corresponding value of each key is an array of elements passed to `callback` that returned the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1372,7 +1372,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2855 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2903 "View in source") [Ⓣ][1] Invokes the method named by `methodName` on each element in the `collection`, returning an array of the results of each invoked method. Additional arguments will be passed to each invoked method. If `methodName` is a function, it will be invoked for, and `this` bound to, each element in the `collection`. @@ -1401,7 +1401,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2907 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2955 "View in source") [Ⓣ][1] Creates an array of values by running each element in the `collection` through the `callback`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1446,7 +1446,7 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2964 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3012 "View in source") [Ⓣ][1] Retrieves the maximum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1488,7 +1488,7 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3033 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3081 "View in source") [Ⓣ][1] Retrieves the minimum value of an `array`. If `callback` is passed, it will be executed for each value in the `array` to generate the criterion by which the value is ranked. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, collection)*. @@ -1530,7 +1530,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3083 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3131 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1560,7 +1560,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3163 "View in source") [Ⓣ][1] Reduces a `collection` to a value which is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not passed, the first element of the `collection` will be used as the initial `accumulator` value. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. @@ -1598,7 +1598,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) { ### `_.reduceRight(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3158 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3206 "View in source") [Ⓣ][1] This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. @@ -1629,7 +1629,7 @@ var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []); ### `_.reject(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3218 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3266 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1672,7 +1672,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3239 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3287 "View in source") [Ⓣ][1] Creates an array of shuffled `array` values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle. @@ -1696,7 +1696,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3272 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3320 "View in source") [Ⓣ][1] Gets the size of the `collection` by returning `collection.length` for arrays and array-like objects or the number of own enumerable properties for objects. @@ -1726,7 +1726,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3319 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3367 "View in source") [Ⓣ][1] Checks if the `callback` returns a truthy value for **any** element of a `collection`. The function returns as soon as it finds passing value, and does not iterate over the entire `collection`. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1772,7 +1772,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3375 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3423 "View in source") [Ⓣ][1] Creates an array of elements, sorted in ascending order by the results of running each element in the `collection` through the `callback`. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. @@ -1809,7 +1809,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3410 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3458 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1833,7 +1833,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3442 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3490 "View in source") [Ⓣ][1] Examines each element in a `collection`, returning an array of all elements that have the given `properties`. When checking `properties`, this method performs a deep comparison between values to determine if they are equivalent to each other. @@ -1870,7 +1870,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4370 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4388 "View in source") [Ⓣ][1] If `n` is greater than `0`, a function is created that is restricted to executing `func`, with the `this` binding and arguments of the created function, only after it is called `n` times. If `n` is less than `1`, `func` is executed immediately, without a `this` binding or additional arguments, and its result is returned. @@ -1898,7 +1898,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4403 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4421 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with the `this` binding of `thisArg` and prepends any additional `bind` arguments to those passed to the bound function. @@ -1929,7 +1929,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4434 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4452 "View in source") [Ⓣ][1] Binds methods on `object` to `object`, overwriting the existing method. Method names may be specified as individual arguments or as arrays of method names. If no method names are provided, all the function properties of `object` will be bound. @@ -1960,7 +1960,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4480 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4498 "View in source") [Ⓣ][1] Creates a function that, when called, invokes the method at `object[key]` and prepends any additional `bindKey` arguments to those passed to the bound function. This method differs from `_.bind` by allowing bound functions to reference methods that will be redefined or don't yet exist. See http://michaux.ca/articles/lazy-function-definition-pattern. @@ -2001,7 +2001,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4503 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4521 "View in source") [Ⓣ][1] Creates a function that is the composition of the passed functions, where each function consumes the return value of the function that follows. For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`. Each function is executed with the `this` binding of the composed function. @@ -2028,7 +2028,7 @@ welcome('moe'); ### `_.createCallback([func=identity, thisArg, argCount=3])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4562 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4580 "View in source") [Ⓣ][1] Produces a callback bound to an optional `thisArg`. If `func` is a property name, the created callback will return the property value for a given element. If `func` is an object, the created callback will return `true` for elements that contain the equivalent object properties, otherwise it will return `false`. @@ -2082,7 +2082,7 @@ _.toLookup(stooges, 'name'); ### `_.debounce(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4638 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4656 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -2115,7 +2115,7 @@ jQuery('#postbox').on('click', _.debounce(sendMail, 200, { ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4691 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4709 "View in source") [Ⓣ][1] Defers executing the `func` function until the current call stack has cleared. Additional arguments will be passed to `func` when it is invoked. @@ -2140,7 +2140,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4717 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4735 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -2167,7 +2167,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4741 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4759 "View in source") [Ⓣ][1] Creates a function that memoizes the result of `func`. If `resolver` is passed, it will be used to determine the cache key for storing the result based on the arguments passed to the memoized function. By default, the first argument passed to the memoized function is used as the cache key. The `func` is executed with the `this` binding of the memoized function. @@ -2193,7 +2193,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4771 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4789 "View in source") [Ⓣ][1] Creates a function that is restricted to execute `func` once. Repeat calls to the function will return the value of the first call. The `func` is executed with the `this` binding of the created function. @@ -2219,7 +2219,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4806 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4824 "View in source") [Ⓣ][1] Creates a function that, when called, invokes `func` with any additional `partial` arguments prepended to those passed to the new function. This method is similar to `_.bind`, except it does **not** alter the `this` binding. @@ -2246,7 +2246,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4837 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4855 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2283,7 +2283,7 @@ options.imports ### `_.throttle(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4888 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2315,7 +2315,7 @@ jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4935 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4953 "View in source") [Ⓣ][1] Creates a function that passes `value` to the `wrapper` function as its first argument. Additional arguments passed to the function are appended to those passed to the `wrapper` function. The `wrapper` is executed with the `this` binding of the created function. @@ -2351,7 +2351,7 @@ hello(); ### `_.assign(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1205 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1253 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` function is passed, it will be executed to produce the assigned values. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -2389,7 +2389,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1260 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1308 "View in source") [Ⓣ][1] Creates a clone of `value`. If `deep` is `true`, nested objects will also be cloned, otherwise they will be assigned by reference. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2436,7 +2436,7 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1385 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1433 "View in source") [Ⓣ][1] Creates a deep clone of `value`. If a `callback` function is passed, it will be executed to produce the cloned values. If `callback` returns `undefined`, cloning will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with one argument; *(value)*. @@ -2482,7 +2482,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1409 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1457 "View in source") [Ⓣ][1] Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a property is set, additional defaults of the same property will be ignored. @@ -2508,7 +2508,7 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.findKey(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1431 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1479 "View in source") [Ⓣ][1] This method is similar to `_.find`, except that it returns the key of the element that passes the callback check, instead of the element itself. @@ -2536,7 +2536,7 @@ _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1472 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1520 "View in source") [Ⓣ][1] Iterates over `object`'s own and inherited enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2572,7 +2572,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1497 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1545 "View in source") [Ⓣ][1] Iterates over an object's own enumerable properties, executing the `callback` for each property. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -2600,7 +2600,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1514 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1562 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2627,7 +2627,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1539 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1587 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2652,7 +2652,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1556 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1604 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2676,7 +2676,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1068 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1116 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2703,7 +2703,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1094 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1142 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2730,7 +2730,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1582 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1630 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2754,7 +2754,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1599 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1647 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2778,7 +2778,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1616 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1664 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2802,7 +2802,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1641 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1689 "View in source") [Ⓣ][1] Checks if `value` is empty. Arrays, strings, or `arguments` objects with a length of `0` and objects with no own enumerable properties are considered "empty". @@ -2832,7 +2832,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1700 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1748 "View in source") [Ⓣ][1] Performs a deep comparison between two values to determine if they are equivalent to each other. If `callback` is passed, it will be executed to compare values. If `callback` returns `undefined`, comparisons will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(a, b)*. @@ -2877,7 +2877,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1881 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1929 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2915,7 +2915,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1898 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1946 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2939,7 +2939,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1961 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2009 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2974,7 +2974,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1983 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2031 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -3001,7 +3001,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2000 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2048 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -3025,7 +3025,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1928 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1976 "View in source") [Ⓣ][1] Checks if `value` is the language type of Object. *(e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)* @@ -3055,7 +3055,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2028 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2076 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -3090,7 +3090,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2053 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2101 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -3114,7 +3114,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2070 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2118 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -3138,7 +3138,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2087 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2135 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -3162,7 +3162,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1127 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1175 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -3186,7 +3186,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2146 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2194 "View in source") [Ⓣ][1] Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined`, into the destination object. Subsequent sources will overwrite property assignments of previous sources. If a `callback` function is passed, it will be executed to produce the merged values of the destination and source properties. If `callback` returns `undefined`, merging will be handled by the method instead. The `callback` is bound to `thisArg` and invoked with two arguments; *(objectValue, sourceValue)*. @@ -3242,7 +3242,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2255 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2303 "View in source") [Ⓣ][1] Creates a shallow clone of `object` excluding the specified properties. Property names may be specified as individual arguments or as arrays of property names. If a `callback` function is passed, it will be executed for each property in the `object`, omitting the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3273,7 +3273,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2289 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2337 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3297,7 +3297,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2327 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2375 "View in source") [Ⓣ][1] Creates a shallow clone of `object` composed of the specified properties. Property names may be specified as individual arguments or as arrays of property names. If `callback` is passed, it will be executed for each property in the `object`, picking the properties `callback` returns truthy for. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, key, object)*. @@ -3328,7 +3328,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.transform(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2381 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2429 "View in source") [Ⓣ][1] Transforms an `object` to an new `accumulator` object which is the result of running each of its elements through the `callback`, with each `callback` execution potentially mutating the `accumulator` object. The `callback`is bound to `thisArg` and invoked with four arguments; *(accumulator, value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -3365,7 +3365,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2414 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2462 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3396,7 +3396,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4959 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4977 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3420,7 +3420,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4977 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4995 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -3445,7 +3445,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5003 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5021 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3475,7 +3475,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5032 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5050 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3495,7 +3495,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value [, radix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5056 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5074 "View in source") [Ⓣ][1] Converts the given `value` into an integer of the specified `radix`. If `radix` is `undefined` or `0`, a `radix` of `10` is used unless the `value` is a hexadecimal, in which case a `radix` of `16` is used. @@ -3522,7 +3522,7 @@ _.parseInt('08'); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5079 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5097 "View in source") [Ⓣ][1] Produces a random number between `min` and `max` *(inclusive)*. If only one argument is passed, a number between `0` and the given number will be returned. @@ -3550,7 +3550,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5123 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5141 "View in source") [Ⓣ][1] Resolves the value of `property` on `object`. If `property` is a function, it will be invoked with the `this` binding of `object` and its result returned, else the property value is returned. If `object` is falsey, then `undefined` is returned. @@ -3603,7 +3603,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5207 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5225 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3685,7 +3685,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5332 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5350 "View in source") [Ⓣ][1] Executes the `callback` function `n` times, returning an array of the results of each `callback` execution. The `callback` is bound to `thisArg` and invoked with one argument; *(index)*. @@ -3717,7 +3717,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5359 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5377 "View in source") [Ⓣ][1] The inverse of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3741,7 +3741,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5379 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5397 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3794,7 +3794,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5621 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5639 "View in source") [Ⓣ][1] *(String)*: The semantic version number. diff --git a/lodash.js b/lodash.js index d34c622b3..1a1ed7466 100644 --- a/lodash.js +++ b/lodash.js @@ -4200,7 +4200,7 @@ * Creates a duplicate-value-free version of the `array` using strict equality * for comparisons, i.e. `===`. If the `array` is already sorted, passing `true` * for `isSorted` will run a faster algorithm. If `callback` is passed, each - * element of `array` is passed through a `callback` before uniqueness is computed. + * element of `array` is passed through the `callback` before uniqueness is computed. * The `callback` is bound to `thisArg` and invoked with three arguments; (value, index, array). * * If a property name is passed for `callback`, the created "_.pluck" style @@ -4229,11 +4229,11 @@ * _.uniq([1, 1, 2, 2, 3], true); * // => [1, 2, 3] * - * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return Math.floor(num); }); - * // => [1, 2, 3] + * _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); }); + * // => ['A', 'b', 'C'] * - * _.uniq([1, 2, 1.5, 3, 2.5], function(num) { return this.floor(num); }, Math); - * // => [1, 2, 3] + * _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); + * // => [1, 2.5, 3] * * // using "_.pluck" callback shorthand * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');