From fdd0a3357119a2f01204b3637c267b268d602306 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 29 Jul 2013 00:26:38 -0700 Subject: [PATCH] Rebuild docs and dist. Former-commit-id: ae113f2c04eef7a34b1b49bca3e6dcb7402f723c --- dist/lodash.compat.js | 388 +++++++++++++++++++--- dist/lodash.compat.min.js | 90 ++--- dist/lodash.js | 379 ++++++++++++++++++--- dist/lodash.min.js | 85 ++--- dist/lodash.underscore.js | 114 ++++--- dist/lodash.underscore.min.js | 61 ++-- doc/README.md | 608 +++++++++++++++++++++++++--------- 7 files changed, 1307 insertions(+), 418 deletions(-) diff --git a/dist/lodash.compat.js b/dist/lodash.compat.js index a40cf1684..ef02e644a 100644 --- a/dist/lodash.compat.js +++ b/dist/lodash.compat.js @@ -581,7 +581,6 @@ * * @name _ * @constructor - * @alias chain * @category Chaining * @param {Mixed} value The value to wrap in a `lodash` instance. * @returns {Object} Returns a `lodash` instance. @@ -618,9 +617,11 @@ * * @private * @param {Mixed} value The value to wrap in a `lodash` instance. + * @param {Boolean} chainAll A flag to enable chaining for all methods * @returns {Object} Returns a `lodash` instance. */ - function lodashWrapper(value) { + function lodashWrapper(value, chainAll) { + this.__chain__ = !!chainAll; this.__wrapped__ = value; } // ensure `new lodashWrapper` is an instance of `lodash` @@ -1605,6 +1606,7 @@ * * @static * @memberOf _ + * @type Function * @category Objects * @param {Mixed} value The value to check. * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. @@ -1893,7 +1895,7 @@ var defaults = createIterator(defaultsIteratorOptions); /** - * This method is similar to `_.find`, except that it returns the key of the + * This method is like `_.findIndex`, except that it returns the key of the * element that passes the callback check, instead of the element itself. * * @static @@ -1910,7 +1912,7 @@ * _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { * return num % 2 == 0; * }); - * // => 'b' + * // => 'b' (order is not guaranteed) */ function findKey(object, callback, thisArg) { var result; @@ -1924,6 +1926,38 @@ return result; } + /** + * This method is like `_.findKey`, except that it iterates over elements + * of a `collection` in the opposite order. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to search. + * @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 + * + * _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { + * return num % 2 == 1; + * }); + * // => returns `c`, assuming `_.findKey` returns `a` + */ + function findLastKey(object, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg); + forOwnRight(object, function(value, key, object) { + if (callback(value, key, object)) { + result = key; + return false; + } + }); + return result; + } + /** * Iterates over own and inherited enumerable properties of a given `object`, * executing the `callback` for each property. The `callback` is bound to @@ -1945,18 +1979,62 @@ * } * * Dog.prototype.bark = function() { - * alert('Woof, woof!'); + * console.log('Woof, woof!'); * }; * * _.forIn(new Dog('Dagny'), function(value, key) { - * alert(key); + * console.log(key); * }); - * // => alerts 'name' and 'bark' (order is not guaranteed) + * // => logs 'bark' and 'name' (order is not guaranteed) */ var forIn = createIterator(eachIteratorOptions, forOwnIteratorOptions, { 'useHas': false }); + /** + * This method is like `_.forIn`, except that it iterates over elements + * of a `collection` in the opposite order. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns `object`. + * @example + * + * function Dog(name) { + * this.name = name; + * } + * + * Dog.prototype.bark = function() { + * console.log('Woof, woof!'); + * }; + * + * _.forInRight(new Dog('Dagny'), function(value, key) { + * console.log(key); + * }); + * // => logs 'name' and 'bark' assuming `_.forIn ` logs 'bark' and 'name' + */ + function forInRight(object, callback, thisArg) { + var index = -1, + pairs = []; + + forIn(object, function(value, key) { + pairs.push(value, key); + }); + + var length = pairs.length; + callback = lodash.createCallback(callback, thisArg, 3); + while (++index < length) { + if (callback(pairs[index], pairs[++index], object) === false) { + break; + } + } + return object; + } + /** * Iterates over own enumerable properties of a given `object`, executing the * `callback` for each property. The `callback` is bound to `thisArg` and @@ -1974,12 +2052,44 @@ * @example * * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - * alert(key); + * console.log(key); * }); - * // => alerts '0', '1', and 'length' (order is not guaranteed) + * // => logs '0', '1', and 'length' (order is not guaranteed) */ var forOwn = createIterator(eachIteratorOptions, forOwnIteratorOptions); + /** + * This method is like `_.forOwn`, except that it iterates over elements + * of a `collection` in the opposite order. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns `object`. + * @example + * + * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + * console.log(key); + * }); + * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' + */ + function forOwnRight(object, callback, thisArg) { + var props = keys(object), + length = props.length; + + callback = lodash.createCallback(callback, thisArg, 3); + while (length--) { + var key = props[length]; + if (callback(object[key], key, object) === false) { + break; + } + } + return object; + } + /** * Creates a sorted array of property names of all enumerable properties, * own and inherited, of `object` that have function values. @@ -3023,6 +3133,38 @@ } } + /** + * This method is like `_.find`, except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @category Collections + * @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 found element, else `undefined`. + * @example + * + * _.findLast([1, 2, 3, 4], function(num) { + * return num % 2 == 1; + * }); + * // => 3 + */ + function findLast(collection, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg); + forEachRight(collection, function(value, index, collection) { + if (callback(value, index, collection)) { + result = value; + return false; + } + }); + return result; + } + /** * Iterates over elements of a `collection`, executing the `callback` for * each element. The `callback` is bound to `thisArg` and invoked with three @@ -3039,11 +3181,11 @@ * @returns {Array|Object|String} Returns `collection`. * @example * - * _([1, 2, 3]).forEach(alert).join(','); - * // => alerts each number and returns '1,2,3' + * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); + * // => logs each number and returns '1,2,3' * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); - * // => alerts each number value (order is not guaranteed) + * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + * // => logs each number value and returns the object (order is not guaranteed) */ function forEach(collection, callback, thisArg) { if (callback && typeof thisArg == 'undefined' && isArray(collection)) { @@ -3061,6 +3203,41 @@ return collection; } + /** + * This method is like `_.forEach`, except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @alias each + * @category Collections + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|String} Returns `collection`. + * @example + * + * _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); + * // => logs each number from right to left and returns '3,2,1' + */ + function forEachRight(collection, callback, thisArg) { + var iterable = collection, + length = collection ? collection.length : 0; + + if (typeof length != 'number') { + var props = keys(collection); + length = props.length; + } else if (support.unindexedChars && isString(collection)) { + iterable = collection.split(''); + } + callback = lodash.createCallback(callback, thisArg, 3); + forEach(collection, function(value, index, collection) { + index = props ? props[--length] : --length; + callback(iterable[index], index, collection); + }); + return collection; + } + /** * Creates an object composed of keys generated from the results of running * each element of the `collection` through the `callback`. The corresponding @@ -3450,7 +3627,7 @@ } /** - * This method is similar to `_.reduce`, except that it iterates over elements + * This method is like `_.reduce`, except that it iterates over elements * of a `collection` from right to left. * * @static @@ -3469,22 +3646,12 @@ * // => [4, 5, 2, 3, 0, 1] */ function reduceRight(collection, callback, accumulator, thisArg) { - var iterable = collection, - length = collection ? collection.length : 0, - noaccum = arguments.length < 3; - - if (typeof length != 'number') { - var props = keys(collection); - length = props.length; - } else if (support.unindexedChars && isString(collection)) { - iterable = collection.split(''); - } + var noaccum = arguments.length < 3; callback = lodash.createCallback(callback, thisArg, 4); - forEach(collection, function(value, index, collection) { - index = props ? props[--length] : --length; + forEachRight(collection, function(value, index, collection) { accumulator = noaccum - ? (noaccum = false, iterable[index]) - : callback(accumulator, iterable[index], index, collection); + ? (noaccum = false, value) + : callback(accumulator, value, index, collection); }); return accumulator; } @@ -3833,8 +4000,8 @@ } /** - * 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. + * This method is like `_.find`, except that it returns the index of the + * element that passes the callback check, instead of the element itself. * * @static * @memberOf _ @@ -3865,6 +4032,39 @@ return -1; } + /** + * This method is like `_.findIndex`, except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to search. + * @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 + * + * _.findLastIndex(['apple', 'banana', 'beet'], function(food) { + * return /^b/.test(food); + * }); + * // => 2 + */ + function findLastIndex(array, callback, thisArg) { + var index = -1, + length = array ? array.length : 0; + + callback = lodash.createCallback(callback, thisArg); + while (length--) { + if (callback(array[index], index, array)) { + 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, @@ -4693,12 +4893,12 @@ * * var view = { * 'label': 'docs', - * 'onClick': function() { alert('clicked ' + this.label); } + * 'onClick': function() { console.log('clicked ' + this.label); } * }; * * _.bindAll(view); * jQuery('#docs').on('click', view.onClick); - * // => alerts 'clicked docs', when the button is clicked + * // => logs 'clicked docs', when the button is clicked */ function bindAll(object) { var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object), @@ -4763,11 +4963,22 @@ * @returns {Function} Returns the new composed function. * @example * - * var greet = function(name) { return 'hi ' + name; }; - * var exclaim = function(statement) { return statement + '!'; }; - * var welcome = _.compose(exclaim, greet); - * welcome('moe'); - * // => 'hi moe!' + * var realNameMap = { + * 'curly': 'jerome' + * }; + * + * var format = function(name) { + * name = realNameMap[name.toLowerCase()] || name; + * return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); + * }; + * + * var greet = function(formatted) { + * return 'Hiya ' + formatted + '!'; + * }; + * + * var welcome = _.compose(greet, format); + * welcome('curly'); + * // => 'Hiya Jerome!' */ function compose() { var funcs = arguments; @@ -5019,8 +5230,8 @@ * @returns {Number} Returns the timer id. * @example * - * _.defer(function() { alert('deferred'); }); - * // returns from the function before `alert` is called + * _.defer(function() { console.log('deferred'); }); + * // returns from the function before 'deferred' is logged */ function defer(func) { var args = nativeSlice.call(arguments, 1); @@ -5143,7 +5354,7 @@ } /** - * This method is similar to `_.partial`, except that `partial` arguments are + * This method is like `_.partial`, except that `partial` arguments are * appended to those passed to the new function. * * @static @@ -5709,6 +5920,34 @@ /*--------------------------------------------------------------------------*/ + /** + * Creates a `lodash` object that wraps the given `value`. + * + * @static + * @memberOf _ + * @category Chaining + * @param {Mixed} value The value to wrap. + * @returns {Object} Returns the wrapper object. + * @example + * + * var stooges = [ + * { 'name': 'moe', 'age': 40 }, + * { 'name': 'larry', 'age': 50 }, + * { 'name': 'curly', 'age': 60 } + * ]; + * + * var youngest = _.chain(stooges) + * .sortBy(function(stooge) { return stooge.age; }) + * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) + * .first(); + * // => 'moe is 40' + */ + function chain(value) { + value = new lodashWrapper(value); + value.__chain__ = true; + return value; + } + /** * 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, @@ -5724,10 +5963,10 @@ * * _([1, 2, 3, 4]) * .filter(function(num) { return num % 2 == 0; }) - * .tap(alert) + * .tap(function(array) { console.log(array); }) * .map(function(num) { return num * num; }) * .value(); - * // => // [2, 4] (alerted) + * // => // [2, 4] (logged) * // => [4, 16] */ function tap(value, interceptor) { @@ -5735,6 +5974,26 @@ return value; } + /** + * Enables method chaining on the wrapper object. + * + * @name chain + * @memberOf _ + * @category Chaining + * @returns {Mixed} Returns the wrapper object. + * @example + * + * var sum = _([1, 2, 3]) + * .chain() + * .reduce(function(sum, num) { return sum + num; }) + * .value() + * // => 6` + */ + function wrapperChain() { + this.__chain__ = true; + return this; + } + /** * Produces the `toString` result of the wrapped value. * @@ -5777,6 +6036,7 @@ lodash.bind = bind; lodash.bindAll = bindAll; lodash.bindKey = bindKey; + lodash.chain = chain; lodash.compact = compact; lodash.compose = compose; lodash.countBy = countBy; @@ -5789,8 +6049,11 @@ lodash.filter = filter; lodash.flatten = flatten; lodash.forEach = forEach; + lodash.forEachRight = forEachRight; lodash.forIn = forIn; + lodash.forInRight = forInRight; lodash.forOwn = forOwn; + lodash.forOwnRight = forOwnRight; lodash.functions = functions; lodash.groupBy = groupBy; lodash.indexBy = indexBy; @@ -5845,10 +6108,6 @@ // add functions to `lodash.prototype` mixin(lodash); - // add Underscore compat - lodash.chain = lodash; - lodash.prototype.chain = function() { return this; }; - /*--------------------------------------------------------------------------*/ // add functions that return unwrapped values when chaining @@ -5859,7 +6118,10 @@ lodash.every = every; lodash.find = find; lodash.findIndex = findIndex; + lodash.findLast = findLast; + lodash.findLastIndex = findLastIndex; lodash.findKey = findKey; + lodash.findLastKey = findLastKey; lodash.has = has; lodash.identity = identity; lodash.indexOf = indexOf; @@ -5909,9 +6171,14 @@ forOwn(lodash, function(func, methodName) { if (!lodash.prototype[methodName]) { lodash.prototype[methodName] = function() { - var args = [this.__wrapped__]; + var args = [this.__wrapped__], + chainAll = this.__chain__; + push.apply(args, arguments); - return func.apply(lodash, args); + var result = func.apply(lodash, args); + return chainAll + ? new lodashWrapper(result, chainAll) + : result; }; } }); @@ -5929,10 +6196,12 @@ forOwn(lodash, function(func, methodName) { if (!lodash.prototype[methodName]) { lodash.prototype[methodName]= function(callback, thisArg) { - var result = func(this.__wrapped__, callback, thisArg); - return callback == null || (thisArg && typeof callback != 'function') + var chainAll = this.__chain__, + result = func(this.__wrapped__, callback, thisArg); + + return !chainAll && (callback == null || (thisArg && typeof callback != 'function')) ? result - : new lodashWrapper(result); + : new lodashWrapper(result, chainAll); }; } }); @@ -5949,6 +6218,7 @@ lodash.VERSION = '1.3.1'; // add "Chaining" functions to the wrapper + lodash.prototype.chain = wrapperChain; lodash.prototype.toString = wrapperToString; lodash.prototype.value = wrapperValueOf; lodash.prototype.valueOf = wrapperValueOf; @@ -5957,7 +6227,12 @@ baseEach(['join', 'pop', 'shift'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { - return func.apply(this.__wrapped__, arguments); + var chainAll = this.__chain__, + result = func.apply(this.__wrapped__, arguments); + + return chainAll + ? new lodashWrapper(result, chainAll) + : result; }; }); @@ -5974,7 +6249,7 @@ baseEach(['concat', 'slice', 'splice'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { - return new lodashWrapper(func.apply(this.__wrapped__, arguments)); + return new lodashWrapper(func.apply(this.__wrapped__, arguments), this.__chain__); }; }); @@ -5986,13 +6261,16 @@ isSplice = methodName == 'splice'; lodash.prototype[methodName] = function() { - var value = this.__wrapped__, + var chainAll = this.__chain__, + value = this.__wrapped__, result = func.apply(value, arguments); if (value.length === 0) { delete value[0]; } - return isSplice ? new lodashWrapper(result) : result; + return (chainAll || isSplice) + ? new lodashWrapper(result, chainAll) + : result; }; }); } diff --git a/dist/lodash.compat.min.js b/dist/lodash.compat.min.js index bb27cf21c..79a68b54c 100644 --- a/dist/lodash.compat.min.js +++ b/dist/lodash.compat.min.js @@ -4,48 +4,50 @@ * Build: `lodash -o ./dist/lodash.compat.js` */ ;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++et||typeof n=="undefined")return 1;if(ne?0:e);++r=O&&i===t,v=u||s?l():c;if(s){var h=o(v);h?(i=e,v=h):(s=b,v=u?v:(p(v),c))}for(;++ai(v,y))&&((u||s)&&v.push(y),c.push(h))}return s?(p(v.b),g(v)):u&&p(v),c}function ut(n){return function(t,e,r){var u={};return e=_.createCallback(e,r,3),kt(t,function(t,r,a){r=Yt(e(t,r,a)),n(u,t,r,a)}),u}}function at(n,t,e,r,u,a){var o=a&&!u; -if(!ht(n)&&!o)throw new Zt;if(u||a||r.length||!(Pe.fastBind||de&&e.length))i=function(){var a=arguments,f=u?this:t;return o&&(n=t[l]),(e.length||r.length)&&(me.apply(a,e),pe.apply(a,r)),this instanceof i?(f=it(n.prototype),a=n.apply(f,a),yt(a)?a:f):n.apply(f,a)};else{a=[n,t],pe.apply(a,e);var i=de.call.apply(de,a)}if(o){var l=t;t=n}return i}function ot(){var n=f();n.h=q,n.b=n.c=n.g=n.i="",n.e="s",n.j=m;for(var t,e=0;t=arguments[e];e++)for(var r in t)n[r]=t[r];e=n.a,n.d=/^[^,]+/.exec(e)[0],t=Gt,e="return function("+e+"){",r="var m,s="+n.d+",D="+n.e+";if(!s)return D;"+n.i+";",n.b?(r+="var t=s.length;m=-1;if("+n.b+"){",Pe.unindexedChars&&(r+="if(r(s)){s=s.split('')}"),r+="while(++mk;k++)r+="m='"+n.h[k]+"';if((!(q&&w[m])&&l.call(s,m))",n.j||(r+="||(!w[m]&&s[m]!==z[m])"),r+="){"+n.g+"}"; -r+="}"}return(n.b||Pe.nonEnumArgs)&&(r+="}"),r+=n.c+";return D",t=t("i,j,l,n,o,p,r,u,v,z,A,x,H,I,K",e+r+"}"),g(n),t(J,te,se,C,pt,Ne,dt,n.f,_,ee,X,Be,V,re,ye)}function it(n){return yt(n)?be(n):{}}function lt(n){return Te[n]}function ft(){var n=(n=_.indexOf)===Bt?t:n;return n}function ct(n){var t,e;return!n||ye.call(n)!=G||(t=n.constructor,ht(t)&&!(t instanceof t))||!Pe.argsClass&&pt(n)||!Pe.nodeClass&&c(n)?b:Pe.ownLast?(Ge(n,function(n,t,r){return e=se.call(r,t),b}),e!==false):(Ge(n,function(n,t){e=t -}),e===y||se.call(n,e))}function st(n){return We[n]}function pt(n){return n&&typeof n=="object"?ye.call(n)==T:b}function gt(n){var t=[];return Ge(n,function(n,e){ht(n)&&t.push(e)}),t.sort()}function vt(n){for(var t=-1,e=$e(n),r=e.length,u={};++te?ke(0,a+e):e)||0,a&&typeof a=="number"?o=-1<(dt(n)?n.indexOf(t,e):u(n,t,e)):Je(n,function(n){return++ra&&(a=i)}}else t=!t&&dt(n)?u:_.createCallback(t,e,3),Je(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,a=n)});return a}function Et(n,t,e,r){var u=3>arguments.length;if(t=_.createCallback(t,r,4),Ne(n)){var a=-1,o=n.length;for(u&&(e=n[++a]);++aarguments.length; -if(typeof a!="number")var i=$e(n),a=i.length;else Pe.unindexedChars&&dt(n)&&(u=n.split(""));return t=_.createCallback(t,r,4),kt(n,function(n,r,l){r=i?i[--a]:--a,e=o?(o=b,u[r]):t(e,u[r],r,l)}),e}function At(n,t,e){var r;if(t=_.createCallback(t,e,3),Ne(n)){e=-1;for(var u=n.length;++e=O&&u===t;if(f){var c=o(i);c?(u=e,i=c):f=b}for(;++ru(i,c)&&l.push(c); -return f&&g(i),l}function It(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=d){var a=-1;for(t=_.createCallback(t,e,3);++ar?ke(0,u+r):r||0}else if(r)return r=Nt(n,e),n[r]===e?r:-1;return n?t(n,e,r):-1}function Pt(n,t,e){if(typeof t!="number"&&t!=d){var r=0,u=-1,a=n?n.length:0;for(t=_.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tf&&(i=n.apply(l,o));else{var e=new Mt; -!p&&!h&&(c=e);var r=s-(e-c);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:_}},be||(it=function(n){if(yt(n)){s.prototype=n;var t=new s;s.prototype=d}return t||{}}),Pe.argsClass||(pt=function(n){return n&&typeof n=="object"?se.call(n,"callee"):b});var Ne=_e||function(n){return n&&typeof n=="object"?ye.call(n)==W:b},Fe=ot({a:"y",e:"[]",i:"if(!(A[typeof y]))return D",g:"D.push(m)"}),$e=Ce?function(n){return yt(n)?Pe.enumPrototypes&&typeof n=="function"||Pe.nonEnumArgs&&n.length&&pt(n)?Fe(n):Ce(n):[] -}:Fe,ze={a:"f,d,J",i:"d=d&&typeof J=='undefined'?d:v.createCallback(d,J,3)",b:"typeof t=='number'",u:$e,g:"if(d(s[m],m,f)===false)return D"},Re={a:"y,G,k",i:"var a=arguments,b=0,c=typeof k=='number'?2:a.length;while(++b":">",'"':""","'":"'"},We=vt(Te),Ke=Xt("("+$e(We).join("|")+")","g"),Le=Xt("["+$e(Te).join("")+"]","g"),Je=ot(ze),He=ot(Re,{i:Re.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=v.createCallback(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){d=a[--c]}"),g:"D[m]=d?d(D[m],s[m]):s[m]"}),Me=ot(Re),Ge=ot(ze,qe,{j:b}),Ue=ot(ze,qe); -ht(/x/)&&(ht=function(n){return typeof n=="function"&&ye.call(n)==H});var Ve=ce?function(n){if(!n||ye.call(n)!=G||!Pe.argsClass&&pt(n))return b;var t=n.valueOf,e=typeof t=="function"&&(e=ce(t))&&ce(e);return e?n==e||ce(n)==e:ct(n)}:ct,Qe=ut(function(n,t,e){se.call(n,e)?n[e]++:n[e]=1}),Xe=ut(function(n,t,e){(se.call(n,e)?n[e]:n[e]=[]).push(t)}),Ye=ut(function(n,t,e){n[e]=t}),Ze=xt;De&&nt&&typeof ve=="function"&&(Tt=Rt(ve,r));var nr=8==Oe(S+"08")?Oe:function(n,t){return Oe(dt(n)?n.replace(F,""):n,t||0) -};return _.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},_.assign=He,_.at=function(n){var t=-1,e=Y(arguments,m,b,1),r=e.length,u=Jt(r);for(Pe.unindexedChars&&dt(n)&&(n=n.split(""));++t=O&&o(a?r[a]:h)}n:for(;++f(m?e(m,y):c(h,y))){for(a=u,(m||h).push(y);--a;)if(m=i[a],0>(m?e(m,y):c(r[a],y)))continue n; -v.push(y)}}for(;u--;)(m=i[u])&&g(m);return p(i),p(h),v},_.invert=vt,_.invoke=function(n,t){var e=Se.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Jt(typeof a=="number"?a:0);return kt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},_.keys=$e,_.map=xt,_.max=Ot,_.memoize=function(n,t){function e(){var r=e.cache,u=x+(t?t.apply(this,arguments):arguments[0]);return se.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},_.merge=function(n){var t=arguments,e=2;if(!yt(n))return n; -if("number"!=typeof t[2]&&(e=t.length),3r(o,e))&&(a[e]=n)}),a},_.once=function(n){var t,e;return function(){return t?e:(t=m,e=n.apply(this,arguments),n=d,e)}},_.pairs=function(n){for(var t=-1,e=$e(n),r=e.length,u=Jt(r);++te?ke(0,r+e):xe(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},_.mixin=Kt,_.noConflict=function(){return r._=ue,this -},_.parseInt=nr,_.random=function(n,t){n==d&&t==d&&(t=1),n=+n||0,t==d?(t=n,n=0):t=+t||0;var e=Ee();return n%1||t%1?n+xe(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+fe(e*(t-n+1))},_.reduce=Et,_.reduceRight=St,_.result=function(n,t){var e=n?n[t]:y;return ht(e)?n[t]():e},_.runInContext=h,_.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:$e(n).length},_.some=At,_.sortedIndex=Nt,_.template=function(n,t,e){var r=_.templateSettings;n||(n=""),e=Me({},e,r);var u,a=Me({},e.imports,r.imports),r=$e(a),a=bt(a),o=0,l=e.interpolate||$,f="__p+='",l=Xt((e.escape||$).source+"|"+l.source+"|"+(l===N?B:$).source+"|"+(e.evaluate||$).source+"|$","g"); -n.replace(l,function(t,e,r,a,l,c){return r||(r=a),f+=n.slice(o,c).replace(z,i),e&&(f+="'+__e("+e+")+'"),l&&(u=m,f+="';"+l+";__p+='"),r&&(f+="'+((__t=("+r+"))==null?'':__t)+'"),o=c+t.length,t}),f+="';\n",l=e=e.variable,l||(e="obj",f="with("+e+"){"+f+"}"),f=(u?f.replace(A,""):f).replace(D,"$1").replace(I,"$1;"),f="function("+e+"){"+(l?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}";try{var c=Gt(r,"return "+f).apply(y,a) -}catch(s){throw s.source=f,s}return t?c(t):(c.source=f,c)},_.unescape=function(n){return n==d?"":Yt(n).replace(Ke,st)},_.uniqueId=function(n){var t=++w;return Yt(n==d?"":n)+t},_.all=jt,_.any=At,_.detect=Ct,_.findWhere=Ct,_.foldl=Et,_.foldr=St,_.include=_t,_.inject=Et,Ue(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(){var t=[this.__wrapped__];return pe.apply(t,arguments),n.apply(_,t)})}),_.first=It,_.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=d){var a=u;for(t=_.createCallback(t,e,3);a--&&t(n[a],a,n);)r++ -}else if(r=t,r==d||e)return n[u-1];return v(n,ke(0,u-r))}},_.take=It,_.head=It,Ue(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return t==d||e&&typeof t!="function"?r:new j(r)})}),_.VERSION="1.3.1",_.prototype.toString=function(){return Yt(this.__wrapped__)},_.prototype.value=Lt,_.prototype.valueOf=Lt,Je(["join","pop","shift"],function(n){var t=ne[n];_.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Je(["push","reverse","sort","unshift"],function(n){var t=ne[n]; -_.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Je(["concat","slice","splice"],function(n){var t=ne[n];_.prototype[n]=function(){return new j(t.apply(this.__wrapped__,arguments))}}),Pe.spliceObjects||Je(["pop","shift","splice"],function(n){var t=ne[n],e="splice"==n;_.prototype[n]=function(){var n=this.__wrapped__,r=t.apply(n,arguments);return 0===n.length&&delete n[0],e?new j(r):r}}),_}var y,m=!0,d=null,b=!1,_=[],j=[],w=0,C={},x=+new Date+"",O=75,E=40,S=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",A=/\b__p\+='';/g,D=/\b(__p\+=)''\+/g,I=/(__e\(.*?\)|\b__t\))\+'';/g,B=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,P=/\w*$/,N=/<%=([\s\S]+?)%>/g,F=RegExp("^["+S+"]*0+(?=.$)"),$=/($^)/,z=/['\n\r\t\u2028\u2029\\]/g,R="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),q="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),T="[object Arguments]",W="[object Array]",K="[object Boolean]",L="[object Date]",J="[object Error]",H="[object Function]",M="[object Number]",G="[object Object]",U="[object RegExp]",V="[object String]",Q={}; -Q[H]=b,Q[T]=Q[W]=Q[K]=Q[L]=Q[M]=Q[G]=Q[U]=Q[V]=m;var X={"boolean":b,"function":m,object:m,number:b,string:b,undefined:b},Y={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Z=X[typeof exports]&&exports,nt=X[typeof module]&&module&&module.exports==Z&&module,tt=X[typeof global]&&global;!tt||tt.global!==tt&&tt.window!==tt||(n=tt);var et=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=et, define(function(){return et})):Z&&!Z.nodeType?nt?(nt.exports=et)._=et:Z._=et:n._=et +}}function u(n){return n.charCodeAt(0)}function a(n,t){var e=n.m,r=t.m;if(n=n.l,t=t.l,n!==t){if(n>t||typeof n=="undefined")return 1;if(ne?0:e);++r=O&&i===t,v=u||s?c():l;if(s){var h=o(v);h?(i=e,v=h):(s=b,v=u?v:(p(v),l))}for(;++ai(v,y))&&((u||s)&&v.push(y),l.push(h))}return s?(p(v.b),g(v)):u&&p(v),l}function ut(n){return function(t,e,r){var u={};return e=_.createCallback(e,r,3),xt(t,function(t,r,a){r=ne(e(t,r,a)),n(u,t,r,a)}),u}}function at(n,t,e,r,u,a){var o=a&&!u; +if(!yt(n)&&!o)throw new te;if(u||a||r.length||!(Fe.fastBind||_e&&e.length))i=function(){var a=arguments,f=u?this:t;return o&&(n=t[c]),(e.length||r.length)&&(be.apply(a,e),ve.apply(a,r)),this instanceof i?(f=it(n.prototype),a=n.apply(f,a),mt(a)?a:f):n.apply(f,a)};else{a=[n,t],ve.apply(a,e);var i=_e.call.apply(_e,a)}if(o){var c=t;t=n}return i}function ot(){var n=f();n.h=q,n.b=n.c=n.g=n.i="",n.e="s",n.j=m;for(var t,e=0;t=arguments[e];e++)for(var r in t)n[r]=t[r];e=n.a,n.d=/^[^,]+/.exec(e)[0],t=Vt,e="return function("+e+"){",r="var m,s="+n.d+",D="+n.e+";if(!s)return D;"+n.i+";",n.b?(r+="var t=s.length;m=-1;if("+n.b+"){",Fe.unindexedChars&&(r+="if(r(s)){s=s.split('')}"),r+="while(++mk;k++)r+="m='"+n.h[k]+"';if((!(q&&w[m])&&l.call(s,m))",n.j||(r+="||(!w[m]&&s[m]!==z[m])"),r+="){"+n.g+"}"; +r+="}"}return(n.b||Fe.nonEnumArgs)&&(r+="}"),r+=n.c+";return D",t=t("i,j,l,n,o,p,r,u,v,z,A,x,H,I,K",e+r+"}"),g(n),t(J,re,ge,C,pt,Re,bt,n.f,_,ue,X,Ne,V,ae,de)}function it(n){return mt(n)?je(n):{}}function ct(n){return Ke[n]}function ft(){var n=(n=_.indexOf)===Nt?t:n;return n}function lt(n){var t,e;return!n||de.call(n)!=G||(t=n.constructor,yt(t)&&!(t instanceof t))||!Fe.argsClass&&pt(n)||!Fe.nodeClass&&l(n)?b:Fe.ownLast?(Ve(n,function(n,t,r){return e=ge.call(r,t),b}),e!==false):(Ve(n,function(n,t){e=t +}),e===y||ge.call(n,e))}function st(n){return We[n]}function pt(n){return n&&typeof n=="object"?de.call(n)==L:b}function gt(n,t,e){var r=ze(n),u=r.length;for(t=_.createCallback(t,e,3);u--&&(e=r[u],!(t(n[e],e,n)===false)););return n}function vt(n){var t=[];return Ve(n,function(n,e){yt(n)&&t.push(e)}),t.sort()}function ht(n){for(var t=-1,e=ze(n),r=e.length,u={};++te?Oe(0,a+e):e)||0,a&&typeof a=="number"?o=-1<(bt(n)?n.indexOf(t,e):u(n,t,e)):Me(n,function(n){return++ra&&(a=i) +}}else t=!t&&bt(n)?u:_.createCallback(t,e,3),Me(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,a=n)});return a}function At(n,t,e,r){var u=3>arguments.length;if(t=_.createCallback(t,r,4),Re(n)){var a=-1,o=n.length;for(u&&(e=n[++a]);++aarguments.length;return t=_.createCallback(t,r,4),Ot(n,function(n,r,a){e=u?(u=b,n):t(e,n,r,a)}),e}function Dt(n,t,e){var r;if(t=_.createCallback(t,e,3),Re(n)){e=-1;for(var u=n.length;++e=O&&u===t;if(f){var l=o(i);l?(u=e,i=l):f=b}for(;++ru(i,l)&&c.push(l);return f&&g(i),c}function Pt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=d){var a=-1;for(t=_.createCallback(t,e,3);++ar?Oe(0,u+r):r||0}else if(r)return r=Rt(n,e),n[r]===e?r:-1; +return n?t(n,e,r):-1}function Ft(n,t,e){if(typeof t!="number"&&t!=d){var r=0,u=-1,a=n?n.length:0;for(t=_.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tf&&(i=n.apply(c,o));else{var e=new Ut;!p&&!h&&(l=e);var r=s-(e-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:_}},je||(it=function(n){if(mt(n)){s.prototype=n;var t=new s;s.prototype=d}return t||{}}),Fe.argsClass||(pt=function(n){return n&&typeof n=="object"?ge.call(n,"callee"):b});var Re=we||function(n){return n&&typeof n=="object"?de.call(n)==T:b},$e=ot({a:"y",e:"[]",i:"if(!(A[typeof y]))return D",g:"D.push(m)"}),ze=xe?function(n){return mt(n)?Fe.enumPrototypes&&typeof n=="function"||Fe.nonEnumArgs&&n.length&&pt(n)?$e(n):xe(n):[] +}:$e,qe={a:"f,d,J",i:"d=d&&typeof J=='undefined'?d:v.createCallback(d,J,3)",b:"typeof t=='number'",u:ze,g:"if(d(s[m],m,f)===false)return D"},Le={a:"y,G,k",i:"var a=arguments,b=0,c=typeof k=='number'?2:a.length;while(++b":">",'"':""","'":"'"},We=ht(Ke),Je=Zt("("+ze(We).join("|")+")","g"),He=Zt("["+ze(Ke).join("")+"]","g"),Me=ot(qe),Ge=ot(Le,{i:Le.i.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=v.createCallback(a[--c-1],a[c--],2)}else if(c>2&&typeof a[c-1]=='function'){d=a[--c]}"),g:"D[m]=d?d(D[m],s[m]):s[m]"}),Ue=ot(Le),Ve=ot(qe,Te,{j:b}),Qe=ot(qe,Te); +yt(/x/)&&(yt=function(n){return typeof n=="function"&&de.call(n)==H});var Xe=pe?function(n){if(!n||de.call(n)!=G||!Fe.argsClass&&pt(n))return b;var t=n.valueOf,e=typeof t=="function"&&(e=pe(t))&&pe(e);return e?n==e||pe(n)==e:lt(n)}:lt,Ye=ut(function(n,t,e){ge.call(n,e)?n[e]++:n[e]=1}),Ze=ut(function(n,t,e){(ge.call(n,e)?n[e]:n[e]=[]).push(t)}),nr=ut(function(n,t,e){n[e]=t}),tr=Et;Be&&nt&&typeof ye=="function"&&(Kt=Lt(ye,r));var er=8==Se(S+"08")?Se:function(n,t){return Se(bt(n)?n.replace(F,""):n,t||0) +};return _.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},_.assign=Ge,_.at=function(n){var t=-1,e=Y(arguments,m,b,1),r=e.length,u=Mt(r);for(Fe.unindexedChars&&bt(n)&&(n=n.split(""));++t=O&&o(a?r[a]:h)}n:for(;++f(m?e(m,y):l(h,y))){for(a=u,(m||h).push(y);--a;)if(m=i[a],0>(m?e(m,y):l(r[a],y)))continue n;v.push(y)}}for(;u--;)(m=i[u])&&g(m);return p(i),p(h),v},_.invert=ht,_.invoke=function(n,t){var e=Ie.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Mt(typeof a=="number"?a:0);return xt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},_.keys=ze,_.map=Et,_.max=St,_.memoize=function(n,t){function e(){var r=e.cache,u=x+(t?t.apply(this,arguments):arguments[0]); +return ge.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},_.merge=function(n){var t=arguments,e=2;if(!mt(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(o,e))&&(a[e]=n)}),a},_.once=function(n){var t,e;return function(){return t?e:(t=m,e=n.apply(this,arguments),n=d,e)}},_.pairs=function(n){for(var t=-1,e=ze(n),r=e.length,u=Mt(r);++te?Oe(0,r+e):Ee(e,r-1))+1);r--;)if(n[r]===t)return r; +return-1},_.mixin=Jt,_.noConflict=function(){return r._=oe,this},_.parseInt=er,_.random=function(n,t){n==d&&t==d&&(t=1),n=+n||0,t==d?(t=n,n=0):t=+t||0;var e=Ae();return n%1||t%1?n+Ee(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+se(e*(t-n+1))},_.reduce=At,_.reduceRight=It,_.result=function(n,t){var e=n?n[t]:y;return yt(e)?n[t]():e},_.runInContext=h,_.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ze(n).length},_.some=Dt,_.sortedIndex=Rt,_.template=function(n,t,e){var r=_.templateSettings; +n||(n=""),e=Ue({},e,r);var u,a=Ue({},e.imports,r.imports),r=ze(a),a=_t(a),o=0,c=e.interpolate||R,f="__p+='",c=Zt((e.escape||R).source+"|"+c.source+"|"+(c===N?B:R).source+"|"+(e.evaluate||R).source+"|$","g");n.replace(c,function(t,e,r,a,c,l){return r||(r=a),f+=n.slice(o,l).replace($,i),e&&(f+="'+__e("+e+")+'"),c&&(u=m,f+="';"+c+";__p+='"),r&&(f+="'+((__t=("+r+"))==null?'':__t)+'"),o=l+t.length,t}),f+="';\n",c=e=e.variable,c||(e="obj",f="with("+e+"){"+f+"}"),f=(u?f.replace(A,""):f).replace(I,"$1").replace(D,"$1;"),f="function("+e+"){"+(c?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+f+"return __p}"; +try{var l=Vt(r,"return "+f).apply(y,a)}catch(s){throw s.source=f,s}return t?l(t):(l.source=f,l)},_.unescape=function(n){return n==d?"":ne(n).replace(Je,st)},_.uniqueId=function(n){var t=++w;return ne(n==d?"":n)+t},_.all=wt,_.any=Dt,_.detect=kt,_.findWhere=kt,_.foldl=At,_.foldr=It,_.include=jt,_.inject=At,Qe(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return ve.apply(t,arguments),t=n.apply(_,t),e?new j(t,e):t})}),_.first=Pt,_.last=function(n,t,e){if(n){var r=0,u=n.length; +if(typeof t!="number"&&t!=d){var a=u;for(t=_.createCallback(t,e,3);a--&&t(n[a],a,n);)r++}else if(r=t,r==d||e)return n[u-1];return v(n,Oe(0,u-r))}},_.take=Pt,_.head=Pt,Qe(_,function(n,t){_.prototype[t]||(_.prototype[t]=function(t,e){var r=this.__chain__,u=n(this.__wrapped__,t,e);return!r&&(t==d||e&&typeof t!="function")?u:new j(u,r)})}),_.VERSION="1.3.1",_.prototype.chain=function(){return this.__chain__=m,this},_.prototype.toString=function(){return ne(this.__wrapped__)},_.prototype.value=Ht,_.prototype.valueOf=Ht,Me(["join","pop","shift"],function(n){var t=ee[n]; +_.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new j(e,n):e}}),Me(["push","reverse","sort","unshift"],function(n){var t=ee[n];_.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Me(["concat","slice","splice"],function(n){var t=ee[n];_.prototype[n]=function(){return new j(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Fe.spliceObjects||Me(["pop","shift","splice"],function(n){var t=ee[n],e="splice"==n;_.prototype[n]=function(){var n=this.__chain__,r=this.__wrapped__,u=t.apply(r,arguments); +return 0===r.length&&delete r[0],n||e?new j(u,n):u}}),_}var y,m=!0,d=null,b=!1,_=[],j=[],w=0,C={},x=+new Date+"",O=75,E=40,S=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",A=/\b__p\+='';/g,I=/\b(__p\+=)''\+/g,D=/(__e\(.*?\)|\b__t\))\+'';/g,B=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,P=/\w*$/,N=/<%=([\s\S]+?)%>/g,F=RegExp("^["+S+"]*0+(?=.$)"),R=/($^)/,$=/['\n\r\t\u2028\u2029\\]/g,z="Array Boolean Date Error Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),q="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),L="[object Arguments]",T="[object Array]",K="[object Boolean]",W="[object Date]",J="[object Error]",H="[object Function]",M="[object Number]",G="[object Object]",U="[object RegExp]",V="[object String]",Q={}; +Q[H]=b,Q[L]=Q[T]=Q[K]=Q[W]=Q[M]=Q[G]=Q[U]=Q[V]=m;var X={"boolean":b,"function":m,object:m,number:b,string:b,undefined:b},Y={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},Z=X[typeof exports]&&exports,nt=X[typeof module]&&module&&module.exports==Z&&module,tt=X[typeof global]&&global;!tt||tt.global!==tt&&tt.window!==tt||(n=tt);var et=h();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=et, define(function(){return et})):Z&&!Z.nodeType?nt?(nt.exports=et)._=et:Z._=et:n._=et }(this); \ No newline at end of file diff --git a/dist/lodash.js b/dist/lodash.js index 0701102db..0b6b5f1e4 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -530,7 +530,6 @@ * * @name _ * @constructor - * @alias chain * @category Chaining * @param {Mixed} value The value to wrap in a `lodash` instance. * @returns {Object} Returns a `lodash` instance. @@ -567,9 +566,11 @@ * * @private * @param {Mixed} value The value to wrap in a `lodash` instance. + * @param {Boolean} chainAll A flag to enable chaining for all methods * @returns {Object} Returns a `lodash` instance. */ - function lodashWrapper(value) { + function lodashWrapper(value, chainAll) { + this.__chain__ = !!chainAll; this.__wrapped__ = value; } // ensure `new lodashWrapper` is an instance of `lodash` @@ -1274,6 +1275,7 @@ * * @static * @memberOf _ + * @type Function * @category Objects * @param {Mixed} value The value to check. * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. @@ -1549,7 +1551,7 @@ }; /** - * This method is similar to `_.find`, except that it returns the key of the + * This method is like `_.findIndex`, except that it returns the key of the * element that passes the callback check, instead of the element itself. * * @static @@ -1566,7 +1568,7 @@ * _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { * return num % 2 == 0; * }); - * // => 'b' + * // => 'b' (order is not guaranteed) */ function findKey(object, callback, thisArg) { var result; @@ -1580,6 +1582,38 @@ return result; } + /** + * This method is like `_.findKey`, except that it iterates over elements + * of a `collection` in the opposite order. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to search. + * @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 + * + * _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { + * return num % 2 == 1; + * }); + * // => returns `c`, assuming `_.findKey` returns `a` + */ + function findLastKey(object, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg); + forOwnRight(object, function(value, key, object) { + if (callback(value, key, object)) { + result = key; + return false; + } + }); + return result; + } + /** * Iterates over own and inherited enumerable properties of a given `object`, * executing the `callback` for each property. The `callback` is bound to @@ -1601,13 +1635,13 @@ * } * * Dog.prototype.bark = function() { - * alert('Woof, woof!'); + * console.log('Woof, woof!'); * }; * * _.forIn(new Dog('Dagny'), function(value, key) { - * alert(key); + * console.log(key); * }); - * // => alerts 'name' and 'bark' (order is not guaranteed) + * // => logs 'bark' and 'name' (order is not guaranteed) */ var forIn = function(collection, callback, thisArg) { var index, iterable = collection, result = iterable; @@ -1620,6 +1654,50 @@ return result }; + /** + * This method is like `_.forIn`, except that it iterates over elements + * of a `collection` in the opposite order. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns `object`. + * @example + * + * function Dog(name) { + * this.name = name; + * } + * + * Dog.prototype.bark = function() { + * console.log('Woof, woof!'); + * }; + * + * _.forInRight(new Dog('Dagny'), function(value, key) { + * console.log(key); + * }); + * // => logs 'name' and 'bark' assuming `_.forIn ` logs 'bark' and 'name' + */ + function forInRight(object, callback, thisArg) { + var index = -1, + pairs = []; + + forIn(object, function(value, key) { + pairs.push(value, key); + }); + + var length = pairs.length; + callback = lodash.createCallback(callback, thisArg, 3); + while (++index < length) { + if (callback(pairs[index], pairs[++index], object) === false) { + break; + } + } + return object; + } + /** * Iterates over own enumerable properties of a given `object`, executing the * `callback` for each property. The `callback` is bound to `thisArg` and @@ -1637,9 +1715,9 @@ * @example * * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - * alert(key); + * console.log(key); * }); - * // => alerts '0', '1', and 'length' (order is not guaranteed) + * // => logs '0', '1', and 'length' (order is not guaranteed) */ var forOwn = function(collection, callback, thisArg) { var index, iterable = collection, result = iterable; @@ -1657,6 +1735,38 @@ return result }; + /** + * This method is like `_.forOwn`, except that it iterates over elements + * of a `collection` in the opposite order. + * + * @static + * @memberOf _ + * @category Objects + * @param {Object} object The object to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Object} Returns `object`. + * @example + * + * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + * console.log(key); + * }); + * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' + */ + function forOwnRight(object, callback, thisArg) { + var props = keys(object), + length = props.length; + + callback = lodash.createCallback(callback, thisArg, 3); + while (length--) { + var key = props[length]; + if (callback(object[key], key, object) === false) { + break; + } + } + return object; + } + /** * Creates a sorted array of property names of all enumerable properties, * own and inherited, of `object` that have function values. @@ -2690,6 +2800,38 @@ } } + /** + * This method is like `_.find`, except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @category Collections + * @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 found element, else `undefined`. + * @example + * + * _.findLast([1, 2, 3, 4], function(num) { + * return num % 2 == 1; + * }); + * // => 3 + */ + function findLast(collection, callback, thisArg) { + var result; + callback = lodash.createCallback(callback, thisArg); + forEachRight(collection, function(value, index, collection) { + if (callback(value, index, collection)) { + result = value; + return false; + } + }); + return result; + } + /** * Iterates over elements of a `collection`, executing the `callback` for * each element. The `callback` is bound to `thisArg` and invoked with three @@ -2706,11 +2848,11 @@ * @returns {Array|Object|String} Returns `collection`. * @example * - * _([1, 2, 3]).forEach(alert).join(','); - * // => alerts each number and returns '1,2,3' + * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); + * // => logs each number and returns '1,2,3' * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); - * // => alerts each number value (order is not guaranteed) + * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + * // => logs each number value and returns the object (order is not guaranteed) */ function forEach(collection, callback, thisArg) { var index = -1, @@ -2729,6 +2871,41 @@ return collection; } + /** + * This method is like `_.forEach`, except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @alias each + * @category Collections + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|String} Returns `collection`. + * @example + * + * _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); + * // => logs each number from right to left and returns '3,2,1' + */ + function forEachRight(collection, callback, thisArg) { + var iterable = collection, + length = collection ? collection.length : 0; + + if (typeof length != 'number') { + var props = keys(collection); + length = props.length; + } else if (support.unindexedChars && isString(collection)) { + iterable = collection.split(''); + } + callback = lodash.createCallback(callback, thisArg, 3); + forEach(collection, function(value, index, collection) { + index = props ? props[--length] : --length; + callback(iterable[index], index, collection); + }); + return collection; + } + /** * Creates an object composed of keys generated from the results of running * each element of the `collection` through the `callback`. The corresponding @@ -3131,7 +3308,7 @@ } /** - * This method is similar to `_.reduce`, except that it iterates over elements + * This method is like `_.reduce`, except that it iterates over elements * of a `collection` from right to left. * * @static @@ -3150,20 +3327,12 @@ * // => [4, 5, 2, 3, 0, 1] */ function reduceRight(collection, callback, accumulator, thisArg) { - var iterable = collection, - length = collection ? collection.length : 0, - noaccum = arguments.length < 3; - - if (typeof length != 'number') { - var props = keys(collection); - length = props.length; - } + var noaccum = arguments.length < 3; callback = lodash.createCallback(callback, thisArg, 4); - forEach(collection, function(value, index, collection) { - index = props ? props[--length] : --length; + forEachRight(collection, function(value, index, collection) { accumulator = noaccum - ? (noaccum = false, iterable[index]) - : callback(accumulator, iterable[index], index, collection); + ? (noaccum = false, value) + : callback(accumulator, value, index, collection); }); return accumulator; } @@ -3510,8 +3679,8 @@ } /** - * 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. + * This method is like `_.find`, except that it returns the index of the + * element that passes the callback check, instead of the element itself. * * @static * @memberOf _ @@ -3542,6 +3711,39 @@ return -1; } + /** + * This method is like `_.findIndex`, except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @category Arrays + * @param {Array} array The array to search. + * @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 + * + * _.findLastIndex(['apple', 'banana', 'beet'], function(food) { + * return /^b/.test(food); + * }); + * // => 2 + */ + function findLastIndex(array, callback, thisArg) { + var index = -1, + length = array ? array.length : 0; + + callback = lodash.createCallback(callback, thisArg); + while (length--) { + if (callback(array[index], index, array)) { + 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, @@ -4370,12 +4572,12 @@ * * var view = { * 'label': 'docs', - * 'onClick': function() { alert('clicked ' + this.label); } + * 'onClick': function() { console.log('clicked ' + this.label); } * }; * * _.bindAll(view); * jQuery('#docs').on('click', view.onClick); - * // => alerts 'clicked docs', when the button is clicked + * // => logs 'clicked docs', when the button is clicked */ function bindAll(object) { var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object), @@ -4440,11 +4642,22 @@ * @returns {Function} Returns the new composed function. * @example * - * var greet = function(name) { return 'hi ' + name; }; - * var exclaim = function(statement) { return statement + '!'; }; - * var welcome = _.compose(exclaim, greet); - * welcome('moe'); - * // => 'hi moe!' + * var realNameMap = { + * 'curly': 'jerome' + * }; + * + * var format = function(name) { + * name = realNameMap[name.toLowerCase()] || name; + * return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); + * }; + * + * var greet = function(formatted) { + * return 'Hiya ' + formatted + '!'; + * }; + * + * var welcome = _.compose(greet, format); + * welcome('curly'); + * // => 'Hiya Jerome!' */ function compose() { var funcs = arguments; @@ -4706,8 +4919,8 @@ * @returns {Number} Returns the timer id. * @example * - * _.defer(function() { alert('deferred'); }); - * // returns from the function before `alert` is called + * _.defer(function() { console.log('deferred'); }); + * // returns from the function before 'deferred' is logged */ function defer(func) { var args = nativeSlice.call(arguments, 1); @@ -4830,7 +5043,7 @@ } /** - * This method is similar to `_.partial`, except that `partial` arguments are + * This method is like `_.partial`, except that `partial` arguments are * appended to those passed to the new function. * * @static @@ -5396,6 +5609,34 @@ /*--------------------------------------------------------------------------*/ + /** + * Creates a `lodash` object that wraps the given `value`. + * + * @static + * @memberOf _ + * @category Chaining + * @param {Mixed} value The value to wrap. + * @returns {Object} Returns the wrapper object. + * @example + * + * var stooges = [ + * { 'name': 'moe', 'age': 40 }, + * { 'name': 'larry', 'age': 50 }, + * { 'name': 'curly', 'age': 60 } + * ]; + * + * var youngest = _.chain(stooges) + * .sortBy(function(stooge) { return stooge.age; }) + * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) + * .first(); + * // => 'moe is 40' + */ + function chain(value) { + value = new lodashWrapper(value); + value.__chain__ = true; + return value; + } + /** * 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, @@ -5411,10 +5652,10 @@ * * _([1, 2, 3, 4]) * .filter(function(num) { return num % 2 == 0; }) - * .tap(alert) + * .tap(function(array) { console.log(array); }) * .map(function(num) { return num * num; }) * .value(); - * // => // [2, 4] (alerted) + * // => // [2, 4] (logged) * // => [4, 16] */ function tap(value, interceptor) { @@ -5422,6 +5663,26 @@ return value; } + /** + * Enables method chaining on the wrapper object. + * + * @name chain + * @memberOf _ + * @category Chaining + * @returns {Mixed} Returns the wrapper object. + * @example + * + * var sum = _([1, 2, 3]) + * .chain() + * .reduce(function(sum, num) { return sum + num; }) + * .value() + * // => 6` + */ + function wrapperChain() { + this.__chain__ = true; + return this; + } + /** * Produces the `toString` result of the wrapped value. * @@ -5464,6 +5725,7 @@ lodash.bind = bind; lodash.bindAll = bindAll; lodash.bindKey = bindKey; + lodash.chain = chain; lodash.compact = compact; lodash.compose = compose; lodash.countBy = countBy; @@ -5476,8 +5738,11 @@ lodash.filter = filter; lodash.flatten = flatten; lodash.forEach = forEach; + lodash.forEachRight = forEachRight; lodash.forIn = forIn; + lodash.forInRight = forInRight; lodash.forOwn = forOwn; + lodash.forOwnRight = forOwnRight; lodash.functions = functions; lodash.groupBy = groupBy; lodash.indexBy = indexBy; @@ -5532,10 +5797,6 @@ // add functions to `lodash.prototype` mixin(lodash); - // add Underscore compat - lodash.chain = lodash; - lodash.prototype.chain = function() { return this; }; - /*--------------------------------------------------------------------------*/ // add functions that return unwrapped values when chaining @@ -5546,7 +5807,10 @@ lodash.every = every; lodash.find = find; lodash.findIndex = findIndex; + lodash.findLast = findLast; + lodash.findLastIndex = findLastIndex; lodash.findKey = findKey; + lodash.findLastKey = findLastKey; lodash.has = has; lodash.identity = identity; lodash.indexOf = indexOf; @@ -5596,9 +5860,14 @@ forOwn(lodash, function(func, methodName) { if (!lodash.prototype[methodName]) { lodash.prototype[methodName] = function() { - var args = [this.__wrapped__]; + var args = [this.__wrapped__], + chainAll = this.__chain__; + push.apply(args, arguments); - return func.apply(lodash, args); + var result = func.apply(lodash, args); + return chainAll + ? new lodashWrapper(result, chainAll) + : result; }; } }); @@ -5616,10 +5885,12 @@ forOwn(lodash, function(func, methodName) { if (!lodash.prototype[methodName]) { lodash.prototype[methodName]= function(callback, thisArg) { - var result = func(this.__wrapped__, callback, thisArg); - return callback == null || (thisArg && typeof callback != 'function') + var chainAll = this.__chain__, + result = func(this.__wrapped__, callback, thisArg); + + return !chainAll && (callback == null || (thisArg && typeof callback != 'function')) ? result - : new lodashWrapper(result); + : new lodashWrapper(result, chainAll); }; } }); @@ -5636,6 +5907,7 @@ lodash.VERSION = '1.3.1'; // add "Chaining" functions to the wrapper + lodash.prototype.chain = wrapperChain; lodash.prototype.toString = wrapperToString; lodash.prototype.value = wrapperValueOf; lodash.prototype.valueOf = wrapperValueOf; @@ -5644,7 +5916,12 @@ forEach(['join', 'pop', 'shift'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { - return func.apply(this.__wrapped__, arguments); + var chainAll = this.__chain__, + result = func.apply(this.__wrapped__, arguments); + + return chainAll + ? new lodashWrapper(result, chainAll) + : result; }; }); @@ -5661,7 +5938,7 @@ forEach(['concat', 'slice', 'splice'], function(methodName) { var func = arrayRef[methodName]; lodash.prototype[methodName] = function() { - return new lodashWrapper(func.apply(this.__wrapped__, arguments)); + return new lodashWrapper(func.apply(this.__wrapped__, arguments), this.__chain__); }; }); diff --git a/dist/lodash.min.js b/dist/lodash.min.js index 58a11d83c..5947dc014 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -3,46 +3,47 @@ * Lo-Dash 1.3.1 (Custom Build) lodash.com/license | Underscore.js 1.5.1 underscorejs.org/LICENSE * Build: `lodash modern -o ./dist/lodash.js` */ -;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++et||typeof n=="undefined")return 1;if(ne?0:e);++r=w&&i===t,g=u||v?f():c;if(v){var y=o(g);y?(i=e,g=y):(v=m,g=u?g:(p(g),c))}for(;++ai(g,h))&&((u||v)&&g.push(h),c.push(y))}return v?(p(g.b),s(g)):u&&p(g),c}function ot(n){return function(t,e,r){var u={};return e=Z.createCallback(e,r,3),Ct(t,function(t,r,a){r=Zt(e(t,r,a)),n(u,t,r,a)}),u}}function it(n,t,e,r,u,a){var o=a&&!u;if(!yt(n)&&!o)throw new ne;var i=n.__bindData__;if(i)return se.apply(i[2],e),se.apply(i[3],r),!u&&i[4]&&(i[1]=t,i[4]=m,i[5]=a),it.apply(b,i); -if(u||a||r.length||!(Ne.fastBind||be&&e.length))f=function(){var a=arguments,i=u?this:t;return o&&(n=t[l]),(e.length||r.length)&&(he.apply(a,e),se.apply(a,r)),this instanceof f?(i=ht(n.prototype)?me(n.prototype):{},a=n.apply(i,a),ht(a)?a:i):n.apply(i,a)};else{i=[n,t],se.apply(i,e);var f=be.call.apply(be,i)}if(i=Ee.call(arguments),o){var l=t;t=n}return Be(f,i),f}function ft(n){return Fe[n]}function lt(){var n=(n=Z.indexOf)===$t?t:n;return n}function ct(n){var t,e;return n&&ye.call(n)==M&&(t=n.constructor,!yt(t)||t instanceof t)?(C(n,function(n,t){e=t -}),e===y||pe.call(n,e)):m}function pt(n){return Re[n]}function st(n){return n&&typeof n=="object"?ye.call(n)==T:m}function vt(n){var t=[];return C(n,function(n,e){yt(n)&&t.push(e)}),t.sort()}function gt(n){for(var t=-1,e=De(n),r=e.length,u={};++te?we(0,a+e):e)||0,a&&typeof a=="number"?o=-1<(mt(n)?n.indexOf(t,e):u(n,t,e)):_(n,function(n){return++ra&&(a=i)}}else t=!t&&mt(n)?u:Z.createCallback(t,e,3),Ct(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,a=n)});return a}function Et(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Vt(r);++earguments.length;t=Z.createCallback(t,r,4);var a=-1,o=n.length;if(typeof o=="number")for(u&&(e=n[++a]);++aarguments.length;if(typeof u!="number")var o=De(n),u=o.length;return t=Z.createCallback(t,r,4),Ct(n,function(r,i,f){i=o?o[--u]:--u,e=a?(a=m,n[i]):t(e,n[i],i,f)}),e}function It(n,t,e){var r;t=Z.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e=w&&u===t; -if(l){var c=o(i);c?(u=e,i=c):l=m}for(;++ru(i,c)&&f.push(c);return l&&s(i),f}function Bt(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=b){var a=-1;for(t=Z.createCallback(t,e,3);++ar?we(0,u+r):r||0}else if(r)return r=Ft(n,e),n[r]===e?r:-1;return n?t(n,e,r):-1}function Dt(n,t,e){if(typeof t!="number"&&t!=b){var r=0,u=-1,a=n?n.length:0; -for(t=Z.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tl&&(i=n.apply(f,o)); -else{var e=new Ht;!s&&!y&&(c=e);var r=p-(e-c);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Z}};var Be=ie?function(n,t){var e=l();e.value=t,ie(n,"__bindData__",e),s(e)}:c,$e=de,De=je?function(n){return ht(n)?je(n):[]}:X,Fe={"&":"&","<":"<",">":">",'"':""","'":"'"},Re=gt(Fe),Te=Yt("("+De(Re).join("|")+")","g"),qe=Yt("["+De(Fe).join("")+"]","g"),ze=ot(function(n,t,e){pe.call(n,e)?n[e]++:n[e]=1 -}),We=ot(function(n,t,e){(pe.call(n,e)?n[e]:n[e]=[]).push(t)}),Pe=ot(function(n,t,e){n[e]=t});Ae&&Q&&typeof ve=="function"&&(Pt=zt(ve,r));var Ke=8==xe(x+"08")?xe:function(n,t){return xe(mt(n)?n.replace(B,""):n,t||0)};return Z.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},Z.assign=L,Z.at=function(n){for(var t=-1,e=et(arguments,h,m,1),r=e.length,u=Vt(r);++t=w&&o(a?r[a]:y)}n:for(;++l(b?e(b,h):c(y,h))){for(a=u,(b||y).push(h);--a;)if(b=i[a],0>(b?e(b,h):c(r[a],h)))continue n;g.push(h)}}for(;u--;)(b=i[u])&&s(b);return p(i),p(y),g},Z.invert=gt,Z.invoke=function(n,t){var e=Ee.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Vt(typeof a=="number"?a:0);return Ct(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},Z.keys=De,Z.map=xt,Z.max=Ot,Z.memoize=function(n,t){function e(){var r=e.cache,u=j+(t?t.apply(this,arguments):arguments[0]); -return pe.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},Z.merge=function(n){var t=arguments,e=2;if(!ht(n))return n;if("number"!=typeof t[2]&&(e=t.length),3r(o,e))&&(a[e]=n)}),a},Z.once=function(n){var t,e;return function(){return t?e:(t=h,e=n.apply(this,arguments),n=b,e)}},Z.pairs=function(n){for(var t=-1,e=De(n),r=e.length,u=Vt(r);++te?we(0,r+e):Ce(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Z.mixin=Mt,Z.noConflict=function(){return r._=re,this},Z.parseInt=Ke,Z.random=function(n,t){n==b&&t==b&&(t=1),n=+n||0,t==b?(t=n,n=0):t=+t||0;var e=Oe();return n%1||t%1?n+Ce(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+fe(e*(t-n+1))},Z.reduce=St,Z.reduceRight=At,Z.result=function(n,t){var e=n?n[t]:y; -return yt(e)?n[t]():e},Z.runInContext=g,Z.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:De(n).length},Z.some=It,Z.sortedIndex=Ft,Z.template=function(n,t,e){var r=Z.templateSettings;n||(n=""),e=J({},e,r);var u,a=J({},e.imports,r.imports),r=De(a),a=dt(a),o=0,f=e.interpolate||$,l="__p+='",f=Yt((e.escape||$).source+"|"+f.source+"|"+(f===N?A:$).source+"|"+(e.evaluate||$).source+"|$","g");n.replace(f,function(t,e,r,a,f,c){return r||(r=a),l+=n.slice(o,c).replace(F,i),e&&(l+="'+__e("+e+")+'"),f&&(u=h,l+="';"+f+";__p+='"),r&&(l+="'+((__t=("+r+"))==null?'':__t)+'"),o=c+t.length,t -}),l+="';\n",f=e=e.variable,f||(e="obj",l="with("+e+"){"+l+"}"),l=(u?l.replace(O,""):l).replace(E,"$1").replace(S,"$1;"),l="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var c=Jt(r,"return "+l).apply(y,a)}catch(p){throw p.source=l,p}return t?c(t):(c.source=l,c)},Z.unescape=function(n){return n==b?"":Zt(n).replace(Te,pt)},Z.uniqueId=function(n){var t=++k;return Zt(n==b?"":n)+t -},Z.all=kt,Z.any=It,Z.detect=wt,Z.findWhere=wt,Z.foldl=St,Z.foldr=At,Z.include=_t,Z.inject=St,_(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(){var t=[this.__wrapped__];return se.apply(t,arguments),n.apply(Z,t)})}),Z.first=Bt,Z.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=b){var a=u;for(t=Z.createCallback(t,e,3);a--&&t(n[a],a,n);)r++}else if(r=t,r==b||e)return n[u-1];return v(n,we(0,u-r))}},Z.take=Bt,Z.head=Bt,_(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); -return t==b||e&&typeof t!="function"?r:new nt(r)})}),Z.VERSION="1.3.1",Z.prototype.toString=function(){return Zt(this.__wrapped__)},Z.prototype.value=Ut,Z.prototype.valueOf=Ut,Ct(["join","pop","shift"],function(n){var t=te[n];Z.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),Ct(["push","reverse","sort","unshift"],function(n){var t=te[n];Z.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),Ct(["concat","slice","splice"],function(n){var t=te[n];Z.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments)) -}}),Z}var y,h=!0,b=null,m=!1,d=[],_=[],k=0,j=+new Date+"",w=75,C=40,x=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",O=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,S=/(__e\(.*?\)|\b__t\))\+'';/g,A=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,I=/\w*$/,N=/<%=([\s\S]+?)%>/g,B=RegExp("^["+x+"]*0+(?=.$)"),$=/($^)/,D=(D=/\bthis\b/)&&D.test(g)&&D,F=/['\n\r\t\u2028\u2029\\]/g,R="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),T="[object Arguments]",q="[object Array]",z="[object Boolean]",W="[object Date]",P="[object Function]",K="[object Number]",M="[object Object]",U="[object RegExp]",V="[object String]",G={}; -G[P]=m,G[T]=G[q]=G[z]=G[W]=G[K]=G[M]=G[U]=G[V]=h;var H={"boolean":m,"function":h,object:h,number:m,string:m,undefined:m},J={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},L=H[typeof exports]&&exports,Q=H[typeof module]&&module&&module.exports==L&&module,X=H[typeof global]&&global;!X||X.global!==X&&X.window!==X||(n=X);var Y=g();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=Y, define(function(){return Y})):L&&!L.nodeType?Q?(Q.exports=Y)._=Y:L._=Y:n._=Y +;!function(n){function t(n,t,e){e=(e||0)-1;for(var r=n?n.length:0;++et||typeof n=="undefined")return 1;if(ne?0:e);++r=C&&i===t,g=u||v?f():l;if(v){var h=o(g);h?(i=e,g=h):(v=_,g=u?g:(p(g),l))}for(;++ai(g,y))&&((u||v)&&g.push(y),l.push(h))}return v?(p(g.b),s(g)):u&&p(g),l}function ot(n){return function(t,e,r){var u={};return e=Z.createCallback(e,r,3),xt(t,function(t,r,a){r=te(e(t,r,a)),n(u,t,r,a)}),u}}function it(n,t,e,r,u,a){var o=a&&!u;if(!yt(n)&&!o)throw new ee;var i=n.__bindData__;if(i)return ge.apply(i[2],e),ge.apply(i[3],r),!u&&i[4]&&(i[1]=t,i[4]=_,i[5]=a),it.apply(b,i); +if(u||a||r.length||!(Be.fastBind||me&&e.length))f=function(){var a=arguments,i=u?this:t;return o&&(n=t[c]),(e.length||r.length)&&(_e.apply(a,e),ge.apply(a,r)),this instanceof f?(i=bt(n.prototype)?de(n.prototype):{},a=n.apply(i,a),bt(a)?a:i):n.apply(i,a)};else{i=[n,t],ge.apply(i,e);var f=me.call.apply(me,i)}if(i=Se.call(arguments),o){var c=t;t=n}return $e(f,i),f}function ft(n){return Te[n]}function ct(){var n=(n=Z.indexOf)===Dt?t:n;return n}function lt(n){var t,e;return n&&be.call(n)==L&&(t=n.constructor,!yt(t)||t instanceof t)?(j(n,function(n,t){e=t +}),e===h||ve.call(n,e)):_}function pt(n){return qe[n]}function st(n){return n&&typeof n=="object"?be.call(n)==T:_}function vt(n,t,e){var r=Fe(n),u=r.length;for(t=Z.createCallback(t,e,3);u--&&(e=r[u],!(t(n[e],e,n)===false)););return n}function gt(n){var t=[];return j(n,function(n,e){yt(n)&&t.push(e)}),t.sort()}function ht(n){for(var t=-1,e=Fe(n),r=e.length,u={};++te?xe(0,a+e):e)||0,a&&typeof a=="number"?o=-1<(mt(n)?n.indexOf(t,e):u(n,t,e)):d(n,function(n){return++ra&&(a=i)}}else t=!t&&mt(n)?u:Z.createCallback(t,e,3),xt(n,function(n,e,u){e=t(n,e,u),e>r&&(r=e,a=n)});return a}function St(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Gt(r);++earguments.length;t=Z.createCallback(t,r,4);var a=-1,o=n.length;if(typeof o=="number")for(u&&(e=n[++a]);++aarguments.length; +return t=Z.createCallback(t,r,4),Ot(n,function(n,r,a){e=u?(u=_,n):t(e,n,r,a)}),e}function Rt(n,t,e){var r;t=Z.createCallback(t,e,3),e=-1;var u=n?n.length:0;if(typeof u=="number")for(;++e=C&&u===t;if(c){var l=o(i);l?(u=e,i=l):c=_}for(;++ru(i,l)&&f.push(l);return c&&s(i),f}function $t(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=b){var a=-1; +for(t=Z.createCallback(t,e,3);++ar?xe(0,u+r):r||0}else if(r)return r=Tt(n,e),n[r]===e?r:-1;return n?t(n,e,r):-1}function Ft(n,t,e){if(typeof t!="number"&&t!=b){var r=0,u=-1,a=n?n.length:0;for(t=Z.createCallback(t,e,3);++u>>1,e(n[r])e?0:e);++tc&&(i=n.apply(f,o));else{var e=new Jt;!s&&!h&&(l=e);var r=p-(e-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:N,variable:"",imports:{_:Z}};var $e=ce?function(n,t){var e=c();e.value=t,ce(n,"__bindData__",e),s(e)}:l,De=ke,Fe=je?function(n){return bt(n)?je(n):[]}:X,Te={"&":"&","<":"<",">":">",'"':""","'":"'"},qe=ht(Te),ze=ne("("+Fe(qe).join("|")+")","g"),We=ne("["+Fe(Te).join("")+"]","g"),Pe=ot(function(n,t,e){ve.call(n,e)?n[e]++:n[e]=1 +}),Ke=ot(function(n,t,e){(ve.call(n,e)?n[e]:n[e]=[]).push(t)}),Le=ot(function(n,t,e){n[e]=t});Ne&&Q&&typeof he=="function"&&(Lt=Pt(he,r));var Me=8==Ee(x+"08")?Ee:function(n,t){return Ee(mt(n)?n.replace(R,""):n,t||0)};return Z.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},Z.assign=J,Z.at=function(n){for(var t=-1,e=et(arguments,y,_,1),r=e.length,u=Gt(r);++t=C&&o(a?r[a]:h)}n:for(;++c(b?e(b,y):l(h,y))){for(a=u,(b||h).push(y);--a;)if(b=i[a],0>(b?e(b,y):l(r[a],y)))continue n; +g.push(y)}}for(;u--;)(b=i[u])&&s(b);return p(i),p(h),g},Z.invert=ht,Z.invoke=function(n,t){var e=Se.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Gt(typeof a=="number"?a:0);return xt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},Z.keys=Fe,Z.map=Et,Z.max=It,Z.memoize=function(n,t){function e(){var r=e.cache,u=w+(t?t.apply(this,arguments):arguments[0]);return ve.call(r,u)?r[u]:r[u]=n.apply(this,arguments)}return e.cache={},e},Z.merge=function(n){var t=arguments,e=2;if(!bt(n))return n; +if("number"!=typeof t[2]&&(e=t.length),3r(o,e))&&(a[e]=n)}),a},Z.once=function(n){var t,e;return function(){return t?e:(t=y,e=n.apply(this,arguments),n=b,e)}},Z.pairs=function(n){for(var t=-1,e=Fe(n),r=e.length,u=Gt(r);++te?xe(0,r+e):Oe(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},Z.mixin=Ut,Z.noConflict=function(){return r._=ae,this},Z.parseInt=Me,Z.random=function(n,t){n==b&&t==b&&(t=1),n=+n||0,t==b?(t=n,n=0):t=+t||0;var e=Ie();return n%1||t%1?n+Oe(e*(t-n+parseFloat("1e-"+((e+"").length-1))),t):n+le(e*(t-n+1))},Z.reduce=At,Z.reduceRight=Nt,Z.result=function(n,t){var e=n?n[t]:h; +return yt(e)?n[t]():e},Z.runInContext=g,Z.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Fe(n).length},Z.some=Rt,Z.sortedIndex=Tt,Z.template=function(n,t,e){var r=Z.templateSettings;n||(n=""),e=H({},e,r);var u,a=H({},e.imports,r.imports),r=Fe(a),a=dt(a),o=0,f=e.interpolate||B,c="__p+='",f=ne((e.escape||B).source+"|"+f.source+"|"+(f===N?S:B).source+"|"+(e.evaluate||B).source+"|$","g");n.replace(f,function(t,e,r,a,f,l){return r||(r=a),c+=n.slice(o,l).replace(D,i),e&&(c+="'+__e("+e+")+'"),f&&(u=y,c+="';"+f+";__p+='"),r&&(c+="'+((__t=("+r+"))==null?'':__t)+'"),o=l+t.length,t +}),c+="';\n",f=e=e.variable,f||(e="obj",c="with("+e+"){"+c+"}"),c=(u?c.replace(O,""):c).replace(E,"$1").replace(I,"$1;"),c="function("+e+"){"+(f?"":e+"||("+e+"={});")+"var __t,__p='',__e=_.escape"+(u?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+c+"return __p}";try{var l=Qt(r,"return "+c).apply(h,a)}catch(p){throw p.source=c,p}return t?l(t):(l.source=c,l)},Z.unescape=function(n){return n==b?"":te(n).replace(ze,pt)},Z.uniqueId=function(n){var t=++k;return te(n==b?"":n)+t +},Z.all=wt,Z.any=Rt,Z.detect=jt,Z.findWhere=jt,Z.foldl=At,Z.foldr=Nt,Z.include=kt,Z.inject=At,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(){var t=[this.__wrapped__],e=this.__chain__;return ge.apply(t,arguments),t=n.apply(Z,t),e?new nt(t,e):t})}),Z.first=$t,Z.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&t!=b){var a=u;for(t=Z.createCallback(t,e,3);a--&&t(n[a],a,n);)r++}else if(r=t,r==b||e)return n[u-1];return v(n,xe(0,u-r))}},Z.take=$t,Z.head=$t,d(Z,function(n,t){Z.prototype[t]||(Z.prototype[t]=function(t,e){var r=this.__chain__,u=n(this.__wrapped__,t,e); +return!r&&(t==b||e&&typeof t!="function")?u:new nt(u,r)})}),Z.VERSION="1.3.1",Z.prototype.chain=function(){return this.__chain__=y,this},Z.prototype.toString=function(){return te(this.__wrapped__)},Z.prototype.value=Vt,Z.prototype.valueOf=Vt,xt(["join","pop","shift"],function(n){var t=re[n];Z.prototype[n]=function(){var n=this.__chain__,e=t.apply(this.__wrapped__,arguments);return n?new nt(e,n):e}}),xt(["push","reverse","sort","unshift"],function(n){var t=re[n];Z.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this +}}),xt(["concat","slice","splice"],function(n){var t=re[n];Z.prototype[n]=function(){return new nt(t.apply(this.__wrapped__,arguments),this.__chain__)}}),Z}var h,y=!0,b=null,_=!1,m=[],d=[],k=0,w=+new Date+"",C=75,j=40,x=" \t\x0B\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000",O=/\b__p\+='';/g,E=/\b(__p\+=)''\+/g,I=/(__e\(.*?\)|\b__t\))\+'';/g,S=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,A=/\w*$/,N=/<%=([\s\S]+?)%>/g,R=RegExp("^["+x+"]*0+(?=.$)"),B=/($^)/,$=($=/\bthis\b/)&&$.test(g)&&$,D=/['\n\r\t\u2028\u2029\\]/g,F="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),T="[object Arguments]",q="[object Array]",z="[object Boolean]",W="[object Date]",P="[object Function]",K="[object Number]",L="[object Object]",M="[object RegExp]",U="[object String]",V={}; +V[P]=_,V[T]=V[q]=V[z]=V[W]=V[K]=V[L]=V[M]=V[U]=y;var G={"boolean":_,"function":y,object:y,number:_,string:_,undefined:_},H={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},J=G[typeof exports]&&exports,Q=G[typeof module]&&module&&module.exports==J&&module,X=G[typeof global]&&global;!X||X.global!==X&&X.window!==X||(n=X);var Y=g();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=Y, define(function(){return Y})):J&&!J.nodeType?Q?(Q.exports=Y)._=Y:J._=Y:n._=Y }(this); \ No newline at end of file diff --git a/dist/lodash.underscore.js b/dist/lodash.underscore.js index d43ad7511..e65ad75d2 100644 --- a/dist/lodash.underscore.js +++ b/dist/lodash.underscore.js @@ -233,7 +233,6 @@ * * @name _ * @constructor - * @alias chain * @category Chaining * @param {Mixed} value The value to wrap in a `lodash` instance. * @returns {Object} Returns a `lodash` instance. @@ -269,9 +268,11 @@ * * @private * @param {Mixed} value The value to wrap in a `lodash` instance. + * @param {Boolean} chainAll A flag to enable chaining for all methods * @returns {Object} Returns a `lodash` instance. */ - function lodashWrapper(value) { + function lodashWrapper(value, chainAll) { + this.__chain__ = !!chainAll; this.__wrapped__ = value; } // ensure `new lodashWrapper` is an instance of `lodash` @@ -705,6 +706,7 @@ * * @static * @memberOf _ + * @type Function * @category Objects * @param {Mixed} value The value to check. * @returns {Boolean} Returns `true`, if the `value` is an array, else `false`. @@ -936,13 +938,13 @@ * } * * Dog.prototype.bark = function() { - * alert('Woof, woof!'); + * console.log('Woof, woof!'); * }; * * _.forIn(new Dog('Dagny'), function(value, key) { - * alert(key); + * console.log(key); * }); - * // => alerts 'name' and 'bark' (order is not guaranteed) + * // => logs 'bark' and 'name' (order is not guaranteed) */ var forIn = function(collection, callback) { var index, iterable = collection, result = iterable; @@ -971,9 +973,9 @@ * @example * * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - * alert(key); + * console.log(key); * }); - * // => alerts '0', '1', and 'length' (order is not guaranteed) + * // => logs '0', '1', and 'length' (order is not guaranteed) */ var forOwn = function(collection, callback) { var index, iterable = collection, result = iterable; @@ -1840,11 +1842,11 @@ * @returns {Array|Object|String} Returns `collection`. * @example * - * _([1, 2, 3]).forEach(alert).join(','); - * // => alerts each number and returns '1,2,3' + * _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); + * // => logs each number and returns '1,2,3' * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); - * // => alerts each number value (order is not guaranteed) + * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); + * // => logs each number value and returns the object (order is not guaranteed) */ function forEach(collection, callback, thisArg) { var index = -1, @@ -1862,6 +1864,41 @@ }; } + /** + * This method is like `_.forEach`, except that it iterates over elements + * of a `collection` from right to left. + * + * @static + * @memberOf _ + * @alias each + * @category Collections + * @param {Array|Object|String} collection The collection to iterate over. + * @param {Function} [callback=identity] The function called per iteration. + * @param {Mixed} [thisArg] The `this` binding of `callback`. + * @returns {Array|Object|String} Returns `collection`. + * @example + * + * _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); + * // => logs each number from right to left and returns '3,2,1' + */ + function forEachRight(collection, callback, thisArg) { + var iterable = collection, + length = collection ? collection.length : 0; + + if (typeof length != 'number') { + var props = keys(collection); + length = props.length; + } else if (support.unindexedChars && isString(collection)) { + iterable = collection.split(''); + } + callback = createCallback(callback, thisArg, 3); + forEach(collection, function(value, index, collection) { + index = props ? props[--length] : --length; + callback(iterable[index], index, collection); + }); + return collection; + } + /** * Creates an object composed of keys generated from the results of running * each element of the `collection` through the `callback`. The corresponding @@ -2217,7 +2254,7 @@ } /** - * This method is similar to `_.reduce`, except that it iterates over elements + * This method is like `_.reduce`, except that it iterates over elements * of a `collection` from right to left. * * @static @@ -2236,20 +2273,12 @@ * // => [4, 5, 2, 3, 0, 1] */ function reduceRight(collection, callback, accumulator, thisArg) { - var iterable = collection, - length = collection ? collection.length : 0, - noaccum = arguments.length < 3; - - if (typeof length != 'number') { - var props = keys(collection); - length = props.length; - } + var noaccum = arguments.length < 3; callback = createCallback(callback, thisArg, 4); - forEach(collection, function(value, index, collection) { - index = props ? props[--length] : --length; + forEachRight(collection, function(value, index, collection) { accumulator = noaccum - ? (noaccum = false, iterable[index]) - : callback(accumulator, iterable[index], index, collection); + ? (noaccum = false, value) + : callback(accumulator, value, index, collection); }); return accumulator; } @@ -3384,12 +3413,12 @@ * * var view = { * 'label': 'docs', - * 'onClick': function() { alert('clicked ' + this.label); } + * 'onClick': function() { console.log('clicked ' + this.label); } * }; * * _.bindAll(view); * jQuery('#docs').on('click', view.onClick); - * // => alerts 'clicked docs', when the button is clicked + * // => logs 'clicked docs', when the button is clicked */ function bindAll(object) { var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object), @@ -3416,11 +3445,22 @@ * @returns {Function} Returns the new composed function. * @example * - * var greet = function(name) { return 'hi ' + name; }; - * var exclaim = function(statement) { return statement + '!'; }; - * var welcome = _.compose(exclaim, greet); - * welcome('moe'); - * // => 'hi moe!' + * var realNameMap = { + * 'curly': 'jerome' + * }; + * + * var format = function(name) { + * name = realNameMap[name.toLowerCase()] || name; + * return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); + * }; + * + * var greet = function(formatted) { + * return 'Hiya ' + formatted + '!'; + * }; + * + * var welcome = _.compose(greet, format); + * welcome('curly'); + * // => 'Hiya Jerome!' */ function compose() { var funcs = arguments; @@ -3660,8 +3700,8 @@ * @returns {Number} Returns the timer id. * @example * - * _.defer(function() { alert('deferred'); }); - * // returns from the function before `alert` is called + * _.defer(function() { console.log('deferred'); }); + * // returns from the function before 'deferred' is logged */ function defer(func) { var args = nativeSlice.call(arguments, 1); @@ -4274,10 +4314,10 @@ * * _([1, 2, 3, 4]) * .filter(function(num) { return num % 2 == 0; }) - * .tap(alert) + * .tap(function(array) { console.log(array); }) * .map(function(num) { return num * num; }) * .value(); - * // => // [2, 4] (alerted) + * // => // [2, 4] (logged) * // => [4, 16] */ function tap(value, interceptor) { @@ -4344,6 +4384,7 @@ lodash.after = after; lodash.bind = bind; lodash.bindAll = bindAll; + lodash.chain = chain; lodash.compact = compact; lodash.compose = compose; lodash.countBy = countBy; @@ -4400,9 +4441,6 @@ lodash.tail = rest; lodash.unique = uniq; - // add Underscore compat - lodash.chain = chain; - /*--------------------------------------------------------------------------*/ // add functions that return unwrapped values when chaining diff --git a/dist/lodash.underscore.min.js b/dist/lodash.underscore.min.js index a61f0d7e2..3766dc614 100644 --- a/dist/lodash.underscore.min.js +++ b/dist/lodash.underscore.min.js @@ -3,33 +3,34 @@ * Lo-Dash 1.3.1 (Custom Build) lodash.com/license | Underscore.js 1.5.1 underscorejs.org/LICENSE * Build: `lodash underscore exports="amd,commonjs,global,node" -o ./dist/lodash.underscore.js` */ -;!function(n){function t(n,t){var r;if(n&&yt[typeof n])for(r in n)if(Tt.call(n,r)&&t(n[r],r,n)===ut)break}function r(n,t){var r;if(n&&yt[typeof n])for(r in n)if(t(n[r],r,n)===ut)break}function e(n){var t,r=[];if(!n||!yt[typeof n])return r;for(t in n)Tt.call(n,t)&&r.push(t);return r}function u(n,t,r){r=(r||0)-1;for(var e=n?n.length:0;++rt||typeof n=="undefined")return 1;if(nu(a,c))&&(r&&a.push(c),o.push(f))}return o}function v(n){return function(t,r,e){var u={};return r=L(r,e,3),D(t,function(t,e,i){e=r(t,e,i)+"",n(u,t,e,i)}),u}}function g(n,t,r,e){var u=[];if(!O(n))throw new TypeError;if(e||u.length||!(Ut.fastBind||Rt&&r.length))o=function(){var i=arguments,a=e?this:t;return(r.length||u.length)&&(Nt.apply(i,r),St.apply(i,u)),this instanceof o?(a=h(n.prototype),i=n.apply(a,i),E(i)?i:a):n.apply(a,i) -};else{var i=[n,t];St.apply(i,r);var o=Rt.call.apply(Rt,i)}return o}function h(n){return E(n)?kt(n):{}}function y(n){return Ht[n]}function m(){var n=(n=f.indexOf)===V?u:n;return n}function _(n){return Jt[n]}function d(n){return n&&typeof n=="object"?Ft.call(n)==ft:rt}function b(n){if(!n)return n;for(var t=1,r=arguments.length;te&&(e=r,u=n)});else for(;++iu&&(u=r);return u}function $(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++rarguments.length;r=L(r,u,4);var o=-1,a=n.length;if(typeof a=="number")for(i&&(e=n[++o]);++oarguments.length; -if(typeof u!="number")var o=Gt(n),u=o.length;return t=L(t,e,4),D(n,function(e,a,f){a=o?o[--u]:--u,r=i?(i=rt,n[a]):t(r,n[a],a,f)}),r}function z(n,r,e){var u;r=L(r,e,3),e=-1;var i=n?n.length:0;if(typeof i=="number")for(;++er(u,o)&&i.push(o)}return i}function U(n,t,r){if(n){var e=0,u=n.length; -if(typeof t!="number"&&t!=tt){var i=-1;for(t=L(t,r,3);++ir?$t(0,e+r):r||0}else if(r)return r=H(n,t),n[r]===t?r:-1;return n?u(n,t,r):-1}function G(n,t,r){if(typeof t!="number"&&t!=tt){var e=0,u=-1,i=n?n.length:0;for(t=L(t,r,3);++u>>1,r(n[e])c&&(a=n.apply(f,o));else{var r=new Date;!s&&!h&&(l=r);var e=p-(r-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},kt||(h=function(n){if(E(n)){a.prototype=n;var t=new a;a.prototype=tt}return t||{}}),d(arguments)||(d=function(n){return n&&typeof n=="object"?Tt.call(n,"callee"):rt});var Vt=Bt||function(n){return n&&typeof n=="object"?Ft.call(n)==ct:rt},Gt=Mt?function(n){return E(n)?Mt(n):[] -}:e,Ht={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Jt=x(Ht),Kt=RegExp("("+Gt(Jt).join("|")+")","g"),Lt=RegExp("["+Gt(Ht).join("")+"]","g");O(/x/)&&(O=function(n){return typeof n=="function"&&"[object Function]"==Ft.call(n)});var Qt=v(function(n,t,r){Tt.call(n,r)?n[r]++:n[r]=1}),Xt=v(function(n,t,r){(Tt.call(n,r)?n[r]:n[r]=[]).push(t)});f.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},f.bind=K,f.bindAll=function(n){for(var t=1u(o,a)){for(var f=r;--f;)if(0>u(t[f],a))continue n;o.push(a)}}return o},f.invert=x,f.invoke=function(n,t){var r=zt.call(arguments,2),e=-1,u=typeof t=="function",i=n?n.length:0,o=Array(typeof i=="number"?i:0); -return D(n,function(n){o[++e]=(u?t:n[t]).apply(n,r)}),o},f.keys=Gt,f.map=q,f.max=M,f.memoize=function(n,t){var r={};return function(){var e=it+(t?t.apply(this,arguments):arguments[0]);return Tt.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},f.min=function(n,t,r){var e=1/0,u=e,i=-1,o=n?n.length:0;if(t||typeof o!="number")t=L(t,r,3),D(n,function(n,r,i){r=t(n,r,i),rt(e,r)&&(u[r]=n) -}),u},f.once=function(n){var t,r;return function(){return t?r:(t=nt,r=n.apply(this,arguments),n=tt,r)}},f.pairs=function(n){for(var t=-1,r=Gt(n),e=r.length,u=Array(e);++tt?0:t);++nr?$t(0,e+r):It(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},f.mixin=Y,f.noConflict=function(){return n._=xt,this},f.random=function(n,t){n==tt&&t==tt&&(t=1),n=+n||0,t==tt?(t=n,n=0):t=+t||0;var r=Wt();return n%1||t%1?n+It(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+Et(r*(t-n+1))},f.reduce=I,f.reduceRight=W,f.result=function(n,t){var r=n?n[t]:Z; -return O(r)?n[t]():r},f.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Gt(n).length},f.some=z,f.sortedIndex=H,f.template=function(n,t,r){var e=f.templateSettings;n||(n=""),r=j({},r,e);var u=0,i="__p+='",e=r.variable;n.replace(RegExp((r.escape||ot).source+"|"+(r.interpolate||ot).source+"|"+(r.evaluate||ot).source+"|$","g"),function(t,r,e,a,f){return i+=n.slice(u,f).replace(at,o),r&&(i+="'+_.escape("+r+")+'"),a&&(i+="';"+a+";__p+='"),e&&(i+="'+((__t=("+e+"))==null?'':__t)+'"),u=f+t.length,t -}),i+="';\n",e||(e="obj",i="with("+e+"||{}){"+i+"}"),i="function("+e+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+i+"return __p}";try{var a=Function("_","return "+i)(f)}catch(c){throw c.source=i,c}return t?a(t):(a.source=i,a)},f.unescape=function(n){return n==tt?"":(n+"").replace(Kt,_)},f.uniqueId=function(n){var t=++et+"";return n?n+t:t},f.all=R,f.any=z,f.detect=B,f.findWhere=function(n,t){return C(n,t,nt)},f.foldl=I,f.foldr=W,f.include=N,f.inject=I,f.first=U,f.last=function(n,t,r){if(n){var e=0,u=n.length; -if(typeof t!="number"&&t!=tt){var i=u;for(t=L(t,r,3);i--&&t(n[i],i,n);)e++}else if(e=t,e==tt||r)return n[u-1];return zt.call(n,$t(0,u-e))}},f.take=U,f.head=U,f.VERSION="1.3.1",Y(f),f.prototype.chain=function(){return this.__chain__=nt,this},f.prototype.value=function(){return this.__wrapped__},D("pop push reverse shift sort splice unshift".split(" "),function(n){var t=jt[n];f.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),!Ut.spliceObjects&&0===n.length&&delete n[0],this -}}),D(["concat","join","slice"],function(n){var t=jt[n];f.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new c(n),n.__chain__=nt),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=f, define(function(){return f})):_t&&!_t.nodeType?dt?(dt.exports=f)._=f:_t._=f:n._=f}(this); \ No newline at end of file +;!function(n){function t(n,t){var r;if(n&&mt[typeof n])for(r in n)if(St.call(n,r)&&t(n[r],r,n)===it)break}function r(n,t){var r;if(n&&mt[typeof n])for(r in n)if(t(n[r],r,n)===it)break}function e(n){var t,r=[];if(!n||!mt[typeof n])return r;for(t in n)St.call(n,t)&&r.push(t);return r}function u(n,t,r){r=(r||0)-1;for(var e=n?n.length:0;++rt||typeof n=="undefined")return 1;if(nu(a,c))&&(r&&a.push(c),o.push(f))}return o}function v(n){return function(t,r,e){var u={};return r=Q(r,e,3),D(t,function(t,e,i){e=r(t,e,i)+"",n(u,t,e,i)}),u}}function g(n,t,r,e){var u=[];if(!O(n))throw new TypeError; +if(e||u.length||!(Vt.fastBind||kt&&r.length))o=function(){var i=arguments,a=e?this:t;return(r.length||u.length)&&(Rt.apply(i,r),Ft.apply(i,u)),this instanceof o?(a=h(n.prototype),i=n.apply(a,i),E(i)?i:a):n.apply(a,i)};else{var i=[n,t];Ft.apply(i,r);var o=kt.call.apply(kt,i)}return o}function h(n){return E(n)?Bt(n):{}}function y(n){return Jt[n]}function m(){var n=(n=f.indexOf)===G?u:n;return n}function _(n){return Kt[n]}function d(n){return n&&typeof n=="object"?Nt.call(n)==ct:et}function b(n){if(!n)return n; +for(var t=1,r=arguments.length;te&&(e=r,u=n) +});else for(;++iu&&(u=r);return u}function I(n,t){var r=-1,e=n?n.length:0;if(typeof e=="number")for(var u=Array(e);++rarguments.length;r=Q(r,u,4);var o=-1,a=n.length;if(typeof a=="number")for(i&&(e=n[++o]);++oarguments.length;return t=Q(t,e,4),q(n,function(n,e,i){r=u?(u=et,n):t(r,n,e,i)}),r}function C(n,r,e){var u; +r=Q(r,e,3),e=-1;var i=n?n.length:0;if(typeof i=="number")for(;++er(u,o)&&i.push(o)}return i}function V(n,t,r){if(n){var e=0,u=n.length;if(typeof t!="number"&&t!=rt){var i=-1;for(t=Q(t,r,3);++ir?It(0,e+r):r||0}else if(r)return r=J(n,t),n[r]===t?r:-1;return n?u(n,t,r):-1}function H(n,t,r){if(typeof t!="number"&&t!=rt){var e=0,u=-1,i=n?n.length:0;for(t=Q(t,r,3);++u>>1,r(n[e])c&&(a=n.apply(f,o));else{var r=new Date; +!s&&!h&&(l=r);var e=p-(r-l);0/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,variable:""},Bt||(h=function(n){if(E(n)){a.prototype=n;var t=new a;a.prototype=rt}return t||{}}),d(arguments)||(d=function(n){return n&&typeof n=="object"?St.call(n,"callee"):et});var Gt=Dt||function(n){return n&&typeof n=="object"?Nt.call(n)==lt:et},Ht=$t?function(n){return E(n)?$t(n):[] +}:e,Jt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Kt=x(Jt),Lt=RegExp("("+Ht(Kt).join("|")+")","g"),Qt=RegExp("["+Ht(Jt).join("")+"]","g");O(/x/)&&(O=function(n){return typeof n=="function"&&"[object Function]"==Nt.call(n)});var Xt=v(function(n,t,r){St.call(n,r)?n[r]++:n[r]=1}),Yt=v(function(n,t,r){(St.call(n,r)?n[r]:n[r]=[]).push(t)});f.after=function(n,t){return function(){return 1>--n?t.apply(this,arguments):void 0}},f.bind=L,f.bindAll=function(n){for(var t=1u(o,a)){for(var f=r;--f;)if(0>u(t[f],a))continue n;o.push(a)}}return o},f.invert=x,f.invoke=function(n,t){var r=Ct.call(arguments,2),e=-1,u=typeof t=="function",i=n?n.length:0,o=Array(typeof i=="number"?i:0); +return D(n,function(n){o[++e]=(u?t:n[t]).apply(n,r)}),o},f.keys=Ht,f.map=M,f.max=$,f.memoize=function(n,t){var r={};return function(){var e=ot+(t?t.apply(this,arguments):arguments[0]);return St.call(r,e)?r[e]:r[e]=n.apply(this,arguments)}},f.min=function(n,t,r){var e=1/0,u=e,i=-1,o=n?n.length:0;if(t||typeof o!="number")t=Q(t,r,3),D(n,function(n,r,i){r=t(n,r,i),rt(e,r)&&(u[r]=n) +}),u},f.once=function(n){var t,r;return function(){return t?r:(t=tt,r=n.apply(this,arguments),n=rt,r)}},f.pairs=function(n){for(var t=-1,r=Ht(n),e=r.length,u=Array(e);++tt?0:t);++nr?It(0,e+r):Wt(r,e-1))+1);e--;)if(n[e]===t)return e;return-1},f.mixin=Z,f.noConflict=function(){return n._=At,this},f.random=function(n,t){n==rt&&t==rt&&(t=1),n=+n||0,t==rt?(t=n,n=0):t=+t||0;var r=zt();return n%1||t%1?n+Wt(r*(t-n+parseFloat("1e-"+((r+"").length-1))),t):n+Tt(r*(t-n+1))},f.reduce=W,f.reduceRight=z,f.result=function(n,t){var r=n?n[t]:nt; +return O(r)?n[t]():r},f.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:Ht(n).length},f.some=C,f.sortedIndex=J,f.template=function(n,t,r){var e=f.templateSettings;n||(n=""),r=j({},r,e);var u=0,i="__p+='",e=r.variable;n.replace(RegExp((r.escape||at).source+"|"+(r.interpolate||at).source+"|"+(r.evaluate||at).source+"|$","g"),function(t,r,e,a,f){return i+=n.slice(u,f).replace(ft,o),r&&(i+="'+_.escape("+r+")+'"),a&&(i+="';"+a+";__p+='"),e&&(i+="'+((__t=("+e+"))==null?'':__t)+'"),u=f+t.length,t +}),i+="';\n",e||(e="obj",i="with("+e+"||{}){"+i+"}"),i="function("+e+"){var __t,__p='',__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}"+i+"return __p}";try{var a=Function("_","return "+i)(f)}catch(c){throw c.source=i,c}return t?a(t):(a.source=i,a)},f.unescape=function(n){return n==rt?"":(n+"").replace(Lt,_)},f.uniqueId=function(n){var t=++ut+"";return n?n+t:t},f.all=R,f.any=C,f.detect=B,f.findWhere=function(n,t){return P(n,t,tt)},f.foldl=W,f.foldr=z,f.include=N,f.inject=W,f.first=V,f.last=function(n,t,r){if(n){var e=0,u=n.length; +if(typeof t!="number"&&t!=rt){var i=u;for(t=Q(t,r,3);i--&&t(n[i],i,n);)e++}else if(e=t,e==rt||r)return n[u-1];return Ct.call(n,It(0,u-e))}},f.take=V,f.head=V,f.VERSION="1.3.1",Z(f),f.prototype.chain=function(){return this.__chain__=tt,this},f.prototype.value=function(){return this.__wrapped__},D("pop push reverse shift sort splice unshift".split(" "),function(n){var t=wt[n];f.prototype[n]=function(){var n=this.__wrapped__;return t.apply(n,arguments),!Vt.spliceObjects&&0===n.length&&delete n[0],this +}}),D(["concat","join","slice"],function(n){var t=wt[n];f.prototype[n]=function(){var n=t.apply(this.__wrapped__,arguments);return this.__chain__&&(n=new c(n),n.__chain__=tt),n}}),typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=f, define(function(){return f})):dt&&!dt.nodeType?bt?(bt.exports=f)._=f:dt._=f:n._=f}(this); \ No newline at end of file diff --git a/doc/README.md b/doc/README.md index 6e92a012a..32e8af8f9 100644 --- a/doc/README.md +++ b/doc/README.md @@ -10,6 +10,7 @@ * [`_.difference`](#_differencearray--array1-array2-) * [`_.drop`](#_restarray--callbackn1-thisarg) * [`_.findIndex`](#_findindexarray--callbackidentity-thisarg) +* [`_.findLastIndex`](#_findlastindexarray--callbackidentity-thisarg) * [`_.first`](#_firstarray--callbackn-thisarg) * [`_.flatten`](#_flattenarray--isshallowfalse-callbackidentity-thisarg) * [`_.head`](#_firstarray--callbackn-thisarg) @@ -39,8 +40,9 @@ ## `Chaining` * [`_`](#_value) -* [`_.chain`](#_value) +* [`_.chain`](#_chainvalue) * [`_.tap`](#_tapvalue-interceptor) +* [`_.prototype.chain`](#_prototypechain) * [`_.prototype.toString`](#_prototypetostring) * [`_.prototype.value`](#_prototypevalueof) * [`_.prototype.valueOf`](#_prototypevalueof) @@ -59,15 +61,19 @@ * [`_.countBy`](#_countbycollection--callbackidentity-thisarg) * [`_.detect`](#_findcollection--callbackidentity-thisarg) * [`_.each`](#_foreachcollection--callbackidentity-thisarg) +* [`_.each`](#_foreachrightcollection--callbackidentity-thisarg) * [`_.every`](#_everycollection--callbackidentity-thisarg) * [`_.filter`](#_filtercollection--callbackidentity-thisarg) * [`_.find`](#_findcollection--callbackidentity-thisarg) +* [`_.findLast`](#_findlastcollection--callbackidentity-thisarg) * [`_.findWhere`](#_findcollection--callbackidentity-thisarg) * [`_.foldl`](#_reducecollection--callbackidentity-accumulator-thisarg) * [`_.foldr`](#_reducerightcollection--callbackidentity-accumulator-thisarg) * [`_.forEach`](#_foreachcollection--callbackidentity-thisarg) +* [`_.forEachRight`](#_foreachrightcollection--callbackidentity-thisarg) * [`_.groupBy`](#_groupbycollection--callbackidentity-thisarg) * [`_.include`](#_containscollection-target--fromindex0) +* [`_.indexBy`](#_indexbycollection--callbackidentity-thisarg) * [`_.inject`](#_reducecollection--callbackidentity-accumulator-thisarg) * [`_.invoke`](#_invokecollection-methodname--arg1-arg2-) * [`_.map`](#_mapcollection--callbackidentity-thisarg) @@ -119,8 +125,11 @@ * [`_.defaults`](#_defaultsobject--source1-source2-) * [`_.extend`](#_assignobject--source1-source2--callback-thisarg) * [`_.findKey`](#_findkeyobject--callbackidentity-thisarg) +* [`_.findLastKey`](#_findlastkeyobject--callbackidentity-thisarg) * [`_.forIn`](#_forinobject--callbackidentity-thisarg) +* [`_.forInRight`](#_forinrightobject--callbackidentity-thisarg) * [`_.forOwn`](#_forownobject--callbackidentity-thisarg) +* [`_.forOwnRight`](#_forownrightobject--callbackidentity-thisarg) * [`_.functions`](#_functionsobject) * [`_.has`](#_hasobject-property) * [`_.invert`](#_invertobject) @@ -218,7 +227,7 @@ ### `_.compact(array)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3760 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3981 "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. @@ -242,7 +251,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array [, array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3789 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4010 "View in source") [Ⓣ][1] Creates an array excluding all values of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -267,9 +276,9 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); ### `_.findIndex(array [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3839 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4060 "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. +This method is like `_.find`, except that it returns the index of the element that passes the callback check, instead of the element itself. #### Arguments 1. `array` *(Array)*: The array to search. @@ -292,10 +301,38 @@ _.findIndex(['apple', 'banana', 'beet'], function(food) { + + +### `_.findLastIndex(array [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4093 "View in source") [Ⓣ][1] + +This method is like `_.findIndex`, except that it iterates over elements of a `collection` from right to left. + +#### Arguments +1. `array` *(Array)*: The array to search. +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 +_.findLastIndex(['apple', 'banana', 'beet'], function(food) { + return /^b/.test(food); +}); +// => 2 +``` + +* * * + + + + ### `_.first(array [, callback|n, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3909 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4163 "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)*. @@ -355,7 +392,7 @@ _.first(food, { 'type': 'fruit' }); ### `_.flatten(array [, isShallow=false, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3971 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4225 "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)*. @@ -398,7 +435,7 @@ _.flatten(stooges, 'quotes'); ### `_.indexOf(array, value [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4008 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4262 "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. @@ -430,7 +467,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#L4075 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4329 "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)*. @@ -487,7 +524,7 @@ _.initial(food, { 'type': 'vegetable' }); ### `_.intersection([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4108 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4362 "View in source") [Ⓣ][1] Creates an array of unique values present in all passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -511,7 +548,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#L4210 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4464 "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). @@ -568,7 +605,7 @@ _.last(food, { 'type': 'vegetable' }); ### `_.lastIndexOf(array, value [, fromIndex=array.length-1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4251 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4505 "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. @@ -597,9 +634,9 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); ### `_.range([start=0], end [, step=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4292 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4547 "View in source") [Ⓣ][1] -Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. +Creates an array of numbers *(positive and/or negative)* progressing from `start` up to but not including `end`. If `start` is less than `stop` a zero-length range is created unless a negative `step` is specified. #### Arguments 1. `[start=0]` *(Number)*: The start of the range. @@ -635,7 +672,7 @@ _.range(0); ### `_.rest(array [, callback|n=1, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4371 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4626 "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)*. @@ -695,7 +732,7 @@ _.rest(food, { 'type': 'fruit' }); ### `_.sortedIndex(array, value [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4435 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4690 "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)*. @@ -744,7 +781,7 @@ _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { ### `_.union([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4466 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4721 "View in source") [Ⓣ][1] Creates an array of unique values, in order, of the passed-in arrays using strict equality for comparisons, i.e. `===`. @@ -768,7 +805,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#L4513 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4768 "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 the `callback` before uniqueness is computed. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index, array)*. @@ -815,7 +852,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.without(array [, value1, value2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4541 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4796 "View in source") [Ⓣ][1] Creates an array excluding all passed values using strict equality for comparisons, i.e. `===`. @@ -840,7 +877,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.zip([array1, array2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4561 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4816 "View in source") [Ⓣ][1] Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on. @@ -867,7 +904,7 @@ _.zip(['moe', 'larry'], [30, 40], [true, false]); ### `_.zipObject(keys [, values=[]])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4591 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4846 "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`. @@ -902,7 +939,7 @@ _.zipObject(['moe', 'larry'], [30, 40]); ### `_(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L610 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L612 "View in source") [Ⓣ][1] Creates a `lodash` object, which wraps the given `value`, to enable method chaining. @@ -912,16 +949,13 @@ In addition to Lo-Dash methods, wrappers also have the following `Array` methods Chaining is supported in custom builds as long as the `value` method is implicitly or explicitly included in the build. The chainable wrapper functions are:
-`after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `createCallback`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`, `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`, and `zip` +`after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`, `compose`, `concat`, `countBy`, `createCallback`, `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`, `forEach`, `forIn`, `forOwn`, `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`, `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `push`, `range`, `reject`, `rest`, `reverse`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`, `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`, and `zip` The non-chainable wrapper functions are:
`clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value` The wrapper functions `first` and `last` return wrapped values when `n` is passed, otherwise they return unwrapped values. -#### Aliases -*chain* - #### Arguments 1. `value` *(Mixed)*: The value to wrap in a `lodash` instance. @@ -955,10 +989,43 @@ _.isArray(squares.value()); + + +### `_.chain(value)` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5993 "View in source") [Ⓣ][1] + +Creates a `lodash` object that wraps the given `value`. + +#### Arguments +1. `value` *(Mixed)*: The value to wrap. + +#### Returns +*(Object)*: Returns the wrapper object. + +#### Example +```js +var stooges = [ + { 'name': 'moe', 'age': 40 }, + { 'name': 'larry', 'age': 50 }, + { 'name': 'curly', 'age': 60 } +]; + +var youngest = _.chain(stooges) + .sortBy(function(stooge) { return stooge.age; }) + .map(function(stooge) { return stooge.name + ' is ' + stooge.age; }) + .first(); +// => 'moe is 40' +``` + +* * * + + + + ### `_.tap(value, interceptor)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5728 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6020 "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. @@ -973,10 +1040,10 @@ Invokes `interceptor` with the `value` as the first argument, and then returns ` ```js _([1, 2, 3, 4]) .filter(function(num) { return num % 2 == 0; }) - .tap(alert) + .tap(function(array) { console.log(array); }) .map(function(num) { return num * num; }) .value(); -// => // [2, 4] (alerted) +// => // [2, 4] (logged) // => [4, 16] ``` @@ -985,10 +1052,34 @@ _([1, 2, 3, 4]) + + +### `_.prototype.chain()` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6040 "View in source") [Ⓣ][1] + +Enables method chaining on the wrapper object. + +#### Returns +*(Mixed)*: Returns the wrapper object. + +#### Example +```js +var sum = _([1, 2, 3]) + .chain() + .reduce(function(sum, num) { return sum + num; }) + .value() +// => 6` +``` + +* * * + + + + ### `_.prototype.toString()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5745 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6057 "View in source") [Ⓣ][1] Produces the `toString` result of the wrapped value. @@ -1009,7 +1100,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.valueOf()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5762 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6074 "View in source") [Ⓣ][1] Extracts the wrapped value. @@ -1040,7 +1131,7 @@ _([1, 2, 3]).valueOf(); ### `_.at(collection [, index1, index2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2745 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2878 "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. @@ -1068,7 +1159,7 @@ _.at(['moe', 'larry', 'curly'], 0, 2); ### `_.contains(collection, target [, fromIndex=0])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2787 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2920 "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. @@ -1106,9 +1197,9 @@ _.contains('curly', 'ur'); ### `_.countBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2842 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2976 "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)*. +Creates an object composed of keys generated from the results of 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)*. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. @@ -1142,7 +1233,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2894 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3021 "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)*. @@ -1188,7 +1279,7 @@ _.every(stooges, { 'age': 50 }); ### `_.filter(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2955 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3082 "View in source") [Ⓣ][1] Iterates over elements of 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)*. @@ -1234,7 +1325,7 @@ _.filter(food, { 'type': 'fruit' }); ### `_.find(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3022 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3149 "View in source") [Ⓣ][1] Iterates over elements of 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)*. @@ -1280,10 +1371,38 @@ _.find(food, 'organic'); + + +### `_.findLast(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3194 "View in source") [Ⓣ][1] + +This method is like `_.find`, except that it iterates over elements of a `collection` from right to left. + +#### 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 found element, else `undefined`. + +#### Example +```js +_.findLast([1, 2, 3, 4], function(num) { + return num % 2 == 1; +}); +// => 3 +``` + +* * * + + + + ### `_.forEach(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3069 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3228 "View in source") [Ⓣ][1] Iterates over elements of a `collection`, executing the `callback` for each element. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -1300,11 +1419,40 @@ Iterates over elements of a `collection`, executing the `callback` for each elem #### Example ```js -_([1, 2, 3]).forEach(alert).join(','); -// => alerts each number and returns '1,2,3' +_([1, 2, 3]).forEach(function(num) { console.log(num); }).join(','); +// => logs each number and returns '1,2,3' -_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); -// => alerts each number value (order is not guaranteed) +_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +// => logs each number value and returns the object (order is not guaranteed) +``` + +* * * + + + + + + +### `_.forEachRight(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3261 "View in source") [Ⓣ][1] + +This method is like `_.forEach`, except that it iterates over elements of a `collection` from right to left. + +#### Aliases +*each* + +#### Arguments +1. `collection` *(Array|Object|String)*: The collection to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Array, Object, String)*: Returns `collection`. + +#### Example +```js +_([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(','); +// => logs each number from right to left and returns '3,2,1' ``` * * * @@ -1315,9 +1463,9 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, alert); ### `_.groupBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3119 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3314 "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)*. +Creates an object composed of keys generated from the results of running each element of the `collection` through the `callback`. The corresponding value of each key is an array of the elements responsible for generating the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. @@ -1349,10 +1497,51 @@ _.groupBy(['one', 'two', 'three'], 'length'); + + +### `_.indexBy(collection [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3357 "View in source") [Ⓣ][1] + +Creates an object composed of keys generated from the results of running each element of the `collection` through the given `callback`. The corresponding value of each key is the last element responsible for generating the key. The `callback` is bound to `thisArg` and invoked with three arguments; *(value, index|key, collection)*. + +If a property name is passed for `callback`, the created "_.pluck" style callback will return the property value of the given element. + +If an object is passed for `callback`, the created "_.where" style callback will return `true` for elements that have the properties of the given object, else `false`. + +#### 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 +*(Object)*: Returns the composed aggregate object. + +#### Example +```js +var keys = [ + { 'dir': 'left', 'code': 97 }, + { 'dir': 'right', 'code': 100 } +]; + +_.indexBy(keys, 'dir'); +// => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } + +_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); +// => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + +_.indexBy(stooges, function(key) { this.fromCharCode(key.code); }, String); +// => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } +``` + +* * * + + + + ### `_.invoke(collection, methodName [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3152 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3383 "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`. @@ -1381,7 +1570,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3204 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3435 "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)*. @@ -1426,7 +1615,7 @@ _.map(stooges, 'name'); ### `_.max(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3261 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3492 "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)*. @@ -1468,7 +1657,7 @@ _.max(stooges, 'age'); ### `_.min(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3330 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3561 "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)*. @@ -1510,7 +1699,7 @@ _.min(stooges, 'age'); ### `_.pluck(collection, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3380 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3611 "View in source") [Ⓣ][1] Retrieves the value of a specified property from all elements in the `collection`. @@ -1540,7 +1729,7 @@ _.pluck(stooges, 'name'); ### `_.reduce(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3412 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3643 "View in source") [Ⓣ][1] Reduces a `collection` to a value which is the accumulated result of running each element in the `collection` through the `callback`, where each successive `callback` execution consumes the return value of the previous execution. If `accumulator` is not passed, the first element of the `collection` will be used as the initial `accumulator` value. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, index|key, collection)*. @@ -1578,9 +1767,9 @@ 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#L3455 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3686 "View in source") [Ⓣ][1] -This method is similar to `_.reduce`, except that it iterates over elements of a `collection` from right to left. +This method is like `_.reduce`, except that it iterates over elements of a `collection` from right to left. #### Aliases *foldr* @@ -1609,7 +1798,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#L3515 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3736 "View in source") [Ⓣ][1] The opposite of `_.filter`, this method returns the elements of a `collection` that `callback` does **not** return truthy for. @@ -1652,7 +1841,7 @@ _.reject(food, { 'type': 'fruit' }); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3536 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3757 "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. @@ -1676,7 +1865,7 @@ _.shuffle([1, 2, 3, 4, 5, 6]); ### `_.size(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3569 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3790 "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. @@ -1706,7 +1895,7 @@ _.size('curly'); ### `_.some(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3616 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3837 "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)*. @@ -1752,7 +1941,7 @@ _.some(food, { 'type': 'meat' }); ### `_.sortBy(collection [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3672 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3893 "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)*. @@ -1789,7 +1978,7 @@ _.sortBy(['banana', 'strawberry', 'apple'], 'length'); ### `_.toArray(collection)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3708 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3929 "View in source") [Ⓣ][1] Converts the `collection` to an array. @@ -1813,7 +2002,7 @@ Converts the `collection` to an array. ### `_.where(collection, properties)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3742 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L3963 "View in source") [Ⓣ][1] Performs a deep comparison of each element in a `collection` to the given `properties` object, returning an array of all elements that have equivalent property values. @@ -1853,7 +2042,7 @@ _.where(stooges, { 'quotes': ['Poifect!'] }); ### `_.after(n, func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4628 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4883 "View in source") [Ⓣ][1] Creates a function this is restricted to executing `func`, with the `this` binding and arguments of the created function, only after it is called `n` times. @@ -1881,7 +2070,7 @@ _.forEach(notes, function(note) { ### `_.bind(func [, thisArg, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4658 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4913 "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. @@ -1912,7 +2101,7 @@ func(); ### `_.bindAll(object [, methodName1, methodName2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4686 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4941 "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. @@ -1927,12 +2116,12 @@ Binds methods on `object` to `object`, overwriting the existing method. Method n ```js var view = { 'label': 'docs', - 'onClick': function() { alert('clicked ' + this.label); } + 'onClick': function() { console.log('clicked ' + this.label); } }; _.bindAll(view); jQuery('#docs').on('click', view.onClick); -// => alerts 'clicked docs', when the button is clicked +// => logs 'clicked docs', when the button is clicked ``` * * * @@ -1943,7 +2132,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4732 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4987 "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. @@ -1984,7 +2173,7 @@ func(); ### `_.compose([func1, func2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4755 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5021 "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. @@ -1996,11 +2185,22 @@ Creates a function that is the composition of the passed functions, where each f #### Example ```js -var greet = function(name) { return 'hi ' + name; }; -var exclaim = function(statement) { return statement + '!'; }; -var welcome = _.compose(exclaim, greet); -welcome('moe'); -// => 'hi moe!' +var realNameMap = { + 'curly': 'jerome' +}; + +var format = function(name) { + name = realNameMap[name.toLowerCase()] || name; + return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); +}; + +var greet = function(formatted) { + return 'Hiya ' + formatted + '!'; +}; + +var welcome = _.compose(greet, format); +welcome('curly'); +// => 'Hiya Jerome!' ``` * * * @@ -2011,7 +2211,7 @@ welcome('moe'); ### `_.createCallback([func=identity, thisArg, argCount])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4814 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5080 "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`. @@ -2065,7 +2265,7 @@ _.toLookup(stooges, 'name'); ### `_.debounce(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L4923 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5187 "View in source") [Ⓣ][1] Creates a function that will delay the execution of `func` until after `wait` milliseconds have elapsed since the last time it was invoked. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the debounced function will return the result of the last `func` call. @@ -2106,7 +2306,7 @@ source.addEventListener('message', _.debounce(batchLog, 250, { ### `_.defer(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5020 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5284 "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. @@ -2119,8 +2319,8 @@ Defers executing the `func` function until the current call stack has cleared. A #### Example ```js -_.defer(function() { alert('deferred'); }); -// returns from the function before `alert` is called +_.defer(function() { console.log('deferred'); }); +// returns from the function before 'deferred' is logged ``` * * * @@ -2131,7 +2331,7 @@ _.defer(function() { alert('deferred'); }); ### `_.delay(func, wait [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5046 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5310 "View in source") [Ⓣ][1] Executes the `func` function after `wait` milliseconds. Additional arguments will be passed to `func` when it is invoked. @@ -2158,7 +2358,7 @@ _.delay(log, 1000, 'logged later'); ### `_.memoize(func [, resolver])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5071 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5335 "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. The result cache is exposed as the `cache` property on the memoized function. @@ -2184,7 +2384,7 @@ var fibonacci = _.memoize(function(n) { ### `_.once(func)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5365 "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. @@ -2210,7 +2410,7 @@ initialize(); ### `_.partial(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5136 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5400 "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. @@ -2237,9 +2437,9 @@ hi('moe'); ### `_.partialRight(func [, arg1, arg2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5167 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5431 "View in source") [Ⓣ][1] -This method is similar to `_.partial`, except that `partial` arguments are appended to those passed to the new function. +This method is like `_.partial`, except that `partial` arguments are appended to those passed to the new function. #### Arguments 1. `func` *(Function)*: The function to partially apply arguments to. @@ -2274,7 +2474,7 @@ options.imports ### `_.throttle(func, wait, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5202 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5466 "View in source") [Ⓣ][1] Creates a function that, when executed, will only call the `func` function at most once per every `wait` milliseconds. Pass an `options` object to indicate that `func` should be invoked on the leading and/or trailing edge of the `wait` timeout. Subsequent calls to the throttled function will return the result of the last `func` call. @@ -2308,7 +2508,7 @@ jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5243 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5507 "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. @@ -2344,7 +2544,7 @@ hello(); ### `_.assign(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1779 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1804 "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)*. @@ -2382,7 +2582,7 @@ defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.clone(value [, deep=false, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1832 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1857 "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)*. @@ -2429,7 +2629,7 @@ clone.childNodes.length; ### `_.cloneDeep(value [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1884 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1909 "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)*. @@ -2475,7 +2675,7 @@ clone.node == view.node; ### `_.defaults(object [, source1, source2, ...])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1908 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1933 "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. @@ -2501,9 +2701,9 @@ _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); ### `_.findKey(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1930 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1955 "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. +This method is like `_.findIndex`, except that it returns the key of the element that passes the callback check, instead of the element itself. #### Arguments 1. `object` *(Object)*: The object to search. @@ -2518,7 +2718,35 @@ This method is similar to `_.find`, except that it returns the key of the elemen _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { return num % 2 == 0; }); -// => 'b' +// => 'b' (order is not guaranteed) +``` + +* * * + + + + + + +### `_.findLastKey(object [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1987 "View in source") [Ⓣ][1] + +This method is like `_.findKey`, except that it iterates over elements of a `collection` in the opposite order. + +#### Arguments +1. `object` *(Object)*: The object to search. +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 +_.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { + return num % 2 == 1; +}); +// => returns `c`, assuming `_.findKey` returns `a` ``` * * * @@ -2529,7 +2757,7 @@ _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { ### `_.forIn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1971 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2028 "View in source") [Ⓣ][1] Iterates over own and inherited enumerable properties of a given `object`, 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`. @@ -2548,13 +2776,49 @@ function Dog(name) { } Dog.prototype.bark = function() { - alert('Woof, woof!'); + console.log('Woof, woof!'); }; _.forIn(new Dog('Dagny'), function(value, key) { - alert(key); + console.log(key); }); -// => alerts 'name' and 'bark' (order is not guaranteed) +// => logs 'bark' and 'name' (order is not guaranteed) +``` + +* * * + + + + + + +### `_.forInRight(object [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2058 "View in source") [Ⓣ][1] + +This method is like `_.forIn`, except that it iterates over elements of a `collection` in the opposite order. + +#### Arguments +1. `object` *(Object)*: The object to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +function Dog(name) { + this.name = name; +} + +Dog.prototype.bark = function() { + console.log('Woof, woof!'); +}; + +_.forInRight(new Dog('Dagny'), function(value, key) { + console.log(key); +}); +// => logs 'name' and 'bark' assuming `_.forIn ` logs 'bark' and 'name' ``` * * * @@ -2565,7 +2829,7 @@ _.forIn(new Dog('Dagny'), function(value, key) { ### `_.forOwn(object [, callback=identity, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1996 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2097 "View in source") [Ⓣ][1] Iterates over own enumerable properties of a given `object`, 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`. @@ -2580,9 +2844,37 @@ Iterates over own enumerable properties of a given `object`, executing the `call #### Example ```js _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - alert(key); + console.log(key); }); -// => alerts '0', '1', and 'length' (order is not guaranteed) +// => logs '0', '1', and 'length' (order is not guaranteed) +``` + +* * * + + + + + + +### `_.forOwnRight(object [, callback=identity, thisArg])` +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2117 "View in source") [Ⓣ][1] + +This method is like `_.forOwn`, except that it iterates over elements of a `collection` in the opposite order. + +#### Arguments +1. `object` *(Object)*: The object to iterate over. +2. `[callback=identity]` *(Function)*: The function called per iteration. +3. `[thisArg]` *(Mixed)*: The `this` binding of `callback`. + +#### Returns +*(Object)*: Returns `object`. + +#### Example +```js +_.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + console.log(key); +}); +// => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' ``` * * * @@ -2593,7 +2885,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2013 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2146 "View in source") [Ⓣ][1] Creates a sorted array of property names of all enumerable properties, own and inherited, of `object` that have function values. @@ -2620,7 +2912,7 @@ _.functions(_); ### `_.has(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2038 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2171 "View in source") [Ⓣ][1] Checks if the specified object `property` exists and is a direct property, instead of an inherited property. @@ -2645,7 +2937,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2055 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2188 "View in source") [Ⓣ][1] Creates an object composed of the inverted keys and values of the given `object`. @@ -2669,7 +2961,7 @@ _.invert({ 'first': 'moe', 'second': 'larry' }); ### `_.isArguments(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1608 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1632 "View in source") [Ⓣ][1] Checks if `value` is an `arguments` object. @@ -2696,7 +2988,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1634 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1659 "View in source") [Ⓣ][1] Checks if `value` is an array. @@ -2723,7 +3015,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2081 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2214 "View in source") [Ⓣ][1] Checks if `value` is a boolean value. @@ -2747,7 +3039,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2098 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2231 "View in source") [Ⓣ][1] Checks if `value` is a date. @@ -2771,7 +3063,7 @@ _.isDate(new Date); ### `_.isElement(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2115 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2248 "View in source") [Ⓣ][1] Checks if `value` is a DOM element. @@ -2795,7 +3087,7 @@ _.isElement(document.body); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2140 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2273 "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". @@ -2825,7 +3117,7 @@ _.isEmpty(''); ### `_.isEqual(a, b [, callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2197 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2330 "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)*. @@ -2870,7 +3162,7 @@ _.isEqual(words, otherWords, function(a, b) { ### `_.isFinite(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2229 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2362 "View in source") [Ⓣ][1] Checks if `value` is, or can be coerced to, a finite number. @@ -2908,7 +3200,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2246 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2379 "View in source") [Ⓣ][1] Checks if `value` is a function. @@ -2932,11 +3224,11 @@ _.isFunction(_); ### `_.isNaN(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2309 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2442 "View in source") [Ⓣ][1] Checks if `value` is `NaN`. -Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other values. See http://es5.github.io/#x15.1.2.4. +Note: This is not the same as native `isNaN`, which will return `true` for `undefined` and other non-numeric values. See http://es5.github.io/#x15.1.2.4. #### Arguments 1. `value` *(Mixed)*: The value to check. @@ -2967,7 +3259,7 @@ _.isNaN(undefined); ### `_.isNull(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2331 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2464 "View in source") [Ⓣ][1] Checks if `value` is `null`. @@ -2994,7 +3286,7 @@ _.isNull(undefined); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2350 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2483 "View in source") [Ⓣ][1] Checks if `value` is a number. @@ -3020,7 +3312,7 @@ _.isNumber(8.4 * 5); ### `_.isObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2276 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2409 "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('')`)* @@ -3050,7 +3342,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2378 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2511 "View in source") [Ⓣ][1] Checks if a given `value` is an object created by the `Object` constructor. @@ -3085,7 +3377,7 @@ _.isPlainObject({ 'name': 'moe', 'age': 40 }); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2403 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2536 "View in source") [Ⓣ][1] Checks if `value` is a regular expression. @@ -3109,7 +3401,7 @@ _.isRegExp(/moe/); ### `_.isString(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2420 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2553 "View in source") [Ⓣ][1] Checks if `value` is a string. @@ -3133,7 +3425,7 @@ _.isString('moe'); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2437 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2570 "View in source") [Ⓣ][1] Checks if `value` is `undefined`. @@ -3157,7 +3449,7 @@ _.isUndefined(void 0); ### `_.keys(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1667 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L1692 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property names of `object`. @@ -3181,7 +3473,7 @@ _.keys({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.merge(object [, source1, source2, ..., callback, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2492 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2625 "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)*. @@ -3237,7 +3529,7 @@ _.merge(food, otherFood, function(a, b) { ### `_.omit(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2548 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2681 "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)*. @@ -3268,7 +3560,7 @@ _.omit({ 'name': 'moe', 'age': 40 }, function(value) { ### `_.pairs(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2583 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2716 "View in source") [Ⓣ][1] Creates a two dimensional array of the given object's key-value pairs, i.e. `[[key1, value1], [key2, value2]]`. @@ -3292,7 +3584,7 @@ _.pairs({ 'moe': 30, 'larry': 40 }); ### `_.pick(object, callback|[prop1, prop2, ..., thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2622 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2755 "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)*. @@ -3323,7 +3615,7 @@ _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { ### `_.transform(collection [, callback=identity, accumulator, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2677 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2810 "View in source") [Ⓣ][1] An alternative to `_.reduce`, this method transforms an `object` to a new `accumulator` object which is the result of running each of its elements through the `callback`, with each `callback` execution potentially mutating the `accumulator` object. The `callback` is bound to `thisArg` and invoked with four arguments; *(accumulator, value, key, object)*. Callbacks may exit iteration early by explicitly returning `false`. @@ -3360,7 +3652,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) ### `_.values(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2710 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L2843 "View in source") [Ⓣ][1] Creates an array composed of the own enumerable property values of `object`. @@ -3391,7 +3683,7 @@ _.values({ 'one': 1, 'two': 2, 'three': 3 }); ### `_.escape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5267 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5531 "View in source") [Ⓣ][1] Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding HTML entities. @@ -3415,7 +3707,7 @@ _.escape('Moe, Larry & Curly'); ### `_.identity(value)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5285 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5549 "View in source") [Ⓣ][1] This method returns the first argument passed to it. @@ -3440,7 +3732,7 @@ moe === _.identity(moe); ### `_.mixin(object)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5311 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5575 "View in source") [Ⓣ][1] Adds functions properties of `object` to the `lodash` function and chainable wrapper. @@ -3470,7 +3762,7 @@ _('moe').capitalize(); ### `_.noConflict()` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5346 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5610 "View in source") [Ⓣ][1] Reverts the '_' variable to its previous value and returns a reference to the `lodash` function. @@ -3490,7 +3782,7 @@ var lodash = _.noConflict(); ### `_.parseInt(value [, radix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5370 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5634 "View in source") [Ⓣ][1] Converts the given `value` into an integer of the specified `radix`. If `radix` is `undefined` or `0`, a `radix` of `10` is used unless the `value` is a hexadecimal, in which case a `radix` of `16` is used. @@ -3517,7 +3809,7 @@ _.parseInt('08'); ### `_.random([min=0, max=1])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5393 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5657 "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. @@ -3545,7 +3837,7 @@ _.random(5); ### `_.result(object, property)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5437 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5701 "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. @@ -3580,7 +3872,7 @@ _.result(object, 'stuff'); ### `_.runInContext([context=window])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L442 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L445 "View in source") [Ⓣ][1] Create a new `lodash` function using the given `context` object. @@ -3598,7 +3890,7 @@ Create a new `lodash` function using the given `context` object. ### `_.template(text, data, options)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5528 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5792 "View in source") [Ⓣ][1] A micro-templating method that handles arbitrary delimiters, preserves whitespace, and correctly escapes quotes within interpolated code. @@ -3686,7 +3978,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.times(n, callback [, thisArg])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5653 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5917 "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)*. @@ -3718,7 +4010,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.unescape(string)` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5680 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5944 "View in source") [Ⓣ][1] The inverse of `_.escape`, this method converts the HTML entities `&`, `<`, `>`, `"`, and `'` in `string` to their corresponding characters. @@ -3742,7 +4034,7 @@ _.unescape('Moe, Larry & Curly'); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5700 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5964 "View in source") [Ⓣ][1] Generates a unique ID. If `prefix` is passed, the ID will be appended to it. @@ -3776,7 +4068,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L819 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L823 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -3795,7 +4087,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L5943 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L6266 "View in source") [Ⓣ][1] *(String)*: The semantic version number. @@ -3807,7 +4099,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L637 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L641 "View in source") [Ⓣ][1] *(Object)*: An object used to flag environments features. @@ -3819,7 +4111,7 @@ A reference to the `lodash` function. ### `_.support.argsClass` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L662 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L666 "View in source") [Ⓣ][1] *(Boolean)*: Detect if an `arguments` object's [[Class]] is resolvable *(all but Firefox < `4`, IE < `9`)*. @@ -3831,7 +4123,7 @@ A reference to the `lodash` function. ### `_.support.argsObject` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L654 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L658 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `arguments` objects are `Object` objects *(all but Narwhal and Opera < `10.5`)*. @@ -3843,7 +4135,7 @@ A reference to the `lodash` function. ### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L671 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L675 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `name` or `message` properties of `Error.prototype` are enumerable by default. *(IE < `9`, Safari < `5.1`)* @@ -3855,7 +4147,7 @@ A reference to the `lodash` function. ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L684 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L688 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `prototype` properties are enumerable by default. @@ -3869,7 +4161,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#L692 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L696 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `Function#bind` exists and is inferred to be fast *(all but V8)*. @@ -3881,7 +4173,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#L709 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L713 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `arguments` object indexes are non-enumerable *(Firefox < `4`, IE < `9`, PhantomJS, Safari < `5.1`)*. @@ -3893,7 +4185,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#L720 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L724 "View in source") [Ⓣ][1] *(Boolean)*: Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -3907,7 +4199,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#L700 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L704 "View in source") [Ⓣ][1] *(Boolean)*: Detect if own properties are iterated after inherited properties *(all but IE < `9`)*. @@ -3919,7 +4211,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#L734 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L738 "View in source") [Ⓣ][1] *(Boolean)*: Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -3933,7 +4225,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#L745 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L749 "View in source") [Ⓣ][1] *(Boolean)*: Detect lack of support for accessing string characters by index. @@ -3947,7 +4239,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#L771 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L775 "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. @@ -3959,7 +4251,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#L779 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L783 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to be HTML-escaped. @@ -3971,7 +4263,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#L787 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L791 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect code to be evaluated. @@ -3983,7 +4275,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#L795 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L799 "View in source") [Ⓣ][1] *(RegExp)*: Used to detect `data` property values to inject. @@ -3995,7 +4287,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#L803 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L807 "View in source") [Ⓣ][1] *(String)*: Used to reference the data object in the template text. @@ -4007,7 +4299,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#L811 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/bestiejs/lodash/blob/master/lodash.js#L815 "View in source") [Ⓣ][1] *(Object)*: Used to import variables into the compiled template.