From 17eda2a4ccfbb9ed409c0081ea03b61e873fd6f7 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 17 Mar 2013 19:43:23 -0500 Subject: [PATCH] Rebuild files and docs. Former-commit-id: a3948db17af507d28d568d07d3e1a2afbd2c70ad --- dist/lodash.compat.js | 157 +++++++++++----- dist/lodash.compat.min.js | 57 +++--- dist/lodash.js | 155 +++++++++++----- dist/lodash.min.js | 56 +++--- dist/lodash.underscore.js | 69 ++++--- dist/lodash.underscore.min.js | 13 +- doc/README.md | 331 +++++++++++++++++++++------------- doc/parse.php | 2 +- 8 files changed, 536 insertions(+), 304 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index 2f11a7366..32a792b71 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -156,7 +156,7 @@ /** Used to detect if a method is native */ var reNative = RegExp('^' + - (objectRef.valueOf + '') + String(objectRef.valueOf) .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') .replace(/valueOf|for [^\]]+/g, '.+?') + '$' ); @@ -373,7 +373,7 @@ * @type Boolean */ try { - support.nodeClass = !(toString.call(document) == objectClass && !({ 'toString': 0 } + '')); + support.nodeClass = !(toString.call(document) == objectClass && !String({ 'toString': 0 })); } catch(e) { support.nodeClass = true; } @@ -587,13 +587,13 @@ while (++index < length) { // manually coerce `value` to a string because `hasOwnProperty`, in some // older versions of Firefox, coerces objects incorrectly - var key = array[index] + ''; + var key = String(array[index]); (hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = [])).push(array[index]); } } return function(value) { if (isLarge) { - var key = value + ''; + var key = String(value); return hasOwnProperty.call(cache, key) && indexOf(cache[key], value) > -1; } return indexOf(array, value, fromIndex) > -1; @@ -792,7 +792,7 @@ function isNode(value) { // IE < 9 presents DOM nodes as `Object` objects except they have `toString` // methods that are `typeof` "string" and still can coerce nodes to strings - return typeof value.toString != 'function' && typeof (value + '') == 'string'; + return typeof value.toString != 'function' && typeof String(value) == 'string'; } /** @@ -884,6 +884,37 @@ }; } + /** + * 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. + * + * @static + * @memberOf _ + * @alias detect + * @category Object + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Function|Object|String} [callback=identity] The function called per + * iteration. If a property name or object is passed, it will be used to create + * a "_.pluck" or "_.where" style callback, respectively. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Mixed} Returns the key of the found element, else `undefined`. + * @example + * + * _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; }); + * // => 'b' + */ + function findKey(collection, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg); + forOwn(collection, function(value, key, collection) { + if (callback(value, key, collection)) { + result = key; + return false; + } + }); + return result; + } + /** * Iterates over `object`'s own and inherited enumerable properties, executing * the `callback` for each property. The `callback` is bound to `thisArg` and @@ -1120,8 +1151,8 @@ * @param {Boolean} [deep=false] A flag to indicate a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @param- {Array} [stackA=[]] Internally used to track traversed source objects. - * @param- {Array} [stackB=[]] Internally used to associate clones with source counterparts. + * @param- {Array} [stackA=[]] Tracks traversed source objects. + * @param- {Array} [stackB=[]] Associates clones with source counterparts. * @returns {Mixed} Returns the cloned `value`. * @example * @@ -1288,8 +1319,8 @@ * @category Objects * @param {Object} object The destination object. * @param {Object} [source1, source2, ...] The source objects. - * @param- {Object} [guard] Internally used to allow working with `_.reduce` - * without using its callback's `key` and `object` arguments as sources. + * @param- {Object} [guard] Allows working with `_.reduce` without using its + * callback's `key` and `object` arguments as sources. * @returns {Object} Returns the destination object. * @example * @@ -1474,8 +1505,8 @@ * @param {Mixed} b The other value to compare. * @param {Function} [callback] The function to customize comparing values. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @param- {Array} [stackA=[]] Internally used track traversed `a` objects. - * @param- {Array} [stackB=[]] Internally used track traversed `b` objects. + * @param- {Array} [stackA=[]] Tracks traversed `a` objects. + * @param- {Array} [stackB=[]] Tracks traversed `b` objects. * @returns {Boolean} Returns `true`, if the values are equivalent, else `false`. * @example * @@ -1563,7 +1594,7 @@ case stringClass: // coerce regexes to strings (http://es5.github.com/#x15.10.6.4) // treat string primitives and their corresponding object instances as equal - return a == b + ''; + return a == String(b); } var isArr = className == arrayClass; if (!isArr) { @@ -1910,11 +1941,10 @@ * @param {Object} [source1, source2, ...] The source objects. * @param {Function} [callback] The function to customize merging properties. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @param- {Object} [deepIndicator] Internally used to indicate that `stackA` - * and `stackB` are arrays of traversed objects instead of source objects. - * @param- {Array} [stackA=[]] Internally used to track traversed source objects. - * @param- {Array} [stackB=[]] Internally used to associate values with their - * source counterparts. + * @param- {Object} [deepIndicator] Indicates that `stackA` and `stackB` are + * arrays of traversed objects, instead of source objects. + * @param- {Array} [stackA=[]] Tracks traversed source objects. + * @param- {Array} [stackB=[]] Associates values with source counterparts. * @returns {Object} Returns the destination object. * @example * @@ -2302,7 +2332,7 @@ callback = lodash.createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection) + ''; + key = String(callback(value, key, collection)); (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); }); return result; @@ -2455,39 +2485,49 @@ * iteration. If a property name or object is passed, it will be used to create * a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @returns {Mixed} Returns the element that passed the callback check, - * else `undefined`. + * @returns {Mixed} Returns the found element, else `undefined`. * @example * - * var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); + * _.find([1, 2, 3, 4], function(num) { return num % 2 == 0; }); * // => 2 * * var food = [ * { 'name': 'apple', 'organic': false, 'type': 'fruit' }, * { 'name': 'banana', 'organic': true, 'type': 'fruit' }, - * { 'name': 'beet', 'organic': false, 'type': 'vegetable' }, - * { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } + * { 'name': 'beet', 'organic': false, 'type': 'vegetable' } * ]; * * // using "_.where" callback shorthand - * var veggie = _.find(food, { 'type': 'vegetable' }); + * _.find(food, { 'type': 'vegetable' }); * // => { 'name': 'beet', 'organic': false, 'type': 'vegetable' } * * // using "_.pluck" callback shorthand - * var healthy = _.find(food, 'organic'); + * _.find(food, 'organic'); * // => { 'name': 'banana', 'organic': true, 'type': 'fruit' } */ function find(collection, callback, thisArg) { - var result; callback = lodash.createCallback(callback, thisArg); - forEach(collection, function(value, index, collection) { - if (callback(value, index, collection)) { - result = value; - return false; + if (isArray(collection)) { + var index = -1, + length = collection.length; + + while (++index < length) { + var value = collection[index]; + if (callback(value, index, collection)) { + return value; + } } - }); - return result; + } else { + var result; + each(collection, function(value, index, collection) { + if (callback(value, index, collection)) { + result = value; + return false; + } + }); + return result; + } } /** @@ -2567,7 +2607,7 @@ callback = lodash.createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection) + ''; + key = String(callback(value, key, collection)); (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); }); return result; @@ -3246,6 +3286,38 @@ return result; } + /** + * 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. + * + * @static + * @memberOf _ + * @alias detect + * @category Arrays + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Function|Object|String} [callback=identity] The function called per + * iteration. If a property name or object is passed, it will be used to create + * a "_.pluck" or "_.where" style callback, respectively. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Mixed} Returns the index of the found element, else `-1`. + * @example + * + * _.findIndex(['apple', 'banana', 'beet'], function(food) { return /^b/.test(food); }); + * // => 1 + */ + function findIndex(collection, callback, thisArg) { + var index = -1, + length = collection ? collection.length : 0; + + callback = lodash.createCallback(callback, thisArg); + while (++index < length) { + if (callback(collection[index], index, collection)) { + return index; + } + } + return -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, @@ -3540,7 +3612,7 @@ while (++index < length) { var value = array[index]; if (isLarge) { - var key = value + ''; + var key = String(value); var inited = hasOwnProperty.call(cache[0], key) ? !(seen = cache[0][key]) : (seen = cache[0][key] = []); @@ -3948,7 +4020,7 @@ computed = callback ? callback(value, index, array) : value; if (isLarge) { - var key = computed + ''; + var key = String(computed); var inited = hasOwnProperty.call(cache, key) ? !(seen = cache[key]) : (seen = cache[key] = []); @@ -4233,8 +4305,7 @@ * If `func` is an object, the created callback will return `true` for elements * that contain the equivalent object properties, otherwise it will return `false`. * - * Note: All Lo-Dash methods, that accept a `callback` argument, internally - * use `_.createCallback`. + * Note: All Lo-Dash methods, that accept a `callback` argument, use `_.createCallback`. * * @static * @memberOf _ @@ -4435,7 +4506,7 @@ function memoize(func, resolver) { var cache = {}; return function() { - var key = (resolver ? resolver.apply(this, arguments) : arguments[0]) + ''; + var key = String(resolver ? resolver.apply(this, arguments) : arguments[0]); return hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = func.apply(this, arguments)); @@ -4625,7 +4696,7 @@ * // => 'Moe, Larry & Curly' */ function escape(string) { - return string == null ? '' : (string + '').replace(reUnescapedHtml, escapeHtmlChar); + return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar); } /** @@ -5020,7 +5091,7 @@ * // => 'Moe, Larry & Curly' */ function unescape(string) { - return string == null ? '' : (string + '').replace(reEscapedHtml, unescapeHtmlChar); + return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar); } /** @@ -5041,7 +5112,7 @@ */ function uniqueId(prefix) { var id = ++idCounter; - return (prefix == null ? '' : prefix + '') + id; + return String(prefix == null ? '' : prefix) + id; } /*--------------------------------------------------------------------------*/ @@ -5085,7 +5156,7 @@ * // => '1,2,3' */ function wrapperToString() { - return this.__wrapped__ + ''; + return String(this.__wrapped__); } /** @@ -5188,6 +5259,8 @@ lodash.escape = escape; lodash.every = every; lodash.find = find; + lodash.findIndex = findIndex; + lodash.findKey = findKey; lodash.has = has; lodash.identity = identity; lodash.indexOf = indexOf; diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index 82e5b49e8..02b68f0ae 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,42 +4,43 @@ * Build: `lodash -o ./dist/lodash.compat.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n){function t(r){function a(n){return n&&typeof n=="object"&&!ve(n)&&Vt.call(n,"__wrapped__")?n:new L(n)}function B(n,t,e){var r=n.length,u=r-t>=e;if(u){var a={};for(e=t-1;++et||typeof n=="undefined")return 1;if(nu;u++)r+="i='"+t.f[u]+"';if(","constructor"==t.f[u]&&(r+="!(f&&f.prototype===m)&&"),r+="h.call(m,i)){"+t.e+"}"}return(t.b||ce.nonEnumArgs)&&(r+="}"),r+=t.c+";return u",e("h,j,k,l,o,r,p","return function("+n+"){"+r+"}")(Vt,G,ve,et,a,I,ne)}function D(n){return"\\"+N[n]}function z(n){return he[n]}function K(n){return typeof n.toString!="function"&&typeof(n+"")=="string"}function L(n){this.__wrapped__=n}function M(){}function U(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0);var r=-1; +;(function(n){function t(r){function a(n){return n&&typeof n=="object"&&!ve(n)&&Vt.call(n,"__wrapped__")?n:new L(n)}function B(n,t,e){var r=n.length,u=r-t>=e;if(u){var a={};for(e=t-1;++et||typeof n=="undefined")return 1;if(nu;u++)r+="i='"+t.f[u]+"';if(","constructor"==t.f[u]&&(r+="!(f&&f.prototype===m)&&"),r+="h.call(m,i)){"+t.e+"}"}return(t.b||ce.nonEnumArgs)&&(r+="}"),r+=t.c+";return u",e("h,j,k,l,o,r,p","return function("+n+"){"+r+"}")(Vt,G,ve,et,a,P,ne)}function D(n){return"\\"+N[n]}function z(n){return he[n]}function K(n){return typeof n.toString!="function"&&typeof Ft=="string"(n)}function L(n){this.__wrapped__=n}function M(){}function U(n,t,e){t||(t=0),typeof e=="undefined"&&(e=n?n.length:0);var r=-1; e=e-t||0;for(var u=Et(0>e?0:e);++re?te(0,u+e):e)||0,typeof u=="number"?a=-1<(et(n)?n.indexOf(t,e):mt(n,t,e)):le(n,function(n){return++ru&&(u=i)}}else t=!t&&et(n)?F:a.createCallback(t,e),le(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function st(n,t,e,r){var u=3>arguments.length;if(t=a.createCallback(t,r,4),ve(n)){var o=-1,i=n.length;for(u&&(e=n[++o]);++oarguments.length;if(typeof o!="number")var f=ge(n),o=f.length; -else ce.unindexedChars&&et(n)&&(u=n.split(""));return t=a.createCallback(t,r,4),ct(n,function(n,r,a){r=f?f[--o]:--o,e=i?(i=!1,u[r]):t(e,u[r],r,a)}),e}function gt(n,t,e){var r;if(t=a.createCallback(t,e),ve(n)){e=-1;for(var u=n.length;++ee?te(0,u+e):e||0)-1;else if(e)return r=bt(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])mt(f,p))&&((e||c)&&f.push(p),i.push(r))}return i -}function Ct(n,t){for(var e=-1,r=n?n.length:0,u={};++eu&&(u=i)}}else t=!t&&et(n)?F:a.createCallback(t,e),le(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function st(n,t,e,r){var u=3>arguments.length;if(t=a.createCallback(t,r,4),ve(n)){var o=-1,i=n.length;for(u&&(e=n[++o]);++oarguments.length;if(typeof o!="number")var f=ge(n),o=f.length;else ce.unindexedChars&&et(n)&&(u=n.split(""));return t=a.createCallback(t,r,4),ct(n,function(n,r,a){r=f?f[--o]:--o,e=i?(i=!1,u[r]):t(e,u[r],r,a)}),e}function gt(n,t,e){var r;if(t=a.createCallback(t,e),ve(n)){e=-1;for(var u=n.length;++ee?te(0,u+e):e||0)-1;else if(e)return r=bt(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])mt(f,p))&&((e||c)&&f.push(p),i.push(r)) +}return i}function Ct(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:g,variable:"",imports:{_:a}};var St={a:"q,w,g",g:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b":">",'"':""","'":"'"},ye=X(he),me=T(St,{g:St.g.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=o.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),e:"u[i]=d?d(u[i],m[i]):m[i]"}),de=T(St); -Z(/x/)&&(Z=function(n){return n instanceof Pt||Qt.call(n)==x});var be=Ut?function(n){if(!n||Qt.call(n)!=E||!ce.argsClass&&G(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Ut(t))&&Ut(e);return e?n==e||Ut(n)==e:H(n)}:H;return ie&&u&&typeof Ht=="function"&&(jt=wt(Ht,r)),Ht=8==re("08")?re:function(n,t){return re(et(n)?n.replace(h,""):n,t||0)},a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=me,a.at=function(n){var t=-1,e=Lt.apply(qt,U(arguments,1)),r=e.length,u=Et(r); +try{ce.nodeClass=!(Qt.call(document)==E&&!Ft({toString:0}))}catch(u){ce.nodeClass=!0}})(1),a.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:g,variable:"",imports:{_:a}};var St={a:"q,w,g",g:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b":">",'"':""","'":"'"},ye=X(he),me=T(St,{g:St.g.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=o.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),e:"u[i]=d?d(u[i],m[i]):m[i]"}),de=T(St); +Z(/x/)&&(Z=function(n){return n instanceof It||Qt.call(n)==x});var be=Ut?function(n){if(!n||Qt.call(n)!=E||!ce.argsClass&&G(n))return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Ut(t))&&Ut(e);return e?n==e||Ut(n)==e:H(n)}:H;return ie&&u&&typeof Ht=="function"&&(jt=wt(Ht,r)),Ht=8==re("08")?re:function(n,t){return re(et(n)?n.replace(h,""):n,t||0)},a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=me,a.at=function(n){var t=-1,e=Lt.apply(qt,U(arguments,1)),r=e.length,u=Et(r); for(ce.unindexedChars&&et(n)&&(n=n.split(""));++tmt(f,c)){o&&f.push(c); -for(var p=e;--p;)if(!(r[p]||(r[p]=B(t[p],0,100)))(c))continue n;i.push(c)}}return i},a.invert=X,a.invoke=function(n,t){var e=U(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Et(typeof a=="number"?a:0);return ct(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},a.keys=ge,a.map=lt,a.max=pt,a.memoize=function(n,t){var e={};return function(){var r=(t?t.apply(this,arguments):arguments[0])+"";return Vt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=rt,a.min=function(n,t,e){var r=1/0,u=r; +return t=a.createCallback(t,e),ct(n,function(n,e,u){e=Ft(t(n,e,u)),(Vt.call(r,e)?r[e]:r[e]=[]).push(n)}),r},a.initial=function(n,t,e){if(!n)return[];var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else r=null==t||e?1:t||r;return U(n,0,ee(te(0,u-r),u))},a.intersection=function(n){var t=arguments,e=t.length,r={0:{}},u=-1,a=n?n.length:0,o=100<=a,i=[],f=i;n:for(;++umt(f,c)){o&&f.push(c);for(var p=e;--p;)if(!(r[p]||(r[p]=B(t[p],0,100)))(c))continue n;i.push(c)}}return i},a.invert=X,a.invoke=function(n,t){var e=U(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Et(typeof a=="number"?a:0);return ct(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},a.keys=ge,a.map=lt,a.max=pt,a.memoize=function(n,t){var e={};return function(){var r=Ft(t?t.apply(this,arguments):arguments[0]);return Vt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=rt,a.min=function(n,t,e){var r=1/0,u=r; if(!t&&ve(n)){e=-1;for(var o=n.length;++emt(o,e,1))&&(u[e]=n)}),u},a.once=function(n){var t,e;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},a.pairs=function(n){for(var t=-1,e=ge(n),r=e.length,u=Et(r);++te?te(0,r+e):ee(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},a.mixin=xt,a.noConflict=function(){return r._=Tt,this},a.parseInt=Ht,a.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Mt(ue()*((+t||0)-n+1)) -},a.reduce=st,a.reduceRight=vt,a.result=function(n,t){var r=n?n[t]:e;return Z(r)?n[t]():r},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ge(n).length},a.some=gt,a.sortedIndex=bt,a.template=function(n,t,r){var u=a.templateSettings;n||(n=""),r=de({},r,u);var o,i=de({},r.imports,u.imports),u=ge(i),i=ut(i),p=0,v=r.interpolate||y,h="__p+='",v=Bt((r.escape||y).source+"|"+v.source+"|"+(v===g?s:y).source+"|"+(r.evaluate||y).source+"|$","g");n.replace(v,function(t,e,r,u,a,i){return r||(r=u),h+=n.slice(p,i).replace(d,D),e&&(h+="'+__e("+e+")+'"),a&&(o=!0,h+="';"+a+";__p+='"),r&&(h+="'+((__t=("+r+"))==null?'':__t)+'"),p=i+t.length,t -}),h+="';\n",v=r=r.variable,v||(r="obj",h="with("+r+"){"+h+"}"),h=(o?h.replace(f,""):h).replace(c,"$1").replace(l,"$1;"),h="function("+r+"){"+(v?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+h+"return __p}";try{var m=Pt(u,"return "+h).apply(e,i)}catch(b){throw b.source=h,b}return t?m(t):(m.source=h,m)},a.unescape=function(n){return null==n?"":(n+"").replace(p,V)},a.uniqueId=function(n){var t=++o;return(null==n?"":n+"")+t -},a.all=ot,a.any=gt,a.detect=ft,a.foldl=st,a.foldr=vt,a.include=at,a.inject=st,se(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Gt.apply(t,arguments),n.apply(a,t)})}),a.first=ht,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[u-1];return U(n,te(0,u-r))}},a.take=ht,a.head=ht,se(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); -return null==t||e&&typeof t!="function"?r:new L(r)})}),a.VERSION="1.0.1",a.prototype.toString=function(){return this.__wrapped__+""},a.prototype.value=Ot,a.prototype.valueOf=Ot,le(["join","pop","shift"],function(n){var t=qt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),le(["push","reverse","sort","unshift"],function(n){var t=qt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),le(["concat","slice","splice"],function(n){var t=qt[n];a.prototype[n]=function(){return new L(t.apply(this.__wrapped__,arguments)) -}}),ce.spliceObjects||le(["pop","shift","splice"],function(n){var t=qt[n],e="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,r=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new L(r):r}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global;a.global===a&&(n=a);var o=0,i={},f=/\b__p\+='';/g,c=/\b(__p\+=)''\+/g,l=/(__e\(.*?\)|\b__t\))\+'';/g,p=/&(?:amp|lt|gt|quot|#39);/g,s=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,v=/\w*$/,g=/<%=([\s\S]+?)%>/g,h=/^0+(?=.$)/,y=/($^)/,m=/[&<>"']/g,d=/['\n\r\t\u2028\u2029\\]/g,b="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),_="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),C="[object Arguments]",w="[object Array]",j="[object Boolean]",k="[object Date]",x="[object Function]",O="[object Number]",E="[object Object]",S="[object RegExp]",A="[object String]",P={}; -P[x]=!1,P[C]=P[w]=P[j]=P[k]=P[O]=P[E]=P[S]=P[A]=!0;var I={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},N={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},$=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=$,define(function(){return $})):r&&!r.nodeType?u?(u.exports=$)._=$:r._=$:n._=$})(this); \ No newline at end of file +r(a)||u.push(a)}return u},a.wrap=function(n,t){return function(){var e=[n];return Gt.apply(e,arguments),t.apply(this,e)}},a.zip=function(n){for(var t=-1,e=n?pt(lt(arguments,"length")):0,r=Et(e);++te?te(0,r+e):ee(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},a.mixin=xt,a.noConflict=function(){return r._=Tt,this},a.parseInt=Ht,a.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Mt(ue()*((+t||0)-n+1))},a.reduce=st,a.reduceRight=vt,a.result=function(n,t){var r=n?n[t]:e;return Z(r)?n[t]():r},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ge(n).length},a.some=gt,a.sortedIndex=bt,a.template=function(n,t,r){var u=a.templateSettings; +n||(n=""),r=de({},r,u);var o,i=de({},r.imports,u.imports),u=ge(i),i=ut(i),p=0,v=r.interpolate||y,h="__p+='",v=Bt((r.escape||y).source+"|"+v.source+"|"+(v===g?s:y).source+"|"+(r.evaluate||y).source+"|$","g");n.replace(v,function(t,e,r,u,a,i){return r||(r=u),h+=n.slice(p,i).replace(d,D),e&&(h+="'+__e("+e+")+'"),a&&(o=!0,h+="';"+a+";__p+='"),r&&(h+="'+((__t=("+r+"))==null?'':__t)+'"),p=i+t.length,t}),h+="';\n",v=r=r.variable,v||(r="obj",h="with("+r+"){"+h+"}"),h=(o?h.replace(f,""):h).replace(c,"$1").replace(l,"$1;"),h="function("+r+"){"+(v?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+h+"return __p}"; +try{var m=It(u,"return "+h).apply(e,i)}catch(b){throw b.source=h,b}return t?m(t):(m.source=h,m)},a.unescape=function(n){return null==n?"":Ft(n).replace(p,V)},a.uniqueId=function(n){var t=++o;return Ft(null==n?"":n)+t},a.all=ot,a.any=gt,a.detect=ft,a.foldl=st,a.foldr=vt,a.include=at,a.inject=st,se(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Gt.apply(t,arguments),n.apply(a,t)})}),a.first=ht,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u; +for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[u-1];return U(n,te(0,u-r))}},a.take=ht,a.head=ht,se(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return null==t||e&&typeof t!="function"?r:new L(r)})}),a.VERSION="1.0.1",a.prototype.toString=function(){return Ft(this.__wrapped__)},a.prototype.value=Ot,a.prototype.valueOf=Ot,le(["join","pop","shift"],function(n){var t=qt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments) +}}),le(["push","reverse","sort","unshift"],function(n){var t=qt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),le(["concat","slice","splice"],function(n){var t=qt[n];a.prototype[n]=function(){return new L(t.apply(this.__wrapped__,arguments))}}),ce.spliceObjects||le(["pop","shift","splice"],function(n){var t=qt[n],e="splice"==n;a.prototype[n]=function(){var n=this.__wrapped__,r=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new L(r):r}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global; +a.global===a&&(n=a);var o=0,i={},f=/\b__p\+='';/g,c=/\b(__p\+=)''\+/g,l=/(__e\(.*?\)|\b__t\))\+'';/g,p=/&(?:amp|lt|gt|quot|#39);/g,s=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,v=/\w*$/,g=/<%=([\s\S]+?)%>/g,h=/^0+(?=.$)/,y=/($^)/,m=/[&<>"']/g,d=/['\n\r\t\u2028\u2029\\]/g,b="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),_="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),C="[object Arguments]",w="[object Array]",j="[object Boolean]",k="[object Date]",x="[object Function]",O="[object Number]",E="[object Object]",S="[object RegExp]",A="[object String]",I={}; +I[x]=!1,I[C]=I[w]=I[j]=I[k]=I[O]=I[E]=I[S]=I[A]=!0;var P={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},N={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},$=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=$,define(function(){return $})):r&&!r.nodeType?u?(u.exports=$)._=$:r._=$:n._=$})(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index ceec93cd8..0a7099a38 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -150,7 +150,7 @@ /** Used to detect if a method is native */ var reNative = RegExp('^' + - (objectRef.valueOf + '') + String(objectRef.valueOf) .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') .replace(/valueOf|for [^\]]+/g, '.+?') + '$' ); @@ -436,13 +436,13 @@ while (++index < length) { // manually coerce `value` to a string because `hasOwnProperty`, in some // older versions of Firefox, coerces objects incorrectly - var key = array[index] + ''; + var key = String(array[index]); (hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = [])).push(array[index]); } } return function(value) { if (isLarge) { - var key = value + ''; + var key = String(value); return hasOwnProperty.call(cache, key) && indexOf(cache[key], value) > -1; } return indexOf(array, value, fromIndex) > -1; @@ -623,7 +623,7 @@ function isNode(value) { // IE < 9 presents DOM nodes as `Object` objects except they have `toString` // methods that are `typeof` "string" and still can coerce nodes to strings - return typeof value.toString != 'function' && typeof (value + '') == 'string'; + return typeof value.toString != 'function' && typeof String(value) == 'string'; } /** @@ -709,6 +709,37 @@ return toString.call(value) == argsClass; } + /** + * 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. + * + * @static + * @memberOf _ + * @alias detect + * @category Object + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Function|Object|String} [callback=identity] The function called per + * iteration. If a property name or object is passed, it will be used to create + * a "_.pluck" or "_.where" style callback, respectively. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Mixed} Returns the key of the found element, else `undefined`. + * @example + * + * _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; }); + * // => 'b' + */ + function findKey(collection, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg); + forOwn(collection, function(value, key, collection) { + if (callback(value, key, collection)) { + result = key; + return false; + } + }); + return result; + } + /** * Iterates over `object`'s own and inherited enumerable properties, executing * the `callback` for each property. The `callback` is bound to `thisArg` and @@ -931,8 +962,8 @@ * @param {Boolean} [deep=false] A flag to indicate a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @param- {Array} [stackA=[]] Internally used to track traversed source objects. - * @param- {Array} [stackB=[]] Internally used to associate clones with source counterparts. + * @param- {Array} [stackA=[]] Tracks traversed source objects. + * @param- {Array} [stackB=[]] Associates clones with source counterparts. * @returns {Mixed} Returns the cloned `value`. * @example * @@ -1099,8 +1130,8 @@ * @category Objects * @param {Object} object The destination object. * @param {Object} [source1, source2, ...] The source objects. - * @param- {Object} [guard] Internally used to allow working with `_.reduce` - * without using its callback's `key` and `object` arguments as sources. + * @param- {Object} [guard] Allows working with `_.reduce` without using its + * callback's `key` and `object` arguments as sources. * @returns {Object} Returns the destination object. * @example * @@ -1284,8 +1315,8 @@ * @param {Mixed} b The other value to compare. * @param {Function} [callback] The function to customize comparing values. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @param- {Array} [stackA=[]] Internally used track traversed `a` objects. - * @param- {Array} [stackB=[]] Internally used track traversed `b` objects. + * @param- {Array} [stackA=[]] Tracks traversed `a` objects. + * @param- {Array} [stackB=[]] Tracks traversed `b` objects. * @returns {Boolean} Returns `true`, if the values are equivalent, else `false`. * @example * @@ -1373,7 +1404,7 @@ case stringClass: // coerce regexes to strings (http://es5.github.com/#x15.10.6.4) // treat string primitives and their corresponding object instances as equal - return a == b + ''; + return a == String(b); } var isArr = className == arrayClass; if (!isArr) { @@ -1714,11 +1745,10 @@ * @param {Object} [source1, source2, ...] The source objects. * @param {Function} [callback] The function to customize merging properties. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @param- {Object} [deepIndicator] Internally used to indicate that `stackA` - * and `stackB` are arrays of traversed objects instead of source objects. - * @param- {Array} [stackA=[]] Internally used to track traversed source objects. - * @param- {Array} [stackB=[]] Internally used to associate values with their - * source counterparts. + * @param- {Object} [deepIndicator] Indicates that `stackA` and `stackB` are + * arrays of traversed objects, instead of source objects. + * @param- {Array} [stackA=[]] Tracks traversed source objects. + * @param- {Array} [stackB=[]] Associates values with source counterparts. * @returns {Object} Returns the destination object. * @example * @@ -2103,7 +2133,7 @@ callback = lodash.createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection) + ''; + key = String(callback(value, key, collection)); (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); }); return result; @@ -2256,39 +2286,49 @@ * iteration. If a property name or object is passed, it will be used to create * a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @returns {Mixed} Returns the element that passed the callback check, - * else `undefined`. + * @returns {Mixed} Returns the found element, else `undefined`. * @example * - * var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); + * _.find([1, 2, 3, 4], function(num) { return num % 2 == 0; }); * // => 2 * * var food = [ * { 'name': 'apple', 'organic': false, 'type': 'fruit' }, * { 'name': 'banana', 'organic': true, 'type': 'fruit' }, - * { 'name': 'beet', 'organic': false, 'type': 'vegetable' }, - * { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } + * { 'name': 'beet', 'organic': false, 'type': 'vegetable' } * ]; * * // using "_.where" callback shorthand - * var veggie = _.find(food, { 'type': 'vegetable' }); + * _.find(food, { 'type': 'vegetable' }); * // => { 'name': 'beet', 'organic': false, 'type': 'vegetable' } * * // using "_.pluck" callback shorthand - * var healthy = _.find(food, 'organic'); + * _.find(food, 'organic'); * // => { 'name': 'banana', 'organic': true, 'type': 'fruit' } */ function find(collection, callback, thisArg) { - var result; callback = lodash.createCallback(callback, thisArg); - forEach(collection, function(value, index, collection) { - if (callback(value, index, collection)) { - result = value; - return false; + var index = -1, + length = collection ? collection.length : 0; + + if (typeof length == 'number') { + while (++index < length) { + var value = collection[index]; + if (callback(value, index, collection)) { + return value; + } } - }); - return result; + } else { + var result; + forOwn(collection, function(value, index, collection) { + if (callback(value, index, collection)) { + result = value; + return false; + } + }); + return result; + } } /** @@ -2369,7 +2409,7 @@ callback = lodash.createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection) + ''; + key = String(callback(value, key, collection)); (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); }); return result; @@ -3046,6 +3086,38 @@ return result; } + /** + * 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. + * + * @static + * @memberOf _ + * @alias detect + * @category Arrays + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Function|Object|String} [callback=identity] The function called per + * iteration. If a property name or object is passed, it will be used to create + * a "_.pluck" or "_.where" style callback, respectively. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Mixed} Returns the index of the found element, else `-1`. + * @example + * + * _.findIndex(['apple', 'banana', 'beet'], function(food) { return /^b/.test(food); }); + * // => 1 + */ + function findIndex(collection, callback, thisArg) { + var index = -1, + length = collection ? collection.length : 0; + + callback = lodash.createCallback(callback, thisArg); + while (++index < length) { + if (callback(collection[index], index, collection)) { + return index; + } + } + return -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, @@ -3340,7 +3412,7 @@ while (++index < length) { var value = array[index]; if (isLarge) { - var key = value + ''; + var key = String(value); var inited = hasOwnProperty.call(cache[0], key) ? !(seen = cache[0][key]) : (seen = cache[0][key] = []); @@ -3748,7 +3820,7 @@ computed = callback ? callback(value, index, array) : value; if (isLarge) { - var key = computed + ''; + var key = String(computed); var inited = hasOwnProperty.call(cache, key) ? !(seen = cache[key]) : (seen = cache[key] = []); @@ -4033,8 +4105,7 @@ * If `func` is an object, the created callback will return `true` for elements * that contain the equivalent object properties, otherwise it will return `false`. * - * Note: All Lo-Dash methods, that accept a `callback` argument, internally - * use `_.createCallback`. + * Note: All Lo-Dash methods, that accept a `callback` argument, use `_.createCallback`. * * @static * @memberOf _ @@ -4235,7 +4306,7 @@ function memoize(func, resolver) { var cache = {}; return function() { - var key = (resolver ? resolver.apply(this, arguments) : arguments[0]) + ''; + var key = String(resolver ? resolver.apply(this, arguments) : arguments[0]); return hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = func.apply(this, arguments)); @@ -4425,7 +4496,7 @@ * // => 'Moe, Larry & Curly' */ function escape(string) { - return string == null ? '' : (string + '').replace(reUnescapedHtml, escapeHtmlChar); + return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar); } /** @@ -4820,7 +4891,7 @@ * // => 'Moe, Larry & Curly' */ function unescape(string) { - return string == null ? '' : (string + '').replace(reEscapedHtml, unescapeHtmlChar); + return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar); } /** @@ -4841,7 +4912,7 @@ */ function uniqueId(prefix) { var id = ++idCounter; - return (prefix == null ? '' : prefix + '') + id; + return String(prefix == null ? '' : prefix) + id; } /*--------------------------------------------------------------------------*/ @@ -4885,7 +4956,7 @@ * // => '1,2,3' */ function wrapperToString() { - return this.__wrapped__ + ''; + return String(this.__wrapped__); } /** @@ -4988,6 +5059,8 @@ lodash.escape = escape; lodash.every = every; lodash.find = find; + lodash.findIndex = findIndex; + lodash.findKey = findKey; lodash.has = has; lodash.identity = identity; lodash.indexOf = indexOf; diff --git a/dist/lodash.min.js b/dist/lodash.min.js index fbf4a6aab..cc2878e4b 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,39 +4,39 @@ * Build: `lodash modern -o ./dist/lodash.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n){function t(r){function a(n){return n&&typeof n=="object"&&!oe(n)&&Mt.call(n,"__wrapped__")?n:new z(n)}function $(n,t,e){var r=n.length,u=r-t>=e;if(u){var a={};for(e=t-1;++et||typeof n=="undefined")return 1;if(ne?0:e);++r=e;if(u){var a={};for(e=t-1;++et||typeof n=="undefined")return 1;if(ne?0:e);++re?Yt(0,u+e):e)||0,typeof u=="number"?a=-1<(Z(n)?n.indexOf(t,e):gt(n,t,e)):ae(n,function(n){return++ru&&(u=i)}}else t=!t&&Z(n)?B:a.createCallback(t,e),ot(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function ct(n,t,e,r){if(!n)return e;var u=3>arguments.length;t=a.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=ie(n),u=i.length;return t=a.createCallback(t,r,4),ot(n,function(r,a,f){a=i?i[--u]:--u,e=o?(o=!1,n[a]):t(e,n[a],a,f)}),e}function pt(n,t,e){var r;t=a.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++ee?Yt(0,u+e):e||0)-1;else if(e)return r=yt(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])gt(f,p))&&((e||c)&&f.push(p),i.push(r))}return i -}function bt(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:g,variable:"",imports:{_:a}},xt={a:"q,w,g",g:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b":">",'"':""","'":"'"},ce=L(fe),le=R(xt,{g:xt.g.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=o.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),e:"u[i]=d?d(u[i],m[i]):m[i]"}),pe=R(xt),se=function(n){if(!n||Ht.call(n)!=x)return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Pt(t))&&Pt(e); -return e?n==e||Pt(n)==e:V(n)};return St&&u&&typeof Vt=="function"&&(_t=dt(Vt,r)),Vt=8==ne("08")?ne:function(n,t){return ne(Z(n)?n.replace(h,""):n,t||0)},a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=le,a.at=function(n){for(var t=-1,e=zt.apply(Bt,P(arguments,1)),r=e.length,u=Ct(r);++tu&&(u=i)}}else t=!t&&Z(n)?B:a.createCallback(t,e),ot(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function ct(n,t,e,r){if(!n)return e;var u=3>arguments.length;t=a.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=ie(n),u=i.length;return t=a.createCallback(t,r,4),ot(n,function(r,a,f){a=i?i[--u]:--u,e=o?(o=!1,n[a]):t(e,n[a],a,f)}),e}function pt(n,t,e){var r;t=a.createCallback(t,e),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++ee?Yt(0,u+e):e||0)-1; +else if(e)return r=yt(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])gt(f,p))&&((e||c)&&f.push(p),i.push(r))}return i}function bt(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:g,variable:"",imports:{_:a}},xt={a:"q,w,g",g:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b":">",'"':""","'":"'"},ce=L(fe),le=R(xt,{g:xt.g.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=o.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),e:"u[i]=d?d(u[i],m[i]):m[i]"}),pe=R(xt),se=function(n){if(!n||Ht.call(n)!=x)return!1;var t=n.valueOf,e=typeof t=="function"&&(e=Pt(t))&&Pt(e); +return e?n==e||Pt(n)==e:V(n)};return Nt&&u&&typeof Vt=="function"&&(_t=dt(Vt,r)),Vt=8==ne("08")?ne:function(n,t){return ne(Z(n)?n.replace(h,""):n,t||0)},a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=le,a.at=function(n){for(var t=-1,e=zt.apply(Bt,P(arguments,1)),r=e.length,u=Ct(r);++tgt(f,c)){o&&f.push(c);for(var p=e;--p;)if(!(r[p]||(r[p]=$(t[p],0,100)))(c))continue n;i.push(c)}}return i},a.invert=L,a.invoke=function(n,t){var e=P(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Ct(typeof a=="number"?a:0);return ot(n,function(n){o[++r]=(u?t:n[t]).apply(n,e) -}),o},a.keys=ie,a.map=it,a.max=ft,a.memoize=function(n,t){var e={};return function(){var r=(t?t.apply(this,arguments):arguments[0])+"";return Mt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=nt,a.min=function(n,t,e){var r=1/0,u=r;if(!t&&oe(n)){e=-1;for(var o=n.length;++egt(f,c)){o&&f.push(c);for(var p=e;--p;)if(!(r[p]||(r[p]=$(t[p],0,100)))(c))continue n;i.push(c)}}return i},a.invert=L,a.invoke=function(n,t){var e=P(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Ct(typeof a=="number"?a:0);return ot(n,function(n){o[++r]=(u?t:n[t]).apply(n,e) +}),o},a.keys=ie,a.map=it,a.max=ft,a.memoize=function(n,t){var e={};return function(){var r=$t(t?t.apply(this,arguments):arguments[0]);return Mt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=nt,a.min=function(n,t,e){var r=1/0,u=r;if(!t&&oe(n)){e=-1;for(var o=n.length;++egt(o,e,1))&&(u[e]=n)}),u},a.once=function(n){var t,e;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},a.pairs=function(n){for(var t=-1,e=ie(n),r=e.length,u=Ct(r);++te?Yt(0,r+e):Zt(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},a.mixin=wt,a.noConflict=function(){return r._=qt,this -},a.parseInt=Vt,a.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Kt(te()*((+t||0)-n+1))},a.reduce=ct,a.reduceRight=lt,a.result=function(n,t){var r=n?n[t]:e;return W(r)?n[t]():r},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ie(n).length},a.some=pt,a.sortedIndex=yt,a.template=function(n,t,r){var u=a.templateSettings;n||(n=""),r=pe({},r,u);var o,i=pe({},r.imports,u.imports),u=ie(i),i=tt(i),p=0,v=r.interpolate||y,h="__p+='",v=It((r.escape||y).source+"|"+v.source+"|"+(v===g?s:y).source+"|"+(r.evaluate||y).source+"|$","g"); -n.replace(v,function(t,e,r,u,a,i){return r||(r=u),h+=n.slice(p,i).replace(b,T),e&&(h+="'+__e("+e+")+'"),a&&(o=!0,h+="';"+a+";__p+='"),r&&(h+="'+((__t=("+r+"))==null?'':__t)+'"),p=i+t.length,t}),h+="';\n",v=r=r.variable,v||(r="obj",h="with("+r+"){"+h+"}"),h=(o?h.replace(f,""):h).replace(c,"$1").replace(l,"$1;"),h="function("+r+"){"+(v?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+h+"return __p}";try{var m=Nt(u,"return "+h).apply(e,i) -}catch(d){throw d.source=h,d}return t?m(t):(m.source=h,m)},a.unescape=function(n){return null==n?"":(n+"").replace(p,M)},a.uniqueId=function(n){var t=++o;return(null==n?"":n+"")+t},a.all=rt,a.any=pt,a.detect=at,a.foldl=ct,a.foldr=lt,a.include=et,a.inject=ct,ae(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Ut.apply(t,arguments),n.apply(a,t)})}),a.first=st,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u;for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++ -}else if(r=t,null==r||e)return n[u-1];return P(n,Yt(0,u-r))}},a.take=st,a.head=st,ae(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return null==t||e&&typeof t!="function"?r:new z(r)})}),a.VERSION="1.0.1",a.prototype.toString=function(){return this.__wrapped__+""},a.prototype.value=jt,a.prototype.valueOf=jt,ot(["join","pop","shift"],function(n){var t=Bt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),ot(["push","reverse","sort","unshift"],function(n){var t=Bt[n]; -a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),ot(["concat","slice","splice"],function(n){var t=Bt[n];a.prototype[n]=function(){return new z(t.apply(this.__wrapped__,arguments))}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global;a.global===a&&(n=a);var o=0,i={},f=/\b__p\+='';/g,c=/\b(__p\+=)''\+/g,l=/(__e\(.*?\)|\b__t\))\+'';/g,p=/&(?:amp|lt|gt|quot|#39);/g,s=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,v=/\w*$/,g=/<%=([\s\S]+?)%>/g,h=/^0+(?=.$)/,y=/($^)/,m=/[&<>"']/g,b=/['\n\r\t\u2028\u2029\\]/g,d="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),_="[object Arguments]",k="[object Array]",w="[object Boolean]",j="[object Date]",C="[object Number]",x="[object Object]",O="[object RegExp]",N="[object String]",S={"[object Function]":!1}; -S[_]=S[k]=S[w]=S[j]=S[C]=S[x]=S[O]=S[N]=!0;var A={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},E={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},I=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=I,define(function(){return I})):r&&!r.nodeType?u?(u.exports=I)._=I:r._=I:n._=I})(this); \ No newline at end of file +},a.contains=et,a.escape=function(n){return null==n?"":$t(n).replace(m,D)},a.every=rt,a.find=at,a.findIndex=function(n,t,e){var r=-1,u=n?n.length:0;for(t=a.createCallback(t,e);++re?Yt(0,r+e):Zt(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},a.mixin=wt,a.noConflict=function(){return r._=qt,this},a.parseInt=Vt,a.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Kt(te()*((+t||0)-n+1))},a.reduce=ct,a.reduceRight=lt,a.result=function(n,t){var r=n?n[t]:e;return W(r)?n[t]():r},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ie(n).length +},a.some=pt,a.sortedIndex=yt,a.template=function(n,t,r){var u=a.templateSettings;n||(n=""),r=pe({},r,u);var o,i=pe({},r.imports,u.imports),u=ie(i),i=tt(i),p=0,v=r.interpolate||y,h="__p+='",v=Et((r.escape||y).source+"|"+v.source+"|"+(v===g?s:y).source+"|"+(r.evaluate||y).source+"|$","g");n.replace(v,function(t,e,r,u,a,i){return r||(r=u),h+=n.slice(p,i).replace(b,T),e&&(h+="'+__e("+e+")+'"),a&&(o=!0,h+="';"+a+";__p+='"),r&&(h+="'+((__t=("+r+"))==null?'':__t)+'"),p=i+t.length,t}),h+="';\n",v=r=r.variable,v||(r="obj",h="with("+r+"){"+h+"}"),h=(o?h.replace(f,""):h).replace(c,"$1").replace(l,"$1;"),h="function("+r+"){"+(v?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+h+"return __p}"; +try{var m=It(u,"return "+h).apply(e,i)}catch(d){throw d.source=h,d}return t?m(t):(m.source=h,m)},a.unescape=function(n){return null==n?"":$t(n).replace(p,M)},a.uniqueId=function(n){var t=++o;return $t(null==n?"":n)+t},a.all=rt,a.any=pt,a.detect=at,a.foldl=ct,a.foldr=lt,a.include=et,a.inject=ct,ae(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Ut.apply(t,arguments),n.apply(a,t)})}),a.first=st,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var o=u; +for(t=a.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,null==r||e)return n[u-1];return P(n,Yt(0,u-r))}},a.take=st,a.head=st,ae(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return null==t||e&&typeof t!="function"?r:new z(r)})}),a.VERSION="1.0.1",a.prototype.toString=function(){return $t(this.__wrapped__)},a.prototype.value=jt,a.prototype.valueOf=jt,ot(["join","pop","shift"],function(n){var t=Bt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments) +}}),ot(["push","reverse","sort","unshift"],function(n){var t=Bt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),ot(["concat","slice","splice"],function(n){var t=Bt[n];a.prototype[n]=function(){return new z(t.apply(this.__wrapped__,arguments))}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global;a.global===a&&(n=a);var o=0,i={},f=/\b__p\+='';/g,c=/\b(__p\+=)''\+/g,l=/(__e\(.*?\)|\b__t\))\+'';/g,p=/&(?:amp|lt|gt|quot|#39);/g,s=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,v=/\w*$/,g=/<%=([\s\S]+?)%>/g,h=/^0+(?=.$)/,y=/($^)/,m=/[&<>"']/g,b=/['\n\r\t\u2028\u2029\\]/g,d="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),_="[object Arguments]",k="[object Array]",w="[object Boolean]",j="[object Date]",C="[object Number]",x="[object Object]",O="[object RegExp]",I="[object String]",N={"[object Function]":!1}; +N[_]=N[k]=N[w]=N[j]=N[C]=N[x]=N[O]=N[I]=!0;var S={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},A={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},E=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=E,define(function(){return E})):r&&!r.nodeType?u?(u.exports=E)._=E:r._=E:n._=E})(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index 7196515b4..cd01f0653 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -105,7 +105,7 @@ /** Used to detect if a method is native */ var reNative = RegExp('^' + - (objectRef.valueOf + '') + String(objectRef.valueOf) .replace(/[.*+?^${}()|[\]\\]/g, '\\$&') .replace(/valueOf|for [^\]]+/g, '.+?') + '$' ); @@ -400,7 +400,7 @@ function isNode(value) { // IE < 9 presents DOM nodes as `Object` objects except they have `toString` // methods that are `typeof` "string" and still can coerce nodes to strings - return typeof value.toString != 'function' && typeof (value + '') == 'string'; + return typeof value.toString != 'function' && typeof String(value) == 'string'; } /** @@ -736,8 +736,8 @@ * @param {Boolean} [deep=false] A flag to indicate a deep clone. * @param {Function} [callback] The function to customize cloning values. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @param- {Array} [stackA=[]] Internally used to track traversed source objects. - * @param- {Array} [stackB=[]] Internally used to associate clones with source counterparts. + * @param- {Array} [stackA=[]] Tracks traversed source objects. + * @param- {Array} [stackB=[]] Associates clones with source counterparts. * @returns {Mixed} Returns the cloned `value`. * @example * @@ -781,8 +781,8 @@ * @category Objects * @param {Object} object The destination object. * @param {Object} [source1, source2, ...] The source objects. - * @param- {Object} [guard] Internally used to allow working with `_.reduce` - * without using its callback's `key` and `object` arguments as sources. + * @param- {Object} [guard] Allows working with `_.reduce` without using its + * callback's `key` and `object` arguments as sources. * @returns {Object} Returns the destination object. * @example * @@ -978,8 +978,8 @@ * @param {Mixed} b The other value to compare. * @param {Function} [callback] The function to customize comparing values. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @param- {Array} [stackA=[]] Internally used track traversed `a` objects. - * @param- {Array} [stackB=[]] Internally used track traversed `b` objects. + * @param- {Array} [stackA=[]] Tracks traversed `a` objects. + * @param- {Array} [stackB=[]] Tracks traversed `b` objects. * @returns {Boolean} Returns `true`, if the values are equivalent, else `false`. * @example * @@ -1514,7 +1514,7 @@ callback = createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection) + ''; + key = String(callback(value, key, collection)); (hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1); }); return result; @@ -1667,39 +1667,49 @@ * iteration. If a property name or object is passed, it will be used to create * a "_.pluck" or "_.where" style callback, respectively. * @param {Mixed} [thisArg] The `this` binding of `callback`. - * @returns {Mixed} Returns the element that passed the callback check, - * else `undefined`. + * @returns {Mixed} Returns the found element, else `undefined`. * @example * - * var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); + * _.find([1, 2, 3, 4], function(num) { return num % 2 == 0; }); * // => 2 * * var food = [ * { 'name': 'apple', 'organic': false, 'type': 'fruit' }, * { 'name': 'banana', 'organic': true, 'type': 'fruit' }, - * { 'name': 'beet', 'organic': false, 'type': 'vegetable' }, - * { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } + * { 'name': 'beet', 'organic': false, 'type': 'vegetable' } * ]; * * // using "_.where" callback shorthand - * var veggie = _.find(food, { 'type': 'vegetable' }); + * _.find(food, { 'type': 'vegetable' }); * // => { 'name': 'beet', 'organic': false, 'type': 'vegetable' } * * // using "_.pluck" callback shorthand - * var healthy = _.find(food, 'organic'); + * _.find(food, 'organic'); * // => { 'name': 'banana', 'organic': true, 'type': 'fruit' } */ function find(collection, callback, thisArg) { - var result; callback = createCallback(callback, thisArg); - forEach(collection, function(value, index, collection) { - if (callback(value, index, collection)) { - result = value; - return indicatorObject; + var index = -1, + length = collection ? collection.length : 0; + + if (typeof length == 'number') { + while (++index < length) { + var value = collection[index]; + if (callback(value, index, collection)) { + return value; + } } - }); - return result; + } else { + var result; + forOwn(collection, function(value, index, collection) { + if (callback(value, index, collection)) { + result = value; + return indicatorObject; + } + }); + return result; + } } function findWhere(object, properties) { @@ -1783,7 +1793,7 @@ callback = createCallback(callback, thisArg); forEach(collection, function(value, key, collection) { - key = callback(value, key, collection) + ''; + key = String(callback(value, key, collection)); (hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value); }); return result; @@ -3370,8 +3380,7 @@ * If `func` is an object, the created callback will return `true` for elements * that contain the equivalent object properties, otherwise it will return `false`. * - * Note: All Lo-Dash methods, that accept a `callback` argument, internally - * use `_.createCallback`. + * Note: All Lo-Dash methods, that accept a `callback` argument, use `_.createCallback`. * * @static * @memberOf _ @@ -3568,7 +3577,7 @@ function memoize(func, resolver) { var cache = {}; return function() { - var key = (resolver ? resolver.apply(this, arguments) : arguments[0]) + ''; + var key = String(resolver ? resolver.apply(this, arguments) : arguments[0]); return hasOwnProperty.call(cache, key) ? cache[key] : (cache[key] = func.apply(this, arguments)); @@ -3727,7 +3736,7 @@ * // => 'Moe, Larry & Curly' */ function escape(string) { - return string == null ? '' : (string + '').replace(reUnescapedHtml, escapeHtmlChar); + return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar); } /** @@ -4051,7 +4060,7 @@ * // => 'Moe, Larry & Curly' */ function unescape(string) { - return string == null ? '' : (string + '').replace(reEscapedHtml, unescapeHtmlChar); + return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar); } /** @@ -4164,7 +4173,7 @@ * // => '1,2,3' */ function wrapperToString() { - return this.__wrapped__ + ''; + return String(this.__wrapped__); } /** diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index daedc7d07..83d1789ee 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -10,12 +10,13 @@ if(e)for(var u in e)n[u]=e[u]}return n}function h(n){if(!n)return n;for(var t=1, var i=typeof n,a=typeof t;if(n===n&&(!n||"function"!=i&&"object"!=i)&&(!t||"function"!=a&&"object"!=a))return K;if(n==J||t==J)return n===t;if(a=xt.call(n),i=xt.call(t),a!=i)return K;switch(a){case it:case at:return+n==+t;case ft:return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case lt:case pt:return n==t+""}if(i=a==ot,!i){if(n instanceof e||t instanceof e)return b(n.__wrapped__||n,t.__wrapped__||t,u,o);if(a!=ct)return K;var a=n.constructor,f=t.constructor;if(a!=f&&(!d(a)||!(a instanceof a&&d(f)&&f instanceof f)))return K }for(u||(u=[]),o||(o=[]),a=u.length;a--;)if(u[a]==n)return o[a]==t;var c=H,l=0;if(u.push(n),o.push(t),i){if(l=t.length,c=l==n.length)for(;l--&&(c=b(n[l],t[l],u,o)););return c}return r(t,function(t,r,e){return jt.call(e,r)?(l++,!(c=jt.call(n,r)&&b(n[r],t,u,o))&&Z):void 0}),c&&r(n,function(n,t,r){return jt.call(r,t)?!(c=-1<--l)&&Z:void 0}),c}function d(n){return typeof n=="function"}function j(n){return n?st[typeof n]:K}function w(n){return typeof n=="number"||xt.call(n)==ft}function A(n){return typeof n=="string"||xt.call(n)==pt }function x(n){for(var t=-1,r=$t(n),e=r.length,u=Array(e);++te&&(e=r,u=n) -});else for(;++ou&&(u=r);return u}function R(n,r,e,u){if(!n)return e;var o=3>arguments.length;r=V(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=$t(n),u=i.length;return t=V(t,e,4),k(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,r,e){var u;r=V(r,e),e=-1;var o=n?n.length:0; -if(typeof o=="number")for(;++er?Bt(0,u+r):r||0)-1; -else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])T(a,f))&&(r&&a.push(f),i.push(e)) -}return i}function U(n,t){return Dt.fastBind||Ot&&2"']/g,et=/['\n\r\t\u2028\u2029\\]/g,ut="[object Arguments]",ot="[object Array]",it="[object Boolean]",at="[object Date]",ft="[object Number]",ct="[object Object]",lt="[object RegExp]",pt="[object String]",st={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},vt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},gt=[],X={},ht=n._,yt=RegExp("^"+(X.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),mt=Math.ceil,_t=n.clearTimeout,bt=gt.concat,dt=Math.floor,jt=X.hasOwnProperty,wt=gt.push,At=n.setTimeout,xt=X.toString,Ot=yt.test(Ot=l.bind)&&Ot,Et=yt.test(Et=Array.isArray)&&Et,St=n.isFinite,Nt=n.isNaN,kt=yt.test(kt=Object.keys)&&kt,Bt=Math.max,Ft=Math.min,Rt=Math.random,X=yt.test(n.attachEvent),qt=Ot&&!/\n|true/.test(Ot+X),Dt={}; +});return u}function N(n,r,e){r=V(r,e),e=-1;var u=n?n.length:0;if(typeof u!="number"){var o;return t(n,function(n,t,e){return r(n,t,e)?(o=n,Z):void 0}),o}for(;++ee&&(e=r,u=n)});else for(;++ou&&(u=r);return u}function R(n,r,e,u){if(!n)return e;var o=3>arguments.length;r=V(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=$t(n),u=i.length; +return t=V(t,e,4),k(n,function(e,a,f){a=i?i[--u]:--u,r=o?(o=K,n[a]):t(r,n[a],a,f)}),r}function D(n,r,e){var u;r=V(r,e),e=-1;var o=n?n.length:0;if(typeof o=="number")for(;++er?Bt(0,u+r):r||0)-1;else if(r)return e=C(n,t),n[e]===t?e:-1;for(;++e>>1,r(n[e])T(a,f))&&(r&&a.push(f),i.push(e))}return i}function U(n,t){return Dt.fastBind||Ot&&2"']/g,et=/['\n\r\t\u2028\u2029\\]/g,ut="[object Arguments]",ot="[object Array]",it="[object Boolean]",at="[object Date]",ft="[object Number]",ct="[object Object]",lt="[object RegExp]",pt="[object String]",st={"boolean":K,"function":H,object:H,number:K,string:K,undefined:K},vt={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},gt=[],X={},ht=n._,yt=RegExp("^"+(X.valueOf+"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/valueOf|for [^\]]+/g,".+?")+"$"),mt=Math.ceil,_t=n.clearTimeout,bt=gt.concat,dt=Math.floor,jt=X.hasOwnProperty,wt=gt.push,At=n.setTimeout,xt=X.toString,Ot=yt.test(Ot=l.bind)&&Ot,Et=yt.test(Et=Array.isArray)&&Et,St=n.isFinite,Nt=n.isNaN,kt=yt.test(kt=Object.keys)&&kt,Bt=Math.max,Ft=Math.min,Rt=Math.random,X=yt.test(n.attachEvent),qt=Ot&&!/\n|true/.test(Ot+X),Dt={}; (function(){var n={0:1,length:1};Dt.argsObject=arguments.constructor==Object,Dt.fastBind=Ot&&!qt,Dt.spliceObjects=(gt.splice.call(n,0,1),!n[0])})(1),e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},f.prototype=e.prototype,s(arguments)||(s=function(n){return n?jt.call(n,"callee"):K});var Mt=Et||function(n){return Dt.argsObject&&n instanceof Array||xt.call(n)==ot},$t=kt?function(n){return j(n)?kt(n):[]}:v,It={"&":"&","<":"<",">":">",'"':""","'":"'"},Tt=m(It); d(/x/)&&(d=function(n){return n instanceof Function||"[object Function]"==xt.call(n)});var zt=B;e.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},e.bind=U,e.bindAll=function(n){for(var t=bt.apply(gt,arguments),r=1`Arrays` * [`_.compact`](#_compactarray) +* [`_.detect`](#_findindexcollection--callbackidentity-thisarg) * [`_.difference`](#_differencearray--array1-array2-) * [`_.drop`](#_restarray--callbackn1-thisarg) +* [`_.findIndex`](#_findindexcollection--callbackidentity-thisarg) * [`_.first`](#_firstarray--callbackn-thisarg) * [`_.flatten`](#_flattenarray--isshallowfalse-callbackidentity-thisarg) * [`_.head`](#_firstarray--callbackn-thisarg) @@ -106,6 +108,15 @@ + + +## `Object` +* [`_.detect`](#_findkeycollection--callbackidentity-thisarg) +* [`_.findKey`](#_findkeycollection--callbackidentity-thisarg) + + + + ## `Objects` @@ -212,7 +223,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3219 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3254 "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. @@ -236,7 +247,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3249 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3284 "View in source") [Ⓣ][1] Creates an array of `array` elements not present in the other arrays using strict equality for comparisons, i.e. `===`. @@ -258,10 +269,39 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); + + +### `_.findIndex(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3319 "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. + +#### Aliases +*detect* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the index of the found element, else `-1`. + +#### Example +```js +_.findIndex(['apple', 'banana', 'beet'], function(food) { return /^b/.test(food); }); +// => 1 +``` + +* * * + + + + ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3322 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3389 "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)*. @@ -321,7 +361,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array [, isShallow=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3384 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3451 "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)*. @@ -364,7 +404,7 @@ _.flatten(stooges, 'quotes'); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3437 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3504 "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. @@ -396,7 +436,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#L3511 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3578 "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)*. @@ -453,7 +493,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3545 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3612 "View in source") [Ⓣ][1] Computes the intersection of all the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -477,7 +517,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#L3637 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3704 "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). @@ -534,7 +574,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3678 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3745 "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. @@ -563,7 +603,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#L3719 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3786 "View in source") [Ⓣ][1] Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. @@ -601,7 +641,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3798 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3865 "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)*. @@ -661,7 +701,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3862 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3929 "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)*. @@ -710,7 +750,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3894 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3961 "View in source") [Ⓣ][1] Computes the union of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -734,7 +774,7 @@ _.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#L3941 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4008 "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)*. @@ -781,7 +821,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4000 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4067 "View in source") [Ⓣ][1] Creates an array with all occurrences of the passed values removed using strict equality for comparisons, i.e. `===`. @@ -806,7 +846,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4031 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4098 "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. @@ -830,7 +870,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_.zipObject(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4060 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4127 "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`. @@ -865,7 +905,7 @@ _.zipObject(['moe', 'larry'], [30, 40]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L246 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L243 "View in source") [Ⓣ][1] Creates a `lodash` object, that wraps the given `value`, to enable method chaining. @@ -896,7 +936,7 @@ The wrapper functions `first` and `last` return wrapped values when `n` is passe ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5086 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5152 "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. @@ -926,7 +966,7 @@ _([1, 2, 3, 4]) ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5103 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5169 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -947,7 +987,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5120 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5186 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -978,7 +1018,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2245 "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. @@ -1006,7 +1046,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2287 "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. @@ -1044,7 +1084,7 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2316 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2341 "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)*. @@ -1080,7 +1120,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2368 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2393 "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)*. @@ -1126,7 +1166,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2429 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2454 "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)*. @@ -1172,7 +1212,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2496 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2519 "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)*. @@ -1189,26 +1229,25 @@ If an object is passed for `callback`, the created "_.where" style callback will 3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. #### Returns -*(Mixed)*: Returns the element that passed the callback check, else `undefined`. +*(Mixed)*: Returns the found element, else `undefined`. #### Example ```js -var even = _.find([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +_.find([1, 2, 3, 4], function(num) { return num % 2 == 0; }); // => 2 var food = [ { 'name': 'apple', 'organic': false, 'type': 'fruit' }, { 'name': 'banana', 'organic': true, 'type': 'fruit' }, - { 'name': 'beet', 'organic': false, 'type': 'vegetable' }, - { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } + { 'name': 'beet', 'organic': false, 'type': 'vegetable' } ]; // using "_.where" callback shorthand -var veggie = _.find(food, { 'type': 'vegetable' }); +_.find(food, { 'type': 'vegetable' }); // => { 'name': 'beet', 'organic': false, 'type': 'vegetable' } // using "_.pluck" callback shorthand -var healthy = _.find(food, 'organic'); +_.find(food, 'organic'); // => { 'name': 'banana', 'organic': true, 'type': 'fruit' } ``` @@ -1220,7 +1259,7 @@ var healthy = _.find(food, 'organic'); ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2531 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2566 "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`. @@ -1252,7 +1291,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2581 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2616 "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)*. @@ -1289,7 +1328,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2614 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2649 "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`. @@ -1318,7 +1357,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2666 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2701 "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)*. @@ -1363,7 +1402,7 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2723 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2758 "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)*. @@ -1405,7 +1444,7 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2792 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2827 "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)*. @@ -1447,7 +1486,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2842 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2877 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1477,7 +1516,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2874 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2909 "View in source") [Ⓣ][1] Reduces a `collection` to a value that 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)*. @@ -1515,7 +1554,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#L2917 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2952 "View in source") [Ⓣ][1] This method is similar to `_.reduce`, except that it iterates over a `collection` from right to left. @@ -1546,7 +1585,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#L2977 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3012 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1589,7 +1628,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2998 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3033 "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. @@ -1613,7 +1652,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3031 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3066 "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. @@ -1643,7 +1682,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3078 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3113 "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)*. @@ -1689,7 +1728,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3169 "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)*. @@ -1726,7 +1765,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3169 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3204 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1750,7 +1789,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3201 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3236 "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. @@ -1787,7 +1826,7 @@ _.where(stooges, { 'age': 40 }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4100 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4167 "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. @@ -1815,7 +1854,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4133 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4200 "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. @@ -1846,7 +1885,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4164 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4231 "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. @@ -1877,7 +1916,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4210 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4277 "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. @@ -1918,7 +1957,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4300 "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. @@ -1945,11 +1984,11 @@ welcome('moe'); ### `_.createCallback([func=identity, thisArg, argCount=3])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4293 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4359 "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`. -Note: All Lo-Dash methods, that accept a `callback` argument, internally use `_.createCallback`. +Note: All Lo-Dash methods, that accept a `callback` argument, use `_.createCallback`. #### Arguments 1. `[func=identity]` *(Mixed)*: The value to convert to a callback. @@ -1999,7 +2038,7 @@ _.toLookup(stooges, 'name'); ### `_.debounce(func, wait, immediate)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4359 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4425 "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 `true` for `immediate` to cause debounce to invoke `func` on the leading, instead of the trailing, edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -2025,7 +2064,7 @@ jQuery(window).on('resize', lazyLayout); ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4401 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4467 "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. @@ -2050,7 +2089,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4427 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4493 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -2077,7 +2116,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4451 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4517 "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. @@ -2103,7 +2142,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4478 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4544 "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. @@ -2129,7 +2168,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4513 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4579 "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. @@ -2156,7 +2195,7 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4544 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4610 "View in source") [Ⓣ][1] This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. @@ -2193,7 +2232,7 @@ options.imports ### `_.throttle(func, wait)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4566 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4632 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. If the throttled function is invoked more than once during the `wait` timeout, `func` will also be called on the trailing edge of the timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2218,7 +2257,7 @@ jQuery(window).on('scroll', throttled); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4619 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4685 "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. @@ -2247,6 +2286,42 @@ hello(); + + +## `“Object” Methods` + + + +### `_.findKey(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L917 "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. + +#### Aliases +*detect* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function|Object|String)*: The function called per iteration. If a property name or object is passed, it will be used to create a "_.pluck" or "_.where" style callback, respectively. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Mixed)*: Returns the key of the found element, else `undefined`. + +#### Example +```js +_.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; }); +// => 'b' +``` + +* * * + + + + + + + ## `“Objects” Methods` @@ -2254,7 +2329,7 @@ hello(); ### `_.assign(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1112 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1138 "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)*. @@ -2292,7 +2367,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1167 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1193 "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)*. @@ -2339,7 +2414,7 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1292 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1318 "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)*. @@ -2385,7 +2460,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1316 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1342 "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. @@ -2411,7 +2486,7 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L932 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L958 "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`. @@ -2447,7 +2522,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L957 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L983 "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`. @@ -2475,7 +2550,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1333 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1359 "View in source") [Ⓣ][1] Creates a sorted array of all enumerable properties, own and inherited, of `object` that have function values. @@ -2502,7 +2577,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1358 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1384 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2527,7 +2602,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1375 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1401 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2551,7 +2626,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L893 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L888 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2578,7 +2653,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L975 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1001 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2605,7 +2680,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1401 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1427 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2629,7 +2704,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1418 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1444 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2653,7 +2728,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1435 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1461 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2677,7 +2752,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1460 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1486 "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". @@ -2707,7 +2782,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1519 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1545 "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)*. @@ -2752,7 +2827,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1703 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1729 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2790,7 +2865,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1720 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1746 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2814,7 +2889,7 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1783 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1809 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. @@ -2849,7 +2924,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1805 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1831 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2876,7 +2951,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1822 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1848 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -2900,7 +2975,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1750 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1776 "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('')`)* @@ -2930,7 +3005,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1850 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1876 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -2965,7 +3040,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1875 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1901 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -2989,7 +3064,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1892 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1918 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -3013,7 +3088,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1909 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1935 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -3037,7 +3112,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L994 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1020 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -3061,7 +3136,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1969 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1994 "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)*. @@ -3117,7 +3192,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2076 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2101 "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)*. @@ -3148,7 +3223,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2110 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2135 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3172,7 +3247,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2148 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2173 "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)*. @@ -3203,7 +3278,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2185 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2210 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3234,7 +3309,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4643 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4709 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3258,7 +3333,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4661 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4727 "View in source") [Ⓣ][1] This function returns the first argument passed to it. @@ -3283,7 +3358,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4687 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4753 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3313,7 +3388,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4716 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4782 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3333,7 +3408,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4737 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4803 "View in source") [Ⓣ][1] Converts the given `value` into an integer of the specified `radix`. @@ -3359,7 +3434,7 @@ _.parseInt('08'); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4760 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4826 "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. @@ -3387,7 +3462,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4799 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4865 "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. @@ -3422,7 +3497,7 @@ _.result(object, 'stuff'); ### `_.runInContext([context=window])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L134 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L131 "View in source") [Ⓣ][1] Create a new `lodash` function using the given `context` object. @@ -3440,7 +3515,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4886 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4952 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3524,7 +3599,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5011 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5077 "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)*. @@ -3556,7 +3631,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5038 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5104 "View in source") [Ⓣ][1] The opposite of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3580,7 +3655,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5058 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5124 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3614,7 +3689,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L441 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L438 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -3633,7 +3708,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5292 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5360 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3645,7 +3720,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L260 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L257 "View in source") [Ⓣ][1] *(Object)*: An object used to flag environments features. @@ -3657,7 +3732,7 @@ A reference to the `lodash` function. ### `_.support.argsClass` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L285 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L282 "View in source") [Ⓣ][1] *(Boolean)*: Detect if an `arguments` object's [[Class]] is resolvable *(all but Firefox < `4`, IE < `9`)*. @@ -3669,7 +3744,7 @@ A reference to the `lodash` function. ### `_.support.argsObject` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L277 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L274 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `arguments` objects are `Object` objects *(all but Opera < `10.5`)*. @@ -3681,7 +3756,7 @@ A reference to the `lodash` function. ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L298 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L295 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `prototype` properties are enumerable by default. @@ -3695,7 +3770,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.fastBind` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L306 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L303 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `Function#bind` exists and is inferred to be fast *(all but V8)*. @@ -3707,7 +3782,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.fastKeys` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L314 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L311 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `Object.keys` exists and is inferred to be fast *(Firefox, IE, Opera, V8)*. @@ -3719,7 +3794,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumArgs` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L331 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L328 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `arguments` object indexes are non-enumerable *(Firefox < `4`, IE < `9`, PhantomJS, Safari < `5.1`)*. @@ -3731,7 +3806,7 @@ Firefox < `3.6`, Opera > `9.50` - Opera < `11.60`, and Safari < `5.1` *(if the p ### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L342 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L339 "View in source") [Ⓣ][1] *(Boolean)*: Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -3745,7 +3820,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.ownLast` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L322 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L319 "View in source") [Ⓣ][1] *(Boolean)*: Detect if own properties are iterated after inherited properties *(all but IE < `9`)*. @@ -3757,7 +3832,7 @@ In IE < `9` an objects own properties, shadowing non-enumerable ones, are made n ### `_.support.spliceObjects` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L356 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L353 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -3771,7 +3846,7 @@ Firefox < `10`, IE compatibility mode, and IE < `9` have buggy Array `shift()` a ### `_.support.unindexedChars` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L367 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L364 "View in source") [Ⓣ][1] *(Boolean)*: Detect lack of support for accessing string characters by index. @@ -3785,7 +3860,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L393 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L390 "View in source") [Ⓣ][1] *(Object)*: By default, the template delimiters used by Lo-Dash are similar to those in embedded Ruby *(ERB)*. Change the following template settings to use alternative delimiters. @@ -3797,7 +3872,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L401 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L398 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3809,7 +3884,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L409 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L406 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3821,7 +3896,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L417 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L414 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3833,7 +3908,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L425 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L422 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -3845,7 +3920,7 @@ IE < `8` can't access characters by index and IE `8` can only access characters ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L433 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L430 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template. diff --git a/doc/parse.php b/doc/parse.php index e80d37ebb..978138945 100644 --- a/doc/parse.php +++ b/doc/parse.php @@ -21,7 +21,7 @@ // generate Markdown $markdown = docdown(array( 'path' => '../' . $file, - 'title' => 'Lo-Dash v1.1.0', + 'title' => 'Lo-Dash v1.0.1', 'toc' => 'categories', 'url' => 'https://github.com/bestiejs/lodash/blob/master/lodash.js' ));