From 9b6342e7fae2856f61c1e910ea12f45bea3bd0a3 Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 12 Feb 2015 23:09:49 -0800 Subject: [PATCH 01/27] Add `baseIsFunction`. --- lodash.src.js | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index be65b2cd94..d94f1772c8 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -331,6 +331,20 @@ return -1; } + /** + * The base implementation of `_.isFunction` without support for environments + * with incorrect `typeof` results. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + */ + function baseIsFunction(value) { + // Avoid a Chakra JIT bug in compatibility modes of IE 11. + // See https://github.com/jashkenas/underscore/issues/1621 for more details. + return typeof value == 'function' || false; + } + /** * The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer` * to define the sort order of `array` and replaces criteria objects with their @@ -7502,7 +7516,7 @@ if (!length) { return function() { return arguments[0]; }; } - if (!arrayEvery(funcs, isFunction)) { + if (!arrayEvery(funcs, baseIsFunction)) { throw new TypeError(FUNC_ERROR_TEXT); } return function() { @@ -7547,7 +7561,7 @@ if (fromIndex < 0) { return function() { return arguments[0]; }; } - if (!arrayEvery(funcs, isFunction)) { + if (!arrayEvery(funcs, baseIsFunction)) { throw new TypeError(FUNC_ERROR_TEXT); } return function() { @@ -8297,20 +8311,12 @@ * _.isFunction(/abc/); * // => false */ - function isFunction(value) { - // Avoid a Chakra JIT bug in compatibility modes of IE 11. - // See https://github.com/jashkenas/underscore/issues/1621 for more details. - return typeof value == 'function' || false; - } - // Fallback for environments that return incorrect `typeof` operator results. - if (isFunction(/x/) || (Uint8Array && !isFunction(Uint8Array))) { - isFunction = function(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in older versions of Chrome and Safari which return 'function' for regexes - // and Safari 8 equivalents which return 'object' for typed array constructors. - return objToString.call(value) == funcTag; - }; - } + var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for regexes + // and Safari 8 equivalents which return 'object' for typed array constructors. + return objToString.call(value) == funcTag; + }; /** * Checks if `value` is the language type of `Object`. From 7733d02938d5eea73648567ed99e987a7ed2faca Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 15 Feb 2015 00:03:14 -0800 Subject: [PATCH 02/27] Remove `baseSlice` from `_.attempt`. --- lodash.src.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index d94f1772c8..2c685f4229 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -10514,9 +10514,16 @@ * elements = []; * } */ - function attempt(func) { + function attempt() { + var length = arguments.length, + func = arguments[0]; + try { - return func.apply(undefined, baseSlice(arguments, 1)); + var args = Array(length ? length - 1 : 0); + while (--length > 0) { + args[length - 1] = arguments[length]; + } + return func.apply(undefined, args); } catch(e) { return isError(e) ? e : new Error(e); } From 8294acdf1c4617665ca9fe82e0a00d101f63e598 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 15 Feb 2015 00:37:18 -0800 Subject: [PATCH 03/27] Tweak `null` check tests of `_.difference`, `_.intersection`, `_.union`, & `_.xor`. --- test/test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test.js b/test/test.js index 4eef133963..37af94b62e 100644 --- a/test/test.js +++ b/test/test.js @@ -3561,7 +3561,7 @@ var array = [0, 1, null, 3]; deepEqual(_.difference(array, 3, null, { '0': 1 }), array); deepEqual(_.difference(null, array, null, [2, 1]), [0, null, 3]); - deepEqual(_.difference(null, array, null, args), [0, null]); + deepEqual(_.difference(array, null, args, null), [0, null]); }); }(1, 2, 3)); @@ -6135,7 +6135,7 @@ var array = [0, 1, null, 3]; deepEqual(_.intersection(array, 3, null, { '0': 1 }), array); deepEqual(_.intersection(null, array, null, [2, 1]), [1]); - deepEqual(_.intersection(null, array, null, args), [1, 3]); + deepEqual(_.intersection(array, null, args, null), [1, 3]); }); test('should return a wrapped value when chaining', 2, function() { @@ -14196,7 +14196,7 @@ var array = [0]; deepEqual(_.union(array, 3, null, { '0': 1 }), array); deepEqual(_.union(null, array, null, [2, 1]), [0, 2, 1]); - deepEqual(_.union(null, array, null, args), [0, 1, 2, 3]); + deepEqual(_.union(array, null, args, null), [0, 1, 2, 3]); }); }(1, 2, 3)); @@ -14584,7 +14584,7 @@ var array = [1, 2]; deepEqual(_.xor(array, 3, null, { '0': 1 }), array); deepEqual(_.xor(null, array, null, [2, 3]), [1, 3]); - deepEqual(_.xor(null, array, null, args), [3]); + deepEqual(_.xor(array, null, args, null), [3]); }); test('should return a wrapped value when chaining', 2, function() { From 540afb193b26d2248991f04a6e9e977baf95a4ad Mon Sep 17 00:00:00 2001 From: Austin Pray Date: Sun, 15 Feb 2015 13:30:22 -0600 Subject: [PATCH 04/27] Fix type in _.some doc example. [closes #969] [ci skip] --- lodash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index 40ab9b793e..7fb5e4c0e7 100644 --- a/lodash.js +++ b/lodash.js @@ -6562,7 +6562,7 @@ * ]; * * // using the `_.matches` callback shorthand - * _.some(users, { user': 'barney', 'active': false }); + * _.some(users, { 'user': 'barney', 'active': false }); * // => false * * // using the `_.matchesProperty` callback shorthand From f243ebba91a9419df910eaf464724fd45903b0fb Mon Sep 17 00:00:00 2001 From: Milos Zivadinovic Date: Sat, 14 Feb 2015 00:23:04 +0100 Subject: [PATCH 05/27] Add _.inRange. --- lodash.src.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- test/test.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 92 insertions(+), 4 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 2c685f4229..3443999411 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -9562,6 +9562,48 @@ /*------------------------------------------------------------------------*/ + /** + * Checks if `n` is between `start` and up to but not including, `end`. If + * `end` is not specified it defaults to `start` with `start` becoming `0`. + * + * @static + * @memberOf _ + * @category Number + * @param {number} n The number to check. + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `n` is in the range, else `false`. + * @example + * + * _.inRange(3, 2, 4); + * // => true + * + * _.inRange(4, 8); + * // => true + * + * _.inRange(4, 2); + * // => false + * + * _.inRange(2, 2); + * // => false + * + * _.inRange(1.2, 2); + * // => true + * + * _.inRange(5.2, 4); + * // => false + */ + function inRange(value, start, end) { + start = +start || 0; + if (typeof end === 'undefined') { + end = start; + start = 0; + } else { + end = +end || 0; + } + return value >= start && value < end; + } + /** * Produces a random number between `min` and `max` (inclusive). If only one * argument is provided a number between `0` and the given number is returned. @@ -10845,8 +10887,9 @@ /** * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to, but not including, `end`. If `start` is less than `end` a - * zero-length range is created unless a negative `step` is specified. + * `start` up to, but not including, `end`. If `end` is not specified it + * defaults to `start` with `start` becoming `0`. If `start` is less than + * `end` a zero-length range is created unless a negative `step` is specified. * * @static * @memberOf _ @@ -11131,6 +11174,7 @@ lodash.identity = identity; lodash.includes = includes; lodash.indexOf = indexOf; + lodash.inRange = inRange; lodash.isArguments = isArguments; lodash.isArray = isArray; lodash.isBoolean = isBoolean; diff --git a/test/test.js b/test/test.js index 37af94b62e..85e3638c6b 100644 --- a/test/test.js +++ b/test/test.js @@ -6091,6 +6091,50 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.inRange'); + + (function() { + test('should work with an `end` argument', 3, function() { + strictEqual(_.inRange(3, 5), true); + strictEqual(_.inRange(5, 5), false); + strictEqual(_.inRange(6, 5), false); + }); + + test('should work with `start` and `end` arguments', 4, function() { + strictEqual(_.inRange(1, 1, 5), true); + strictEqual(_.inRange(3, 1, 5), true); + strictEqual(_.inRange(0, 1, 5), false); + strictEqual(_.inRange(5, 1, 5), false); + }); + + test('should treat falsey `start` arguments as `0`', 13, function() { + _.each(falsey, function(value, index) { + if (index) { + strictEqual(_.inRange(0, value), false); + strictEqual(_.inRange(0, value, 1), true); + } else { + strictEqual(_.inRange(0), false); + } + }); + }); + + test('should work with a floating point `n` value', 4, function() { + strictEqual(_.inRange(0.5, 5), true); + strictEqual(_.inRange(1.2, 1, 5), true); + strictEqual(_.inRange(5.2, 5), false); + strictEqual(_.inRange(0.5, 1, 5), false); + }); + + test('should coerce arguments to finite numbers', 1, function() { + var actual = [_.inRange(0, '0', 1), _.inRange(0, '1'), _.inRange(0, 0, '1'), _.inRange(0, NaN, 1), _.inRange(-1, -1, NaN)], + expected = _.map(actual, _.constant(true)); + + deepEqual(actual, expected); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.intersection'); (function() { @@ -11178,7 +11222,7 @@ QUnit.module('lodash.range'); (function() { - test('should work with a single `end` argument', 1, function() { + test('should work with an `end` argument', 1, function() { deepEqual(_.range(4), [0, 1, 2, 3]); }); @@ -15482,7 +15526,7 @@ var acceptFalsey = _.difference(allMethods, rejectFalsey); - test('should accept falsey arguments', 208, function() { + test('should accept falsey arguments', 209, function() { var emptyArrays = _.map(falsey, _.constant([])), isExposed = '_' in root, oldDash = root._; From fa0086404d5b9e89c0ce99a3714e1cce4dbe5733 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 15 Feb 2015 21:54:12 -0800 Subject: [PATCH 06/27] Add `baseLodash`. --- lodash.src.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 3443999411..f0375c456a 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -943,6 +943,16 @@ return new LodashWrapper(value); } + /** + * A no-operation function used to setup inheritance for `lodash`, + * `LodashWrapper`, and `LazyWrapper` . + * + * @private + */ + function baseLodash() { + // No operation performed. + } + /** * The base constructor for creating `lodash` wrapper objects. * @@ -5689,7 +5699,7 @@ var result, parent = this; - while (parent instanceof LodashWrapper) { + while (parent instanceof baseLodash) { var clone = wrapperClone(parent); if (result) { previous.__wrapped__ = clone; @@ -11012,11 +11022,13 @@ /*------------------------------------------------------------------------*/ - // Ensure `new LodashWrapper` is an instance of `lodash`. - LodashWrapper.prototype = baseCreate(lodash.prototype); + // Ensure wrappers are instances of `baseLodash`. + lodash.prototype = baseLodash.prototype; + + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; - // Ensure `new LazyWraper` is an instance of `LodashWrapper` - LazyWrapper.prototype = baseCreate(LodashWrapper.prototype); + LazyWrapper.prototype = baseCreate(baseLodash.prototype); LazyWrapper.prototype.constructor = LazyWrapper; // Add functions to the `Map` cache. From 249504b7d639fa1b9a5a1f4f3d10c337e00abf9f Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 15 Feb 2015 22:40:42 -0800 Subject: [PATCH 07/27] Whitespace nits in docs. [ci skip] --- lodash.src.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lodash.src.js b/lodash.src.js index f0375c456a..931d9b3395 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -10638,6 +10638,7 @@ * * var object = { 'user': 'fred' }; * var getter = _.constant(object); + * * getter() === object; * // => true */ @@ -10658,6 +10659,7 @@ * @example * * var object = { 'user': 'fred' }; + * * _.identity(object) === object; * // => true */ From b66a886682931d1e25998ba353466bf81abb2560 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 15 Feb 2015 22:41:37 -0800 Subject: [PATCH 08/27] Clarify `_.noop` docs. [ci skip] --- lodash.src.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index 931d9b3395..0a28cd4736 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -10830,7 +10830,8 @@ } /** - * A no-operation function. + * A no-operation function which returns `undefined` regardless of the + * arguments it receives. * * @static * @memberOf _ @@ -10838,6 +10839,7 @@ * @example * * var object = { 'user': 'fred' }; + * * _.noop(object) === undefined; * // => true */ From 69cd56357fb1c9de23d1c06913ecfe4f33233fd5 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 15 Feb 2015 22:42:16 -0800 Subject: [PATCH 09/27] Tweak `_.propertyOf` usage example. [ci skip] --- lodash.src.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 0a28cd4736..22bc4bfaa9 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -10885,9 +10885,9 @@ * @returns {Function} Returns the new function. * @example * - * var object = { 'user': 'fred', 'age': 40, 'active': true }; - * _.map(['active', 'user'], _.propertyOf(object)); - * // => [true, 'fred'] + * var object = { 'user': 'fred', 'age': 40, 'status': 'busy' }; + * _.map(['user', 'status'], _.propertyOf(object)); + * // => ['fred', 'busy'] * * var object = { 'a': 3, 'b': 1, 'c': 2 }; * _.sortBy(['a', 'b', 'c'], _.propertyOf(object)); From 4a622871395025afedc69243a39e6b41c542817e Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 15 Feb 2015 23:04:50 -0800 Subject: [PATCH 10/27] Cleanup `baseLodash` description. [ci skip] --- lodash.src.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 22bc4bfaa9..5a70200b0e 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -944,8 +944,7 @@ } /** - * A no-operation function used to setup inheritance for `lodash`, - * `LodashWrapper`, and `LazyWrapper` . + * The function whose prototype all chaining wrappers inherit from. * * @private */ From f1046f1cf1980dd36fe8c507d3494ad212d0e039 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 15 Feb 2015 23:05:30 -0800 Subject: [PATCH 11/27] Consistent use of `lodash` when referencing a `lodash` wrapper. [ci skip] --- lodash.src.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 5a70200b0e..98c87ee33f 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -11472,7 +11472,7 @@ LazyWrapper.prototype.reverse = lazyReverse; LazyWrapper.prototype.value = lazyValue; - // Add chaining functions to the lodash wrapper. + // Add chaining functions to the `lodash` wrapper. lodash.prototype.chain = wrapperChain; lodash.prototype.commit = wrapperCommit; lodash.prototype.plant = wrapperPlant; @@ -11480,7 +11480,7 @@ lodash.prototype.toString = wrapperToString; lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; - // Add function aliases to the lodash wrapper. + // Add function aliases to the `lodash` wrapper. lodash.prototype.collect = lodash.prototype.map; lodash.prototype.head = lodash.prototype.first; lodash.prototype.select = lodash.prototype.filter; From f42f46c7d695416ebd4ce071724d6004b2e86a7e Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 16 Feb 2015 23:39:23 -0800 Subject: [PATCH 12/27] Adjust doc examples for smaller screens. [ci skip] --- lodash.src.js | 501 +++++++++++++++++++++++++++++++------------------- 1 file changed, 314 insertions(+), 187 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 98c87ee33f..454540d801 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -919,11 +919,15 @@ * var wrapped = _([1, 2, 3]); * * // returns an unwrapped value - * wrapped.reduce(function(sum, n) { return sum + n; }); + * wrapped.reduce(function(sum, n) { + * return sum + n; + * }); * // => 6 * * // returns a wrapped value - * var squares = wrapped.map(function(n) { return n * n; }); + * var squares = wrapped.map(function(n) { + * return n * n; + * }); * * _.isArray(squares); * // => false @@ -4250,7 +4254,7 @@ * @returns {Array} Returns the new array of filtered values. * @example * - * _.difference([1, 2, 3], [5, 2, 10]); + * _.difference([1, 2, 3], [4, 2]); * // => [1, 3] */ function difference() { @@ -4363,7 +4367,9 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.dropRightWhile([1, 2, 3], function(n) { return n > 1; }); + * _.dropRightWhile([1, 2, 3], function(n) { + * return n > 1; + * }); * // => [1] * * var users = [ @@ -4420,7 +4426,9 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.dropWhile([1, 2, 3], function(n) { return n < 3; }); + * _.dropWhile([1, 2, 3], function(n) { + * return n < 3; + * }); * // => [3] * * var users = [ @@ -4510,7 +4518,9 @@ * { 'user': 'pebbles', 'active': true } * ]; * - * _.findIndex(users, function(chr) { return chr.user == 'barney'; }); + * _.findIndex(users, function(chr) { + * return chr.user == 'barney'; + * }); * // => 0 * * // using the `_.matches` callback shorthand @@ -4569,7 +4579,9 @@ * { 'user': 'pebbles', 'active': false } * ]; * - * _.findLastIndex(users, function(chr) { return chr.user == 'pebbles'; }); + * _.findLastIndex(users, function(chr) { + * return chr.user == 'pebbles'; + * }); * // => 2 * * // using the `_.matches` callback shorthand @@ -4629,11 +4641,11 @@ * @returns {Array} Returns the new flattened array. * @example * - * _.flatten([1, [2], [3, [[4]]]]); - * // => [1, 2, 3, [[4]]]; + * _.flatten([1, [2, 3, [4]]]); + * // => [1, 2, 3, [4]]; * * // using `isDeep` - * _.flatten([1, [2], [3, [[4]]]], true); + * _.flatten([1, [2, 3, [4]]], true); * // => [1, 2, 3, 4]; */ function flatten(array, isDeep, guard) { @@ -4654,7 +4666,7 @@ * @returns {Array} Returns the new flattened array. * @example * - * _.flattenDeep([1, [2], [3, [[4]]]]); + * _.flattenDeep([1, [2, 3, [4]]]); * // => [1, 2, 3, 4]; */ function flattenDeep(array) { @@ -4683,15 +4695,15 @@ * @returns {number} Returns the index of the matched value, else `-1`. * @example * - * _.indexOf([1, 2, 3, 1, 2, 3], 2); - * // => 1 + * _.indexOf([1, 2, 1, 2], 2); + * // => 2 * * // using `fromIndex` - * _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); - * // => 4 + * _.indexOf([1, 2, 1, 2], 2, 2); + * // => 3 * * // performing a binary search - * _.indexOf([4, 4, 5, 5, 6, 6], 5, true); + * _.indexOf([1, 1, 2, 2], 2, true); * // => 2 */ function indexOf(array, value, fromIndex) { @@ -4742,9 +4754,8 @@ * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of shared values. * @example - * - * _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]); - * // => [1, 2] + * _.intersection([1, 2], [4, 2], [2, 1]); + * // => [2] */ function intersection() { var args = [], @@ -4820,15 +4831,15 @@ * @returns {number} Returns the index of the matched value, else `-1`. * @example * - * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); - * // => 4 + * _.lastIndexOf([1, 2, 1, 2], 2); + * // => 3 * * // using `fromIndex` - * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); + * _.lastIndexOf([1, 2, 1, 2], 2, 2); * // => 1 * * // performing a binary search - * _.lastIndexOf([4, 4, 5, 5, 6, 6], 5, true); + * _.lastIndexOf([1, 1, 2, 2], 2, true); * // => 3 */ function lastIndexOf(array, value, fromIndex) { @@ -4874,6 +4885,7 @@ * @example * * var array = [1, 2, 3, 1, 2, 3]; + * * _.pull(array, 2, 3); * console.log(array); * // => [1, 1] @@ -4915,7 +4927,7 @@ * @example * * var array = [5, 10, 15, 20]; - * var evens = _.pullAt(array, [1, 3]); + * var evens = _.pullAt(array, 1, 3); * * console.log(array); * // => [5, 15] @@ -4956,7 +4968,9 @@ * @example * * var array = [1, 2, 3, 4]; - * var evens = _.remove(array, function(n) { return n % 2 == 0; }); + * var evens = _.remove(array, function(n) { + * return n % 2 == 0; + * }); * * console.log(array); * // => [1, 3] @@ -5058,7 +5072,7 @@ * _.sortedIndex([30, 50], 40); * // => 1 * - * _.sortedIndex([4, 4, 5, 5, 6, 6], 5); + * _.sortedIndex([4, 4, 5, 5], 5); * // => 2 * * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; @@ -5097,7 +5111,7 @@ * into `array`. * @example * - * _.sortedLastIndex([4, 4, 5, 5, 6, 6], 5); + * _.sortedLastIndex([4, 4, 5, 5], 5); * // => 4 */ function sortedLastIndex(array, value, iteratee, thisArg) { @@ -5204,7 +5218,9 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.takeRightWhile([1, 2, 3], function(n) { return n > 1; }); + * _.takeRightWhile([1, 2, 3], function(n) { + * return n > 1; + * }); * // => [2, 3] * * var users = [ @@ -5261,7 +5277,9 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.takeWhile([1, 2, 3], function(n) { return n < 3; }); + * _.takeWhile([1, 2, 3], function(n) { + * return n < 3; + * }); * // => [1, 2] * * var users = [ @@ -5309,8 +5327,8 @@ * @returns {Array} Returns the new array of combined values. * @example * - * _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]); - * // => [1, 2, 3, 5, 4] + * _.union([1, 2], [4, 2], [2, 1]); + * // => [1, 2, 4] */ function union() { return baseUniq(baseFlatten(arguments, false, true)); @@ -5359,7 +5377,9 @@ * // => [1, 2] * * // using an iteratee function - * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); + * _.uniq([1, 2.5, 1.5, 2], function(n) { + * return this.floor(n); + * }, Math); * // => [1, 2.5] * * // using the `_.property` callback shorthand @@ -5432,8 +5452,8 @@ * @returns {Array} Returns the new array of filtered values. * @example * - * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); - * // => [2, 3, 4] + * _.without([1, 2, 1, 3], 1, 2); + * // => [3] */ function without(array) { return baseDifference(array, baseSlice(arguments, 1)); @@ -5451,11 +5471,8 @@ * @returns {Array} Returns the new array of values. * @example * - * _.xor([1, 2, 3], [5, 2, 1, 4]); - * // => [3, 5, 4] - * - * _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]); - * // => [1, 4, 5] + * _.xor([1, 2], [4, 2]); + * // => [1, 4] */ function xor() { var index = -1, @@ -5554,7 +5571,9 @@ * * var youngest = _.chain(users) * .sortBy('age') - * .map(function(chr) { return chr.user + ' is ' + chr.age; }) + * .map(function(chr) { + * return chr.user + ' is ' + chr.age; + * }) * .first() * .value(); * // => 'pebbles is 1' @@ -5581,7 +5600,9 @@ * @example * * _([1, 2, 3]) - * .tap(function(array) { array.pop(); }) + * .tap(function(array) { + * array.pop(); + * }) * .reverse() * .value(); * // => [2, 1] @@ -5605,7 +5626,9 @@ * * _([1, 2, 3]) * .last() - * .thru(function(value) { return [value]; }) + * .thru(function(value) { + * return [value]; + * }) * .value(); * // => [3] */ @@ -5794,8 +5817,8 @@ * @returns {Array} Returns the new array of picked elements. * @example * - * _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); - * // => ['a', 'c', 'e'] + * _.at(['a', 'b', 'c'], [0, 2]); + * // => ['a', 'c'] * * _.at(['fred', 'barney', 'pebbles'], 0, 2); * // => ['fred', 'pebbles'] @@ -5808,57 +5831,6 @@ return baseAt(collection, baseFlatten(arguments, false, false, 1)); } - /** - * Checks if `value` is in `collection` using `SameValueZero` for equality - * comparisons. If `fromIndex` is negative, it is used as the offset from - * the end of `collection`. - * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. - * - * @static - * @memberOf _ - * @alias contains, include - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {*} target The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {boolean} Returns `true` if a matching element is found, else `false`. - * @example - * - * _.includes([1, 2, 3], 1); - * // => true - * - * _.includes([1, 2, 3], 1, 2); - * // => false - * - * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); - * // => true - * - * _.includes('pebbles', 'eb'); - * // => true - */ - function includes(collection, target, fromIndex) { - var length = collection ? collection.length : 0; - if (!isLength(length)) { - collection = values(collection); - length = collection.length; - } - if (!length) { - return false; - } - if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); - } else { - fromIndex = 0; - } - return (typeof collection == 'string' || !isArray(collection) && isString(collection)) - ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1) - : (getIndexOf(collection, target, fromIndex) > -1); - } - /** * Creates an object composed of keys generated from the results of running * each element of `collection` through `iteratee`. The corresponding value @@ -5887,10 +5859,14 @@ * @returns {Object} Returns the composed aggregate object. * @example * - * _.countBy([4.3, 6.1, 6.4], function(n) { return Math.floor(n); }); + * _.countBy([4.3, 6.1, 6.4], function(n) { + * return Math.floor(n); + * }); * // => { '4': 1, '6': 2 } * - * _.countBy([4.3, 6.1, 6.4], function(n) { return this.floor(n); }, Math); + * _.countBy([4.3, 6.1, 6.4], function(n) { + * return this.floor(n); + * }, Math); * // => { '4': 1, '6': 2 } * * _.countBy(['one', 'two', 'three'], 'length'); @@ -5983,8 +5959,10 @@ * @returns {Array} Returns the new filtered array. * @example * - * var evens = _.filter([1, 2, 3, 4], function(n) { return n % 2 == 0; }); - * // => [2, 4] + * _.filter([4, 5, 6], function(n) { + * return n % 2 == 0; + * }); + * // => [4, 6] * * var users = [ * { 'user': 'barney', 'age': 36, 'active': true }, @@ -6042,7 +6020,9 @@ * { 'user': 'pebbles', 'age': 1, 'active': true } * ]; * - * _.result(_.find(users, function(chr) { return chr.age < 40; }), 'user'); + * _.result(_.find(users, function(chr) { + * return chr.age < 40; + * }), 'user'); * // => 'barney' * * // using the `_.matches` callback shorthand @@ -6080,7 +6060,9 @@ * @returns {*} Returns the matched element, else `undefined`. * @example * - * _.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; }); + * _.findLast([1, 2, 3, 4], function(n) { + * return n % 2 == 1; + * }); * // => 3 */ function findLast(collection, predicate, thisArg) { @@ -6141,10 +6123,14 @@ * @returns {Array|Object|string} Returns `collection`. * @example * - * _([1, 2, 3]).forEach(function(n) { console.log(n); }).value(); + * _([1, 2]).forEach(function(n) { + * console.log(n); + * }).value(); * // => logs each value from left to right and returns the array * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); }); + * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { + * console.log(n, key); + * }); * // => logs each value-key pair and returns the object (iteration order is not guaranteed) */ function forEach(collection, iteratee, thisArg) { @@ -6167,7 +6153,9 @@ * @returns {Array|Object|string} Returns `collection`. * @example * - * _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); + * _([1, 2]).forEachRight(function(n) { + * console.log(n); + * }).join(','); * // => logs each value from right to left and returns the array */ function forEachRight(collection, iteratee, thisArg) { @@ -6204,10 +6192,14 @@ * @returns {Object} Returns the composed aggregate object. * @example * - * _.groupBy([4.2, 6.1, 6.4], function(n) { return Math.floor(n); }); + * _.groupBy([4.2, 6.1, 6.4], function(n) { + * return Math.floor(n); + * }); * // => { '4': [4.2], '6': [6.1, 6.4] } * - * _.groupBy([4.2, 6.1, 6.4], function(n) { return this.floor(n); }, Math); + * _.groupBy([4.2, 6.1, 6.4], function(n) { + * return this.floor(n); + * }, Math); * // => { '4': [4.2], '6': [6.1, 6.4] } * * // using the `_.property` callback shorthand @@ -6222,6 +6214,57 @@ } }); + /** + * Checks if `value` is in `collection` using `SameValueZero` for equality + * comparisons. If `fromIndex` is negative, it is used as the offset from + * the end of `collection`. + * + * **Note:** `SameValueZero` comparisons are like strict equality comparisons, + * e.g. `===`, except that `NaN` matches `NaN`. See the + * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. + * + * @static + * @memberOf _ + * @alias contains, include + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {*} target The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @returns {boolean} Returns `true` if a matching element is found, else `false`. + * @example + * + * _.includes([1, 2, 3], 1); + * // => true + * + * _.includes([1, 2, 3], 1, 2); + * // => false + * + * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); + * // => true + * + * _.includes('pebbles', 'eb'); + * // => true + */ + function includes(collection, target, fromIndex) { + var length = collection ? collection.length : 0; + if (!isLength(length)) { + collection = values(collection); + length = collection.length; + } + if (!length) { + return false; + } + if (typeof fromIndex == 'number') { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); + } else { + fromIndex = 0; + } + return (typeof collection == 'string' || !isArray(collection) && isString(collection)) + ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1) + : (getIndexOf(collection, target, fromIndex) > -1); + } + /** * Creates an object composed of keys generated from the results of running * each element of `collection` through `iteratee`. The corresponding value @@ -6258,10 +6301,14 @@ * _.indexBy(keyData, 'dir'); * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } * - * _.indexBy(keyData, function(object) { return String.fromCharCode(object.code); }); + * _.indexBy(keyData, function(object) { + * return String.fromCharCode(object.code); + * }); * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } * - * _.indexBy(keyData, function(object) { return this.fromCharCode(object.code); }, String); + * _.indexBy(keyData, function(object) { + * return this.fromCharCode(object.code); + * }, String); * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } */ var indexBy = createAggregator(function(result, value, key) { @@ -6331,11 +6378,15 @@ * @returns {Array} Returns the new mapped array. * @example * - * _.map([1, 2, 3], function(n) { return n * 3; }); - * // => [3, 6, 9] + * function timesThree(n) { + * return n * 3; + * } + * + * _.map([1, 2], timesThree); + * // => [3, 6] * - * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; }); - * // => [3, 6, 9] (iteration order is not guaranteed) + * _.map({ 'a': 1, 'b': 2 }, timesThree); + * // => [3, 6] (iteration order is not guaranteed) * * var users = [ * { 'user': 'barney' }, @@ -6390,7 +6441,9 @@ * { 'user': 'fred', 'age': 40 } * ]; * - * _.max(users, function(chr) { return chr.age; }); + * _.max(users, function(chr) { + * return chr.age; + * }); * // => { 'user': 'fred', 'age': 40 }; * * // using the `_.property` callback shorthand @@ -6437,7 +6490,9 @@ * { 'user': 'fred', 'age': 40 } * ]; * - * _.min(users, function(chr) { return chr.age; }); + * _.min(users, function(chr) { + * return chr.age; + * }); * // => { 'user': 'barney', 'age': 36 }; * * // using the `_.property` callback shorthand @@ -6473,10 +6528,14 @@ * @returns {Array} Returns the array of grouped elements. * @example * - * _.partition([1, 2, 3], function(n) { return n % 2; }); + * _.partition([1, 2, 3], function(n) { + * return n % 2; + * }); * // => [[1, 3], [2]] * - * _.partition([1.2, 2.3, 3.4], function(n) { return this.floor(n) % 2; }, Math); + * _.partition([1.2, 2.3, 3.4], function(n) { + * return this.floor(n) % 2; + * }, Math); * // => [[1, 3], [2]] * * var users = [ @@ -6485,7 +6544,9 @@ * { 'user': 'pebbles', 'age': 1, 'active': false } * ]; * - * var mapper = function(array) { return _.pluck(array, 'user'); }; + * var mapper = function(array) { + * return _.pluck(array, 'user'); + * }; * * // using the `_.matches` callback shorthand * _.map(_.partition(users, { 'age': 1, 'active': false }), mapper); @@ -6555,14 +6616,16 @@ * @returns {*} Returns the accumulated value. * @example * - * var sum = _.reduce([1, 2, 3], function(sum, n) { return sum + n; }); - * // => 6 + * _.reduce([1, 2], function(sum, n) { + * return sum + n; + * }); + * // => 3 * - * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { * result[key] = n * 3; * return result; * }, {}); - * // => { 'a': 3, 'b': 6, 'c': 9 } (iteration order is not guaranteed) + * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) */ function reduce(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduce : baseReduce; @@ -6585,7 +6648,10 @@ * @example * * var array = [[0, 1], [2, 3], [4, 5]]; - * _.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []); + * + * _.reduceRight(array, function(flattened, other) { + * return flattened.concat(other); + * }, []); * // => [4, 5, 2, 3, 0, 1] */ function reduceRight(collection, iteratee, accumulator, thisArg) { @@ -6618,7 +6684,9 @@ * @returns {Array} Returns the new filtered array. * @example * - * var odds = _.reject([1, 2, 3, 4], function(n) { return n % 2 == 0; }); + * _.reject([1, 2, 3, 4], function(n) { + * return n % 2 == 0; + * }); * // => [1, 3] * * var users = [ @@ -6718,12 +6786,12 @@ * @returns {number} Returns the size of `collection`. * @example * - * _.size([1, 2]); - * // => 2 - * - * _.size({ 'one': 1, 'two': 2, 'three': 3 }); + * _.size([1, 2, 3]); * // => 3 * + * _.size({ 'a': 1, 'b': 2 }); + * // => 2 + * * _.size('pebbles'); * // => 7 */ @@ -6818,10 +6886,14 @@ * @returns {Array} Returns the new sorted array. * @example * - * _.sortBy([1, 2, 3], function(n) { return Math.sin(n); }); + * _.sortBy([1, 2, 3], function(n) { + * return Math.sin(n); + * }); * // => [3, 1, 2] * - * _.sortBy([1, 2, 3], function(n) { return this.sin(n); }, Math); + * _.sortBy([1, 2, 3], function(n) { + * return this.sin(n); + * }, Math); * // => [3, 1, 2] * * var users = [ @@ -6938,7 +7010,9 @@ * @category Date * @example * - * _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); * // => logs the number of milliseconds it took for the deferred function to be invoked */ var now = nativeNow || function() { @@ -7114,7 +7188,9 @@ * * var view = { * 'label': 'docs', - * 'onClick': function() { console.log('clicked ' + this.label); } + * 'onClick': function() { + * console.log('clicked ' + this.label); + * } * }; * * _.bindAll(view); @@ -7467,7 +7543,9 @@ * @returns {number} Returns the timer id. * @example * - * _.defer(function(text) { console.log(text); }, 'deferred'); + * _.defer(function(text) { + * console.log(text); + * }, 'deferred'); * // logs 'deferred' after one or more milliseconds */ function defer(func) { @@ -7487,7 +7565,9 @@ * @returns {number} Returns the timer id. * @example * - * _.delay(function(text) { console.log(text); }, 1000, 'later'); + * _.delay(function(text) { + * console.log(text); + * }, 1000, 'later'); * // => logs 'later' after one second */ function delay(func, wait) { @@ -7805,7 +7885,9 @@ * // => ['a', 'b', 'c'] * * var map = _.rearg(_.map, [1, 0]); - * map(function(n) { return n * 3; }, [1, 2, 3]); + * map(function(n) { + * return n * 3; + * }, [1, 2, 3]); * // => [3, 6, 9] */ function rearg(func) { @@ -7884,8 +7966,9 @@ * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); * * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes - * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }) - * jQuery('.interactive').on('click', throttled); + * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + * 'trailing': false + * })); * * // cancel a trailing throttled call * jQuery(window).on('popstate', throttled.cancel); @@ -7975,15 +8058,17 @@ * // => false * * // using a customizer callback - * var body = _.clone(document.body, function(value) { - * return _.isElement(value) ? value.cloneNode(false) : undefined; + * var el = _.clone(document.body, function(value) { + * if (_.isElement(value)) { + * return value.cloneNode(false); + * } * }); * - * body === document.body + * el === document.body * // => false - * body.nodeName + * el.nodeName * // => BODY - * body.childNodes.length; + * el.childNodes.length; * // => 0 */ function clone(value, isDeep, customizer, thisArg) { @@ -8030,14 +8115,16 @@ * * // using a customizer callback * var el = _.cloneDeep(document.body, function(value) { - * return _.isElement(value) ? value.cloneNode(true) : undefined; + * if (_.isElement(value)) { + * return value.cloneNode(true); + * } * }); * - * body === document.body + * el === document.body * // => false - * body.nodeName + * el.nodeName * // => BODY - * body.childNodes.length; + * el.childNodes.length; * // => 20 */ function cloneDeep(value, customizer, thisArg) { @@ -8055,7 +8142,7 @@ * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. * @example * - * (function() { return _.isArguments(arguments); })(); + * _.isArguments(function() { return arguments; }()); * // => true * * _.isArguments([1, 2, 3]); @@ -8087,7 +8174,7 @@ * _.isArray([1, 2, 3]); * // => true * - * (function() { return _.isArray(arguments); })(); + * _.isArray(function() { return arguments; }()); * // => false */ var isArray = nativeIsArray || function(value) { @@ -8237,7 +8324,9 @@ * var other = ['hi', 'goodbye']; * * _.isEqual(array, other, function(value, other) { - * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; + * if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) { + * return true; + * } * }); * // => true */ @@ -8655,7 +8744,9 @@ * @returns {Array} Returns the converted array. * @example * - * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3); + * (function() { + * return _.toArray(arguments).slice(1); + * }(1, 2, 3)); * // => [2, 3] */ function toArray(value) { @@ -8754,7 +8845,9 @@ * Shape.call(this); * } * - * Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle }); + * Circle.prototype = _.create(Shape.prototype, { + * 'constructor': Circle + * }); * * var circle = new Circle; * circle instanceof Circle; @@ -8827,7 +8920,9 @@ * 'pebbles': { 'age': 1, 'active': true } * }; * - * _.findKey(users, function(chr) { return chr.age < 40; }); + * _.findKey(users, function(chr) { + * return chr.age < 40; + * }); * // => 'barney' (iteration order is not guaranteed) * * // using the `_.matches` callback shorthand @@ -8878,7 +8973,9 @@ * 'pebbles': { 'age': 1, 'active': true } * }; * - * _.findLastKey(users, function(chr) { return chr.age < 40; }); + * _.findLastKey(users, function(chr) { + * return chr.age < 40; + * }); * // => returns `pebbles` assuming `_.findKey` returns `barney` * * // using the `_.matches` callback shorthand @@ -8977,10 +9074,17 @@ * @returns {Object} Returns `object`. * @example * - * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwn(new Foo, function(value, key) { * console.log(key); * }); - * // => logs '0', '1', and 'length' (iteration order is not guaranteed) + * // => logs 'a' and 'b' (iteration order is not guaranteed) */ function forOwn(object, iteratee, thisArg) { if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { @@ -9002,10 +9106,17 @@ * @returns {Object} Returns `object`. * @example * - * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwnRight(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' + * // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b' */ function forOwnRight(object, iteratee, thisArg) { iteratee = bindCallback(iteratee, thisArg, 3); @@ -9025,7 +9136,7 @@ * @example * * _.functions(_); - * // => ['all', 'any', 'bind', ...] + * // => ['after', 'ary', 'assign', ...] */ function functions(object) { return baseFunctions(object, keysIn(object)); @@ -9043,7 +9154,9 @@ * @returns {boolean} Returns `true` if `key` is a direct property, else `false`. * @example * - * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); + * var object = { 'a': 1, 'b': 2, 'c': 3 }; + * + * _.has(object, 'b'); * // => true */ function has(object, key) { @@ -9064,16 +9177,14 @@ * @returns {Object} Returns the new inverted object. * @example * - * _.invert({ 'first': 'fred', 'second': 'barney' }); - * // => { 'fred': 'first', 'barney': 'second' } + * var object = { 'a': 1, 'b': 2, 'c': 1 }; * - * // without `multiValue` - * _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }); - * // => { 'fred': 'third', 'barney': 'second' } + * _.invert(object); + * // => { '1': 'c', '2': 'b' } * * // with `multiValue` - * _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true); - * // => { 'fred': ['first', 'third'], 'barney': ['second'] } + * _.invert(object, true); + * // => { '1': ['a', 'c'], '2': ['b'] } */ function invert(object, multiValue, guard) { if (guard && isIterateeCall(object, multiValue, guard)) { @@ -9248,8 +9359,10 @@ * @returns {Object} Returns the new mapped object. * @example * - * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(n) { return n * 3; }); - * // => { 'a': 3, 'b': 6, 'c': 9 } + * _.mapValues({ 'a': 1, 'b': 2 }, function(n) { + * return n * 3; + * }); + * // => { 'a': 3, 'b': 6 } * * var users = { * 'fred': { 'user': 'fred', 'age': 40 }, @@ -9312,7 +9425,9 @@ * }; * * _.merge(object, other, function(a, b) { - * return _.isArray(a) ? a.concat(b) : undefined; + * if (_.isArray(a)) { + * return a.concat(b); + * } * }); * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } */ @@ -9478,18 +9593,16 @@ * @returns {*} Returns the accumulated value. * @example * - * var squares = _.transform([1, 2, 3, 4, 5, 6], function(result, n) { - * n *= n; - * if (n % 2) { - * return result.push(n) < 3; - * } + * _.transform([2, 3, 4], function(result, n) { + * result.push(n *= n); + * return n % 2 == 0; * }); - * // => [1, 9, 25] + * // => [4, 9] * - * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) { * result[key] = n * 3; * }); - * // => { 'a': 3, 'b': 6, 'c': 9 } + * // => { 'a': 3, 'b': 6 } */ function transform(object, iteratee, accumulator, thisArg) { var isArr = isArray(object) || isTypedArray(object); @@ -9832,7 +9945,7 @@ } /** - * Converts `string` to kebab case (a.k.a. spinal case). + * Converts `string` to kebab case. * See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for * more details. * @@ -10431,13 +10544,21 @@ * _.trunc('hi-diddly-ho there, neighborino', 24); * // => 'hi-diddly-ho there, n...' * - * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); + * _.trunc('hi-diddly-ho there, neighborino', { + * 'length': 24, + * 'separator': ' ' + * }); * // => 'hi-diddly-ho there,...' * - * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); + * _.trunc('hi-diddly-ho there, neighborino', { + * 'length': 24, + * 'separator': /,? +/ + * }); * //=> 'hi-diddly-ho there...' * - * _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); + * _.trunc('hi-diddly-ho there, neighborino', { + * 'omission': ' [...]' + * }); * // => 'hi-diddly-ho there, neig [...]' */ function trunc(string, options, guard) { @@ -10609,7 +10730,9 @@ * return callback(func, thisArg); * } * return function(object) { - * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3]; + * return match[2] == 'gt' + * ? object[match[1]] > match[3] + * : object[match[1]] < match[3]; * }; * }); * @@ -10884,11 +11007,11 @@ * @returns {Function} Returns the new function. * @example * - * var object = { 'user': 'fred', 'age': 40, 'status': 'busy' }; - * _.map(['user', 'status'], _.propertyOf(object)); - * // => ['fred', 'busy'] - * * var object = { 'a': 3, 'b': 1, 'c': 2 }; + * + * _.map(['a', 'c'], _.propertyOf(object)); + * // => [3, 2] + * * _.sortBy(['a', 'b', 'c'], _.propertyOf(object)); * // => ['b', 'c', 'a'] */ @@ -10974,10 +11097,14 @@ * var diceRolls = _.times(3, _.partial(_.random, 1, 6, false)); * // => [3, 6, 4] * - * _.times(3, function(n) { mage.castSpell(n); }); + * _.times(3, function(n) { + * mage.castSpell(n); + * }); * // => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2` respectively * - * _.times(3, function(n) { this.cast(n); }, mage); + * _.times(3, function(n) { + * this.cast(n); + * }, mage); * // => also invokes `mage.castSpell(n)` three times */ function times(n, iteratee, thisArg) { From cb132fcbf4b470d00eab6b9643e9e5abd9ff2a95 Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 17 Feb 2015 23:37:03 -0800 Subject: [PATCH 13/27] Add more iteration method tests. --- test/test.js | 283 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 197 insertions(+), 86 deletions(-) diff --git a/test/test.js b/test/test.js index 85e3638c6b..3177c7f57e 100644 --- a/test/test.js +++ b/test/test.js @@ -4962,6 +4962,7 @@ (function() { var methods = [ + '_baseEach', 'countBy', 'every', 'filter', @@ -4971,6 +4972,7 @@ 'findLast', 'findLastIndex', 'findLastKey', + 'forEach', 'forEachRight', 'forIn', 'forInRight', @@ -4995,6 +4997,7 @@ ]; var collectionMethods = [ + '_baseEach', 'countBy', 'every', 'filter', @@ -5022,6 +5025,7 @@ ]; var iterationMethods = [ + '_baseEach', 'forEach', 'forEachRight', 'forIn', @@ -5066,35 +5070,75 @@ _.each(methods, function(methodName) { var array = [1, 2, 3], - func = _[methodName]; + func = _[methodName], + isFind = /^find/.test(methodName), + isSome = methodName == 'some'; test('`_.' + methodName + '` should provide the correct `iteratee` arguments', 1, function() { - var args, - expected = [1, 0, array]; + if (func) { + var args, + expected = [1, 0, array]; - func(array, function() { - args || (args = slice.call(arguments)); - }); + func(array, function() { + args || (args = slice.call(arguments)); + }); - if (_.includes(rightMethods, methodName)) { - expected[0] = 3; - expected[1] = 2; + if (_.includes(rightMethods, methodName)) { + expected[0] = 3; + expected[1] = 2; + } + if (_.includes(objectMethods, methodName)) { + expected[1] += ''; + } + deepEqual(args, expected); } - if (_.includes(objectMethods, methodName)) { - expected[1] += ''; + else { + skipTest(); } - deepEqual(args, expected); }); test('`_.' + methodName + '` should support the `thisArg` argument', 2, function() { - var actual, - callback = function(num, index) { actual = this[index]; }; + if (methodName != '_baseEach') { + var actual, + callback = function(num, index) { actual = this[index]; }; - func([1], callback, [2]); - strictEqual(actual, 2); + func([1], callback, [2]); + strictEqual(actual, 2); - func({ 'a': 1 }, callback, { 'a': 2 }); - strictEqual(actual, 2); + func({ 'a': 1 }, callback, { 'a': 2 }); + strictEqual(actual, 2); + } + else { + skipTest(2); + } + }); + + test('`_.' + methodName + '` should treat sparse arrays as dense', 1, function() { + if (func) { + var array = [1]; + array[2] = 3; + + var expected = [[1, 0, array], [undefined, 1, array], [3, 2, array]]; + if (_.includes(objectMethods, methodName)) { + expected = _.map(expected, function(args) { + args[1] += ''; + return args; + }); + } + if (_.includes(rightMethods, methodName)) { + expected.reverse(); + } + var actual = []; + func(array, function(value, key, array) { + actual.push([value, key, array]); + return !(isFind || isSome); + }); + + deepEqual(actual, expected); + } + else { + skipTest(); + } }); }); @@ -5106,22 +5150,28 @@ array.a = 1; test('`_.' + methodName + '` should not iterate custom properties on arrays', 1, function() { - var keys = []; - func(array, function(value, key) { - keys.push(key); - return isEvery; - }); + if (func) { + var keys = []; + func(array, function(value, key) { + keys.push(key); + return isEvery; + }); - ok(!_.includes(keys, 'a')); + ok(!_.includes(keys, 'a')); + } + else { + skipTest(); + } }); }); _.each(_.difference(methods, unwrappedMethods), function(methodName) { var array = [1, 2, 3], - func = _[methodName]; + func = _[methodName], + isBaseEach = methodName == '_baseEach'; test('`_.' + methodName + '` should return a wrapped value when chaining', 1, function() { - if (!isNpm) { + if (!(isBaseEach || isNpm)) { var wrapped = _(array)[methodName](_.noop); ok(wrapped instanceof _); } @@ -5154,24 +5204,35 @@ function Foo() { this.a = 1; } Foo.prototype.b = 2; - var keys = []; - func(new Foo, function(value, key) { keys.push(key); }); - deepEqual(keys, ['a']); + if (func) { + var keys = []; + func(new Foo, function(value, key) { keys.push(key); }); + deepEqual(keys, ['a']); + } + else { + skipTest(); + } }); }); _.each(iterationMethods, function(methodName) { var array = [1, 2, 3], func = _[methodName], - isEach = !_.includes(objectMethods, methodName), + isBaseEach = methodName == '_baseEach', + isObject = _.includes(objectMethods, methodName), isRight = _.includes(rightMethods, methodName); test('`_.' + methodName + '` should return the collection', 1, function() { - strictEqual(func(array, Boolean), array); + if (func) { + strictEqual(func(array, Boolean), array); + } + else { + skipTest(); + } }); test('`_.' + methodName + '` should not return the existing wrapped value when chaining', 1, function() { - if (!isNpm) { + if (!(isBaseEach || isNpm)) { var wrapped = _(array); notStrictEqual(wrapped[methodName](_.noop), wrapped); } @@ -5186,29 +5247,34 @@ }, function(collection, key) { test('`_.' + methodName + '` should work with a string ' + key + ' for `collection` (test in IE < 9)', 6, function() { - var args, - values = [], - expectedChars = ['a', 'b', 'c']; + if (func) { + var args, + values = [], + expectedChars = ['a', 'b', 'c']; - var expectedArgs = isEach - ? (isRight ? ['c', 2, collection] : ['a', 0, collection]) - : (isRight ? ['c', '2', collection] : ['a', '0', collection]) + var expectedArgs = isObject + ? (isRight ? ['c', '2', collection] : ['a', '0', collection]) + : (isRight ? ['c', 2, collection] : ['a', 0, collection]); - var actual = func(collection, function(value) { - args || (args = slice.call(arguments)); - values.push(value); - }); + var actual = func(collection, function(value) { + args || (args = slice.call(arguments)); + values.push(value); + }); - var stringObject = args[2]; + var stringObject = args[2]; - ok(_.isString(stringObject)); - ok(_.isObject(stringObject)); + ok(_.isString(stringObject)); + ok(_.isObject(stringObject)); - deepEqual([stringObject[0], stringObject[1], stringObject[2]], expectedChars); - deepEqual(args, expectedArgs); - deepEqual(values, isRight ? ['c', 'b', 'a'] : expectedChars); + deepEqual([stringObject[0], stringObject[1], stringObject[2]], expectedChars); + deepEqual(args, expectedArgs); + deepEqual(values, isRight ? ['c', 'b', 'a'] : expectedChars); - strictEqual(actual, collection); + strictEqual(actual, collection); + } + else { + skipTest(6); + } }); }); }); @@ -5217,37 +5283,74 @@ var func = _[methodName]; test('`_.' + methodName + '` should use `isLength` to determine whether a value is array-like', 2, function() { - function isIteratedAsObject(length) { - var result = false; - func({ 'length': length }, function() { result = true; }, 0); - return result; + if (func) { + var isIteratedAsObject = function(length) { + var result = false; + func({ 'length': length }, function() { result = true; }, 0); + return result; + }; + + var values = [-1, '1', 1.1, Object(1), MAX_SAFE_INTEGER + 1], + expected = _.map(values, _.constant(true)), + actual = _.map(values, isIteratedAsObject); + + deepEqual(actual, expected); + ok(!isIteratedAsObject(0)); + } + else { + skipTest(2); } + }); + }); + + _.each(methods, function(methodName) { + var array = [1, 2, 3], + func = _[methodName], + isFind = /^find/.test(methodName), + isSome = methodName == 'some'; - var values = [-1, '1', 1.1, Object(1), MAX_SAFE_INTEGER + 1], - expected = _.map(values, _.constant(true)), - actual = _.map(values, isIteratedAsObject); + test('`_.' + methodName + '` should ignore changes to `array.length`', 1, function() { + if (func) { + var count = 0, + array = [1]; - deepEqual(actual, expected); - ok(!isIteratedAsObject(0)); + func(array, function() { + if (++count == 1) { + array.push(2); + } + return !(isFind || isSome); + }, array); + + strictEqual(count, 1); + } + else { + skipTest(); + } }); }); - _.each(collectionMethods.concat(objectMethods), function(methodName) { - var func = _[methodName]; + _.each(_.difference(_.union(methods, collectionMethods), arrayMethods), function(methodName) { + var func = _[methodName], + isFind = /^find/.test(methodName), + isSome = methodName == 'some'; - test('`_.' + methodName + '` should compute length before iteration', 2, function() { - _.each([[0], { 'a': 0 }], function(collection) { - var count = 0; + test('`_.' + methodName + '` should ignore added `object` properties', 1, function() { + if (func) { + var count = 0, + object = { 'a': 1 }; - func(collection, function() { - collection[++count] = count; - if (count > 1) { - return false; + func(object, function() { + if (++count == 1) { + object.b = 2; } - }, 0); + return !(isFind || isSome); + }, object); strictEqual(count, 1); - }); + } + else { + skipTest(); + } }); }); }()); @@ -5474,31 +5577,39 @@ _.each(['_baseEach', 'forEach', 'forEachRight', 'forIn', 'forInRight', 'forOwn', 'forOwnRight', 'transform'], function(methodName) { var func = _[methodName]; - if (!func) { - return; - } + test('`_.' + methodName + '` can exit early when iterating arrays', 1, function() { - var array = [1, 2, 3], - values = []; + if (func) { + var array = [1, 2, 3], + values = []; - func(array, function(value, other) { - values.push(_.isArray(value) ? other : value); - return false; - }); + func(array, function(value, other) { + values.push(_.isArray(value) ? other : value); + return false; + }); - deepEqual(values, [_.endsWith(methodName, 'Right') ? 3 : 1]); + deepEqual(values, [_.endsWith(methodName, 'Right') ? 3 : 1]); + } + else { + skipTest(); + } }); test('`_.' + methodName + '` can exit early when iterating objects', 1, function() { - var object = { 'a': 1, 'b': 2, 'c': 3 }, - values = []; + if (func) { + var object = { 'a': 1, 'b': 2, 'c': 3 }, + values = []; - func(object, function(value, other) { - values.push(_.isArray(value) ? other : value); - return false; - }); + func(object, function(value, other) { + values.push(_.isArray(value) ? other : value); + return false; + }); - strictEqual(values.length, 1); + strictEqual(values.length, 1); + } + else { + skipTest(); + } }); }); From 15398555b363f2af5e12082ac865eab06fcfc4fa Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 18 Feb 2015 00:33:51 -0800 Subject: [PATCH 14/27] Ensure `isIterateeCall` works with `NaN` values. --- lodash.src.js | 3 +- test/test.js | 111 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 112 insertions(+), 2 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 454540d801..3a6a9f09f9 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -3837,7 +3837,8 @@ } else { prereq = type == 'string' && index in object; } - return prereq && object[index] === value; + var other = object[index]; + return prereq && (value === value ? value === other : other !== other); } /** diff --git a/test/test.js b/test/test.js index 3177c7f57e..1e92c79b73 100644 --- a/test/test.js +++ b/test/test.js @@ -418,7 +418,7 @@ if (isModularize && !isNpm) { _.each(['baseEach', 'isIndex', 'isIterateeCall', 'isLength'], function(funcName) { var path = require('path'), - func = require(path.join(path.dirname(filePath), 'internal', 'baseEach.js')); + func = require(path.join(path.dirname(filePath), 'internal', funcName + '.js')); _['_' + funcName] = func[funcName] || func['default'] || func; }); @@ -780,6 +780,115 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('isIndex'); + + (function() { + var func = _._isIndex; + + test('should return `true` for indexes', 4, function() { + if (func) { + strictEqual(func(0), true); + strictEqual(func('1'), true); + strictEqual(func(3, 4), true); + strictEqual(func(MAX_SAFE_INTEGER - 1), true); + } + else { + skipTest(4); + } + }); + + test('should return `false` for non-indexes', 4, function() { + if (func) { + strictEqual(func(-1), false); + strictEqual(func(3, 3), false); + strictEqual(func(1.1), false); + strictEqual(func(MAX_SAFE_INTEGER), false); + } + else { + skipTest(4); + } + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('isIterateeCall'); + + (function() { + var array = [1], + func = _._isIterateeCall, + object = { 'a': 1 }; + + test('should return `true` for iteratee calls', 3, function() { + function Foo() {} + Foo.prototype.a = 1; + + if (func) { + strictEqual(func(1, 0, array), true); + strictEqual(func(1, 'a', object), true); + strictEqual(func(1, 'a', new Foo), true); + } + else { + skipTest(3); + } + }); + + test('should work with `NaN` values', 2, function() { + if (func) { + strictEqual(func(NaN, 0, [NaN]), true); + strictEqual(func(NaN, 'a', { 'a': NaN }), true); + } + else { + skipTest(2); + } + }); + + test('should return `false` for non-iteratee calls', 4, function() { + if (func) { + strictEqual(func(2, 0, array), false); + strictEqual(func(1, 1.1, array), false); + strictEqual(func(1, 0, { 'length': MAX_SAFE_INTEGER + 1 }), false); + strictEqual(func(1, 'b', object), false); + } + else { + skipTest(4); + } + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('isLength'); + + (function() { + var func = _._isLength; + + test('should return `true` for lengths', 3, function() { + if (func) { + strictEqual(func(0), true); + strictEqual(func(3), true); + strictEqual(func(MAX_SAFE_INTEGER), true); + } + else { + skipTest(3); + } + }); + + test('should return `false` for non-lengths', 4, function() { + if (func) { + strictEqual(func(-1), false); + strictEqual(func('1'), false); + strictEqual(func(1.1), false); + strictEqual(func(MAX_SAFE_INTEGER + 1), false); + } + else { + skipTest(4); + } + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash constructor'); (function() { From 3516881e7acf270231670433d4a13e527a38a247 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 18 Feb 2015 00:46:02 -0800 Subject: [PATCH 15/27] Update tested Chrome in saucelabs.js. --- test/saucelabs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/saucelabs.js b/test/saucelabs.js index 975df98336..0c2978c655 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -108,8 +108,8 @@ var platforms = [ ['Windows 8.1', 'firefox', '35'], ['Windows 8.1', 'firefox', '34'], ['Windows 8.1', 'firefox', '20'], + ['Windows 8.1', 'chrome', '40'], ['Windows 8.1', 'chrome', '39'], - ['Windows 8.1', 'chrome', '38'], ['Windows 8.1', 'internet explorer', '11'], ['Windows 8', 'internet explorer', '10'], ['Windows 7', 'internet explorer', '9'], From 6209c120c0ec329ce161e6a38c6053217d1814bf Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 18 Feb 2015 01:03:53 -0800 Subject: [PATCH 16/27] Non-nits. --- test/test.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/test.js b/test/test.js index 1e92c79b73..4e79ec4012 100644 --- a/test/test.js +++ b/test/test.js @@ -6587,7 +6587,7 @@ strictEqual(_.isArray([1, 2, 3]), true); }); - test('should return `false` for non arrays', 12, function() { + test('should return `false` for non-arrays', 12, function() { var expected = _.map(falsey, _.constant(false)); var actual = _.map(falsey, function(value, index) { @@ -6633,7 +6633,7 @@ strictEqual(_.isBoolean(Object(false)), true); }); - test('should return `false` for non booleans', 12, function() { + test('should return `false` for non-booleans', 12, function() { var expected = _.map(falsey, function(value) { return value === false; }); var actual = _.map(falsey, function(value, index) { @@ -6676,7 +6676,7 @@ strictEqual(_.isDate(new Date), true); }); - test('should return `false` for non dates', 12, function() { + test('should return `false` for non-dates', 12, function() { var expected = _.map(falsey, _.constant(false)); var actual = _.map(falsey, function(value, index) { @@ -6802,7 +6802,7 @@ strictEqual(_.isEmpty(), true); }); - test('should return `false` for non empty values', 3, function() { + test('should return `false` for non-empty values', 3, function() { strictEqual(_.isEmpty([0]), false); strictEqual(_.isEmpty({ 'a': 0 }), false); strictEqual(_.isEmpty('a'), false); @@ -7540,7 +7540,7 @@ deepEqual(actual, expected); }); - test('should return `false` for non finite values', 9, function() { + test('should return `false` for non-finite values', 9, function() { var values = [NaN, Infinity, -Infinity, Object(1)], expected = _.map(values, _.constant(false)); @@ -7560,7 +7560,7 @@ strictEqual(_.isFinite('a'), false); }); - test('should return `false` for non numeric values', 1, function() { + test('should return `false` for non-numeric values', 1, function() { var values = [undefined, [], true, new Date, new Error, '', ' ', '2px'], expected = _.map(values, _.constant(false)); @@ -7607,7 +7607,7 @@ deepEqual(actual, expected); }); - test('should return `false` for non functions', 11, function() { + test('should return `false` for non-functions', 11, function() { var expected = _.map(falsey, _.constant(false)); var actual = _.map(falsey, function(value, index) { @@ -7937,7 +7937,7 @@ strictEqual(_.isNaN(Object(NaN)), true); }); - test('should return `false` for non NaNs', 12, function() { + test('should return `false` for non-NaNs', 12, function() { var expected = _.map(falsey, function(value) { return value !== value; }); var actual = _.map(falsey, function(value, index) { @@ -7994,7 +7994,7 @@ } }); - test('should return `false` for non native methods', 12, function() { + test('should return `false` for non-native methods', 12, function() { var expected = _.map(falsey, _.constant(false)); var actual = _.map(falsey, function(value, index) { @@ -8043,7 +8043,7 @@ strictEqual(_.isNull(null), true); }); - test('should return `false` for non nulls', 13, function() { + test('should return `false` for non-nulls', 13, function() { var expected = _.map(falsey, function(value) { return value === null; }); var actual = _.map(falsey, function(value, index) { @@ -8089,7 +8089,7 @@ strictEqual(_.isNumber(NaN), true); }); - test('should return `false` for non numbers', 11, function() { + test('should return `false` for non-numbers', 11, function() { var expected = _.map(falsey, function(value) { return typeof value == 'number'; }); var actual = _.map(falsey, function(value, index) { @@ -8151,7 +8151,7 @@ } }); - test('should return `false` for non objects', 1, function() { + test('should return `false` for non-objects', 1, function() { var values = falsey.concat(true, 1, 'a'), expected = _.map(values, _.constant(false)); @@ -8253,7 +8253,7 @@ strictEqual(_.isPlainObject(Math), false); }); - test('should return `false` for non objects', 3, function() { + test('should return `false` for non-objects', 3, function() { var expected = _.map(falsey, _.constant(false)); var actual = _.map(falsey, function(value, index) { @@ -8288,7 +8288,7 @@ strictEqual(_.isRegExp(RegExp('x')), true); }); - test('should return `false` for non regexes', 12, function() { + test('should return `false` for non-regexes', 12, function() { var expected = _.map(falsey, _.constant(false)); var actual = _.map(falsey, function(value, index) { @@ -8332,7 +8332,7 @@ strictEqual(_.isString(Object('a')), true); }); - test('should return `false` for non strings', 12, function() { + test('should return `false` for non-strings', 12, function() { var expected = _.map(falsey, function(value) { return value === ''; }); var actual = _.map(falsey, function(value, index) { From 9734fd035370380b44f836d37544291bbae4616d Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 18 Feb 2015 01:05:39 -0800 Subject: [PATCH 17/27] Increase `_.merge` test coverage. --- test/test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test.js b/test/test.js index 4e79ec4012..3632e839cb 100644 --- a/test/test.js +++ b/test/test.js @@ -9774,6 +9774,20 @@ deepEqual(actual, expected); }); + test('should assign non array/plain-object values directly', 1, function() { + function Foo() {} + + var values = [new Foo, new Boolean, new Date, Foo, new Number, new String, new RegExp], + expected = _.map(values, _.constant(true)); + + var actual = _.map(values, function(value) { + var object = _.merge({}, { 'a': value }); + return object.a === value; + }); + + deepEqual(actual, expected); + }); + test('should handle merging if `customizer` returns `undefined`', 2, function() { var actual = _.merge({ 'a': { 'b': [1, 1] } }, { 'a': { 'b': [0] } }, _.noop); deepEqual(actual, { 'a': { 'b': [0, 1] } }); From 153fe61b4b8e829d7fa1a2e1babe2dcd06a85ebb Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 18 Feb 2015 21:05:39 -0800 Subject: [PATCH 18/27] Avoid iterating strings in `_.merge`. [closes #978] --- lodash.src.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index 3a6a9f09f9..6bc73ed094 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2548,8 +2548,10 @@ * @returns {Object} Returns the destination object. */ function baseMerge(object, source, customizer, stackA, stackB) { + if (!isObjectLike(object)) { + return object; + } var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source)); - (isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) { if (isObjectLike(srcValue)) { stackA || (stackA = []); From 633b1663ca14b61a6c64907a6257ce06bbd46898 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 18 Feb 2015 23:22:03 -0800 Subject: [PATCH 19/27] Tweak `iteration methods` test. --- test/test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test.js b/test/test.js index 3632e839cb..10c3cd7d43 100644 --- a/test/test.js +++ b/test/test.js @@ -5237,13 +5237,13 @@ if (_.includes(rightMethods, methodName)) { expected.reverse(); } - var actual = []; - func(array, function(value, key, array) { - actual.push([value, key, array]); + var argsList = []; + func(array, function() { + argsList.push(slice.call(arguments)); return !(isFind || isSome); }); - deepEqual(actual, expected); + deepEqual(argsList, expected); } else { skipTest(); From 0dc70ca5f35ea95b9dba8c8df5a8af0085fa498f Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 18 Feb 2015 23:35:09 -0800 Subject: [PATCH 20/27] Semicolon nits. --- test/test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test.js b/test/test.js index 10c3cd7d43..a4ad61db44 100644 --- a/test/test.js +++ b/test/test.js @@ -10802,7 +10802,7 @@ deepEqual(c(3, 5), expected); - a = _.partial(fn, ph3, 2) + a = _.partial(fn, ph3, 2); b = _.bind(a, object, 1, ph1, 4); c = _.partialRight(b, ph4, 6); @@ -10829,7 +10829,7 @@ deepEqual(c(1), expected); - a = _.partial(fn, ph3, 2) + a = _.partial(fn, ph3, 2); b = _.bind(a, object, ph1, 3); c = _.partialRight(b, ph4, 4); @@ -10987,7 +10987,7 @@ }); deepEqual(actual, [[1.1, 1.3], [0.2]]); - }) + }); }()); /*--------------------------------------------------------------------------*/ @@ -12901,7 +12901,7 @@ var expected = (isSortedIndex ? !_.isNaN(value) : _.isFinite(value)) ? 0 - : Math.min(length, MAX_ARRAY_INDEX) + : Math.min(length, MAX_ARRAY_INDEX); // Avoid false fails in older Firefox. if (array.length == length) { @@ -13345,7 +13345,7 @@ strictEqual(compiled(), "'\n\r\t\u2028\u2029\\"); var data = { 'a': 'A' }; - compiled = _.template('\'\n\r\t<%= a %>\u2028\u2029\\"') + compiled = _.template('\'\n\r\t<%= a %>\u2028\u2029\\"'); strictEqual(compiled(data), '\'\n\r\tA\u2028\u2029\\"'); }); From 474ae1e91c207c63188cbefa61ce08991c45599a Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 18 Feb 2015 23:35:43 -0800 Subject: [PATCH 21/27] Allow `isDeep` of `_.clone` to work with more truthy values. --- lodash.src.js | 11 ++++++----- test/test.js | 13 ++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 6bc73ed094..18eac6170b 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -5394,8 +5394,7 @@ if (!length) { return []; } - // Juggle arguments. - if (typeof isSorted != 'boolean' && isSorted != null) { + if (isSorted != null && typeof isSorted != 'boolean') { thisArg = iteratee; iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; isSorted = false; @@ -8075,10 +8074,12 @@ * // => 0 */ function clone(value, isDeep, customizer, thisArg) { - // Juggle arguments. - if (typeof isDeep != 'boolean' && isDeep != null) { + if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) { + isDeep = false; + } + else if (typeof isDeep == 'function') { thisArg = customizer; - customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep; + customizer = isDeep; isDeep = false; } customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); diff --git a/test/test.js b/test/test.js index a4ad61db44..5f41925b55 100644 --- a/test/test.js +++ b/test/test.js @@ -1851,12 +1851,15 @@ ok(actual !== expected && actual[0] === expected[0]); }); - test('`_.clone` should work with `isDeep`', 2, function() { - var expected = [{ 'a': 0 }, { 'b': 1 }], - actual = _.clone(expected, true); + test('`_.clone` should work with `isDeep`', 8, function() { + var array = [{ 'a': 0 }, { 'b': 1 }], + values = [true, 1, {}, '1']; - deepEqual(actual, expected); - ok(actual !== expected && actual[0] !== expected[0]); + _.each(values, function(isDeep) { + var actual = _.clone(array, isDeep); + deepEqual(actual, array); + ok(actual !== array && actual[0] !== array[0]); + }); }); test('`_.cloneDeep` should deep clone objects with circular references', 1, function() { From 10ee74d872f8c12a976a05f9a1c82c90f13b3c7d Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 18 Feb 2015 23:48:32 -0800 Subject: [PATCH 22/27] Cleanup clone tests. --- test/test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test.js b/test/test.js index 5f41925b55..4e0a1397d9 100644 --- a/test/test.js +++ b/test/test.js @@ -1844,11 +1844,11 @@ }); test('`_.clone` should perform a shallow clone', 2, function() { - var expected = [{ 'a': 0 }, { 'b': 1 }], - actual = _.clone(expected); + var array = [{ 'a': 0 }, { 'b': 1 }], + actual = _.clone(array); - deepEqual(actual, expected); - ok(actual !== expected && actual[0] === expected[0]); + deepEqual(actual, array); + ok(actual !== array && actual[0] === array[0]); }); test('`_.clone` should work with `isDeep`', 8, function() { @@ -1871,8 +1871,8 @@ object.foo.b.c.d = object; object.bar.b = object.foo.b; - var clone = _.cloneDeep(object); - ok(clone.bar.b === clone.foo.b && clone === clone.foo.b.c.d && clone !== object); + var actual = _.cloneDeep(object); + ok(actual.bar.b === actual.foo.b && actual === actual.foo.b.c.d && actual !== object); }); _.each(['clone', 'cloneDeep'], function(methodName) { From 89ed40e4a4f76c86fcd99be9a5deac020af15407 Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 19 Feb 2015 00:14:59 -0800 Subject: [PATCH 23/27] Add `_.merge`. tests. --- lodash.src.js | 2 +- test/test.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index 18eac6170b..5f1c095c2b 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2548,7 +2548,7 @@ * @returns {Object} Returns the destination object. */ function baseMerge(object, source, customizer, stackA, stackB) { - if (!isObjectLike(object)) { + if (!isObject(object)) { return object; } var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source)); diff --git a/test/test.js b/test/test.js index 4e0a1397d9..805e6307c8 100644 --- a/test/test.js +++ b/test/test.js @@ -9791,6 +9791,37 @@ deepEqual(actual, expected); }); + test('should work with a function `object` value', 2, function() { + function Foo() {} + + var source = { 'a': 1 }, + actual = _.merge(Foo, source); + + strictEqual(actual, Foo); + strictEqual(Foo.a, 1); + }); + + test('should work with a non-plain `object` value', 2, function() { + function Foo() {} + + var object = new Foo, + source = { 'a': 1 }, + actual = _.merge(object, source); + + strictEqual(actual, object); + strictEqual(object.a, 1); + }); + + test('should pass thru primitive `object` values', 1, function() { + var values = [true, 1, '1']; + + var actual = _.map(values, function(value) { + return _.merge(value, { 'a': 1 }); + }); + + deepEqual(actual, values); + }); + test('should handle merging if `customizer` returns `undefined`', 2, function() { var actual = _.merge({ 'a': { 'b': [1, 1] } }, { 'a': { 'b': [0] } }, _.noop); deepEqual(actual, { 'a': { 'b': [0, 1] } }); From dc4cef17d4cf86b075406e00af38a3955496be1a Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 19 Feb 2015 00:39:25 -0800 Subject: [PATCH 24/27] Update ecstatic, istanbul, & sauce-tunnel in travis.yml. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f294006555..02249729c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,8 +42,8 @@ before_install: - "nvm use $TRAVIS_NODE_VERSION" - "npm config set loglevel error" - "npm i -g npm@\"$NPM_VERSION\"" - - "[ $SAUCE_LABS == false ] || npm i chalk@\"0.5.1\" ecstatic@\"0.5.8\" request@\"^2.0.0\" sauce-tunnel@\"2.1.1\"" - - "[ $ISTANBUL == false ] || (npm i -g coveralls@\"^2.0.0\" && npm i istanbul@\"0.3.5\")" + - "[ $SAUCE_LABS == false ] || npm i chalk@\"0.5.1\" ecstatic@\"0.6.0\" request@\"^2.0.0\" sauce-tunnel@\"2.2.2\"" + - "[ $ISTANBUL == false ] || (npm i -g coveralls@\"^2.0.0\" && npm i istanbul@\"0.3.6\")" - "[ $BIN != 'rhino' ] || (sudo mkdir /opt/rhino-1.7R5 && sudo wget --no-check-certificate -O $_/js.jar https://lodash.com/_travis/rhino-1.7R5.jar)" - "[ $BIN != 'rhino' ] || (echo -e '#!/bin/sh\\njava -jar /opt/rhino-1.7R5/js.jar $@' | sudo tee /usr/local/bin/rhino && sudo chmod +x /usr/local/bin/rhino)" - "[ $BIN != 'ringo' ] || (wget --no-check-certificate https://lodash.com/_travis/ringojs-0.11.zip && sudo unzip ringojs-0.11 -d /opt && rm ringojs-0.11.zip)" From 7749a7e41de09ad713e27fdfe19a39262ce2ec5b Mon Sep 17 00:00:00 2001 From: jdalton Date: Fri, 20 Feb 2015 02:14:13 -0800 Subject: [PATCH 25/27] Add gitter webhook to travis.yml. --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 02249729c0..feeb737a0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,12 @@ git: branches: only: - master +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/4aab6358b0e9aed0b628 + on_success: change + on_failure: always before_install: - "nvm use $TRAVIS_NODE_VERSION" - "npm config set loglevel error" From eb16051b1e25794f775f3772ab9e7c22f3b94c52 Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 19 Feb 2015 23:08:00 -0800 Subject: [PATCH 26/27] Rebuild lodash and docs. --- doc/README.md | 870 ++++++++++++++++++++++++++++++-------------------- lodash.js | 653 ++++++++++++++++++++++++------------- lodash.min.js | 168 +++++----- lodash.src.js | 4 +- 4 files changed, 1036 insertions(+), 659 deletions(-) diff --git a/doc/README.md b/doc/README.md index b624f979a1..6c31751ef6 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# lodash v3.2.0 +# lodash v3.3.0 @@ -184,6 +184,7 @@ ## `Number` +* `_.inRange` * `_.random` @@ -312,7 +313,7 @@ ### `_.chunk(array, [size=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4167 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4197 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.chunk "See the npm package") Creates an array of elements split into groups the length of `size`. If `collection` can't be split evenly, the final chunk will be the remaining @@ -340,7 +341,7 @@ _.chunk(['a', 'b', 'c', 'd'], 3); ### `_.compact(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4198 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4228 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.compact "See the npm package") Creates an array with all falsey values removed. The values `false`, `null`, `0`, `""`, `undefined`, and `NaN` are falsey. @@ -363,7 +364,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4233 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4263 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.difference "See the npm package") Creates an array excluding all values of the provided arrays using `SameValueZero` for equality comparisons. @@ -383,7 +384,7 @@ for more details. #### Example ```js -_.difference([1, 2, 3], [5, 2, 10]); +_.difference([1, 2, 3], [4, 2]); // => [1, 3] ``` * * * @@ -393,7 +394,7 @@ _.difference([1, 2, 3], [5, 2, 10]); ### `_.drop(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4270 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4300 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.drop "See the npm package") Creates a slice of `array` with `n` elements dropped from the beginning. @@ -425,7 +426,7 @@ _.drop([1, 2, 3], 0); ### `_.dropRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4305 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4335 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropright "See the npm package") Creates a slice of `array` with `n` elements dropped from the end. @@ -457,7 +458,7 @@ _.dropRight([1, 2, 3], 0); ### `_.dropRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4364 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4396 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.droprightwhile "See the npm package") Creates a slice of `array` excluding elements dropped from the end. Elements are dropped until `predicate` returns falsey. The predicate is @@ -487,7 +488,9 @@ object, else `false`. #### Example ```js -_.dropRightWhile([1, 2, 3], function(n) { return n > 1; }); +_.dropRightWhile([1, 2, 3], function(n) { + return n > 1; +}); // => [1] var users = [ @@ -515,7 +518,7 @@ _.pluck(_.dropRightWhile(users, 'active'), 'user'); ### `_.dropWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4421 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4455 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropwhile "See the npm package") Creates a slice of `array` excluding elements dropped from the beginning. Elements are dropped until `predicate` returns falsey. The predicate is @@ -545,7 +548,9 @@ object, else `false`. #### Example ```js -_.dropWhile([1, 2, 3], function(n) { return n < 3; }); +_.dropWhile([1, 2, 3], function(n) { + return n < 3; +}); // => [3] var users = [ @@ -573,7 +578,7 @@ _.pluck(_.dropWhile(users, 'active'), 'user'); ### `_.fill(array, value, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4447 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4481 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.fill "See the npm package") Fills elements of `array` with `value` from `start` up to, but not including, `end`. @@ -597,7 +602,7 @@ including, `end`. ### `_.findIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4505 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4541 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findindex "See the npm package") This method is like `_.find` except that it returns the index of the first element `predicate` returns truthy for, instead of the element itself. @@ -632,7 +637,9 @@ var users = [ { 'user': 'pebbles', 'active': true } ]; -_.findIndex(users, function(chr) { return chr.user == 'barney'; }); +_.findIndex(users, function(chr) { + return chr.user == 'barney'; +}); // => 0 // using the `_.matches` callback shorthand @@ -654,7 +661,7 @@ _.findIndex(users, 'active'); ### `_.findLastIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4564 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4602 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastindex "See the npm package") This method is like `_.findIndex` except that it iterates over elements of `collection` from right to left. @@ -689,11 +696,13 @@ var users = [ { 'user': 'pebbles', 'active': false } ]; -_.findLastIndex(users, function(chr) { return chr.user == 'pebbles'; }); +_.findLastIndex(users, function(chr) { + return chr.user == 'pebbles'; +}); // => 2 // using the `_.matches` callback shorthand -_.findLastIndex(users, { user': 'barney', 'active': true }); +_.findLastIndex(users, { 'user': 'barney', 'active': true }); // => 0 // using the `_.matchesProperty` callback shorthand @@ -711,7 +720,7 @@ _.findLastIndex(users, 'active'); ### `_.first(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4592 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4630 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.first "See the npm package") Gets the first element of `array`. @@ -736,7 +745,7 @@ _.first([]); ### `_.flatten(array, [isDeep])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4616 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4654 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatten "See the npm package") Flattens a nested array. If `isDeep` is `true` the array is recursively flattened, otherwise it is only flattened a single level. @@ -750,11 +759,11 @@ flattened, otherwise it is only flattened a single level. #### Example ```js -_.flatten([1, [2], [3, [[4]]]]); -// => [1, 2, 3, [[4]]]; +_.flatten([1, [2, 3, [4]]]); +// => [1, 2, 3, [4]]; // using `isDeep` -_.flatten([1, [2], [3, [[4]]]], true); +_.flatten([1, [2, 3, [4]]], true); // => [1, 2, 3, 4]; ``` * * * @@ -764,7 +773,7 @@ _.flatten([1, [2], [3, [[4]]]], true); ### `_.flattenDeep(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4637 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4675 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the npm package") Recursively flattens a nested array. @@ -776,7 +785,7 @@ Recursively flattens a nested array. #### Example ```js -_.flattenDeep([1, [2], [3, [[4]]]]); +_.flattenDeep([1, [2, 3, [4]]]); // => [1, 2, 3, 4]; ``` * * * @@ -786,7 +795,7 @@ _.flattenDeep([1, [2], [3, [[4]]]]); ### `_.indexOf(array, value, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4674 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4712 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexof "See the npm package") Gets the index at which the first occurrence of `value` is found in `array` using `SameValueZero` for equality comparisons. If `fromIndex` is negative, @@ -809,15 +818,15 @@ for more details. #### Example ```js -_.indexOf([1, 2, 3, 1, 2, 3], 2); +_.indexOf([1, 2, 1, 2], 2); // => 1 // using `fromIndex` -_.indexOf([1, 2, 3, 1, 2, 3], 2, 3); -// => 4 +_.indexOf([1, 2, 1, 2], 2, 2); +// => 3 // performing a binary search -_.indexOf([4, 4, 5, 5, 6, 6], 5, true); +_.indexOf([1, 1, 2, 2], 2, true); // => 2 ``` * * * @@ -827,7 +836,7 @@ _.indexOf([4, 4, 5, 5, 6, 6], 5, true); ### `_.initial(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4703 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4741 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm package") Gets all but the last element of `array`. @@ -849,7 +858,7 @@ _.initial([1, 2, 3]); ### `_.intersection([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4726 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4763 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersection "See the npm package") Creates an array of unique values in all provided arrays using `SameValueZero` for equality comparisons. @@ -868,8 +877,8 @@ for more details. #### Example ```js -_.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]); -// => [1, 2] +_.intersection([1, 2], [4, 2], [2, 1]); +// => [2] ``` * * * @@ -878,7 +887,7 @@ _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]); ### `_.last(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4781 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4818 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm package") Gets the last element of `array`. @@ -900,7 +909,7 @@ _.last([1, 2, 3]); ### `_.lastIndexOf(array, value, [fromIndex=array.length-1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4811 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4848 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lastindexof "See the npm package") This method is like `_.indexOf` except that it iterates over elements of `array` from right to left. @@ -915,15 +924,15 @@ This method is like `_.indexOf` except that it iterates over elements of #### Example ```js -_.lastIndexOf([1, 2, 3, 1, 2, 3], 2); -// => 4 +_.lastIndexOf([1, 2, 1, 2], 2); +// => 3 // using `fromIndex` -_.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); +_.lastIndexOf([1, 2, 1, 2], 2, 2); // => 1 // performing a binary search -_.lastIndexOf([4, 4, 5, 5, 6, 6], 5, true); +_.lastIndexOf([1, 1, 2, 2], 2, true); // => 3 ``` * * * @@ -933,7 +942,7 @@ _.lastIndexOf([4, 4, 5, 5, 6, 6], 5, true); ### `_.pull(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4858 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4896 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pull "See the npm package") Removes all provided values from `array` using `SameValueZero` for equality comparisons. @@ -957,6 +966,7 @@ for more details. #### Example ```js var array = [1, 2, 3, 1, 2, 3]; + _.pull(array, 2, 3); console.log(array); // => [1, 1] @@ -968,7 +978,7 @@ console.log(array); ### `_.pullAt(array, [indexes])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4903 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4941 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullat "See the npm package") Removes elements from `array` corresponding to the given indexes and returns an array of the removed elements. Indexes may be specified as an array of @@ -987,7 +997,7 @@ indexes or as individual arguments. #### Example ```js var array = [5, 10, 15, 20]; -var evens = _.pullAt(array, [1, 3]); +var evens = _.pullAt(array, 1, 3); console.log(array); // => [5, 15] @@ -1002,7 +1012,7 @@ console.log(evens); ### `_.remove(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4944 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L4984 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.remove "See the npm package") Removes all elements from `array` that `predicate` returns truthy for and returns an array of the removed elements. The predicate is bound to @@ -1036,7 +1046,9 @@ object, else `false`. #### Example ```js var array = [1, 2, 3, 4]; -var evens = _.remove(array, function(n) { return n % 2 == 0; }); +var evens = _.remove(array, function(n) { + return n % 2 == 0; +}); console.log(array); // => [1, 3] @@ -1051,7 +1063,7 @@ console.log(evens); ### `_.rest(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4975 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5015 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rest "See the npm package") Gets all but the first element of `array`. @@ -1073,7 +1085,7 @@ _.rest([1, 2, 3]); ### `_.slice(array, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L4993 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5033 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.slice "See the npm package") Creates a slice of `array` from `start` up to, but not including, `end`.
@@ -1096,7 +1108,7 @@ lists in IE < 9 and to ensure dense arrays are returned. ### `_.sortedIndex(array, value, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5053 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5093 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindex "See the npm package") Uses a binary search to determine the lowest index at which `value` should be inserted into `array` in order to maintain its sort order. If an iteratee @@ -1133,7 +1145,7 @@ into `array`. _.sortedIndex([30, 50], 40); // => 1 -_.sortedIndex([4, 4, 5, 5, 6, 6], 5); +_.sortedIndex([4, 4, 5, 5], 5); // => 2 var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; @@ -1155,7 +1167,7 @@ _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); ### `_.sortedLastIndex(array, value, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5080 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5120 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindex "See the npm package") This method is like `_.sortedIndex` except that it returns the highest index at which `value` should be inserted into `array` in order to @@ -1173,7 +1185,7 @@ into `array`. #### Example ```js -_.sortedLastIndex([4, 4, 5, 5, 6, 6], 5); +_.sortedLastIndex([4, 4, 5, 5], 5); // => 4 ``` * * * @@ -1183,7 +1195,7 @@ _.sortedLastIndex([4, 4, 5, 5, 6, 6], 5); ### `_.take(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5111 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5151 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.take "See the npm package") Creates a slice of `array` with `n` elements taken from the beginning. @@ -1215,7 +1227,7 @@ _.take([1, 2, 3], 0); ### `_.takeRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5146 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5186 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takeright "See the npm package") Creates a slice of `array` with `n` elements taken from the end. @@ -1247,7 +1259,7 @@ _.takeRight([1, 2, 3], 0); ### `_.takeRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5205 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5247 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takerightwhile "See the npm package") Creates a slice of `array` with elements taken from the end. Elements are taken until `predicate` returns falsey. The predicate is bound to `thisArg` @@ -1277,7 +1289,9 @@ object, else `false`. #### Example ```js -_.takeRightWhile([1, 2, 3], function(n) { return n > 1; }); +_.takeRightWhile([1, 2, 3], function(n) { + return n > 1; +}); // => [2, 3] var users = [ @@ -1305,7 +1319,7 @@ _.pluck(_.takeRightWhile(users, 'active'), 'user'); ### `_.takeWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5262 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5306 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takewhile "See the npm package") Creates a slice of `array` with elements taken from the beginning. Elements are taken until `predicate` returns falsey. The predicate is bound to @@ -1335,7 +1349,9 @@ object, else `false`. #### Example ```js -_.takeWhile([1, 2, 3], function(n) { return n < 3; }); +_.takeWhile([1, 2, 3], function(n) { + return n < 3; +}); // => [1, 2] var users = [ @@ -1363,7 +1379,7 @@ _.pluck(_.takeWhile(users, 'active'), 'user'); ### `_.union([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5292 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5336 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.union "See the npm package") Creates an array of unique values, in order, of the provided arrays using `SameValueZero` for equality comparisons. @@ -1382,8 +1398,8 @@ for more details. #### Example ```js -_.union([1, 2, 3], [5, 2, 1, 4], [2, 1]); -// => [1, 2, 3, 5, 4] +_.union([1, 2], [4, 2], [2, 1]); +// => [1, 2, 4] ``` * * * @@ -1392,7 +1408,7 @@ _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]); ### `_.uniq(array, [isSorted], [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5346 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5392 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniq "See the npm package") Creates a duplicate-value-free version of an array using `SameValueZero` for equality comparisons. Providing `true` for `isSorted` performs a faster @@ -1440,7 +1456,9 @@ _.uniq([1, 1, 2], true); // => [1, 2] // using an iteratee function -_.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); +_.uniq([1, 2.5, 1.5, 2], function(n) { + return this.floor(n); +}, Math); // => [1, 2.5] // using the `_.property` callback shorthand @@ -1454,7 +1472,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.unzip(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5384 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5429 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzip "See the npm package") This method is like `_.zip` except that it accepts an array of grouped elements and creates an array regrouping the elements to their pre-`_.zip` @@ -1481,7 +1499,7 @@ _.unzip(zipped); ### `_.without(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5415 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5460 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.without "See the npm package") Creates an array excluding all provided values using `SameValueZero` for equality comparisons. @@ -1501,8 +1519,8 @@ for more details. #### Example ```js -_.without([1, 2, 1, 0, 3, 1, 4], 0, 1); -// => [2, 3, 4] +_.without([1, 2, 1, 3], 1, 2); +// => [3] ``` * * * @@ -1511,7 +1529,7 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); ### `_.xor([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5437 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5479 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xor "See the npm package") Creates an array that is the symmetric difference of the provided arrays. See [Wikipedia](https://en.wikipedia.org/wiki/Symmetric_difference) for @@ -1525,11 +1543,8 @@ more details. #### Example ```js -_.xor([1, 2, 3], [5, 2, 1, 4]); -// => [3, 5, 4] - -_.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]); -// => [1, 4, 5] +_.xor([1, 2], [4, 2]); +// => [1, 4] ``` * * * @@ -1538,7 +1553,7 @@ _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]); ### `_.zip([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5467 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5509 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zip "See the npm package") 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 @@ -1562,7 +1577,7 @@ _.zip(['fred', 'barney'], [30, 40], [true, false]); ### `_.zipObject(props, [values=[]])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5494 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5536 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobject "See the npm package") Creates an object composed from arrays of property names and values. Provide either a single two dimensional array, e.g. `[[key1, value1], [key2, value2]]` @@ -1592,8 +1607,8 @@ _.zipObject(['fred', 'barney'], [30, 40]); -### `._(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L920 "View in source") [Ⓣ][1] +### `_(value)` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L938 "View in source") [Ⓣ][1] Creates a `lodash` object which wraps `value` to enable implicit chaining. Methods that operate on and return arrays, collections, and functions can @@ -1674,11 +1689,15 @@ otherwise an unwrapped value is returned. var wrapped = _([1, 2, 3]); // returns an unwrapped value -wrapped.reduce(function(sum, n) { return sum + n; }); +wrapped.reduce(function(sum, n) { + return sum + n; +}); // => 6 // returns a wrapped value -var squares = wrapped.map(function(n) { return n * n; }); +var squares = wrapped.map(function(n) { + return n * n; +}); _.isArray(squares); // => false @@ -1693,7 +1712,7 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5539 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5583 "View in source") [Ⓣ][1] Creates a `lodash` object that wraps `value` with explicit method chaining enabled. @@ -1714,7 +1733,9 @@ var users = [ var youngest = _.chain(users) .sortBy('age') - .map(function(chr) { return chr.user + ' is ' + chr.age; }) + .map(function(chr) { + return chr.user + ' is ' + chr.age; + }) .first() .value(); // => 'pebbles is 1' @@ -1726,7 +1747,7 @@ var youngest = _.chain(users) ### `_.tap(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5566 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5612 "View in source") [Ⓣ][1] This method invokes `interceptor` and returns `value`. The interceptor is bound to `thisArg` and invoked with one argument; (value). The purpose of @@ -1744,7 +1765,9 @@ on intermediate results within the chain. #### Example ```js _([1, 2, 3]) - .tap(function(array) { array.pop(); }) + .tap(function(array) { + array.pop(); + }) .reverse() .value(); // => [2, 1] @@ -1756,7 +1779,7 @@ _([1, 2, 3]) ### `_.thru(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5589 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5637 "View in source") [Ⓣ][1] This method is like `_.tap` except that it returns the result of `interceptor`. @@ -1772,7 +1795,9 @@ This method is like `_.tap` except that it returns the result of `interceptor`. ```js _([1, 2, 3]) .last() - .thru(function(value) { return [value]; }) + .thru(function(value) { + return [value]; + }) .value(); // => [3] ``` @@ -1783,7 +1808,7 @@ _([1, 2, 3]) ### `_.prototype.chain()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5618 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5666 "View in source") [Ⓣ][1] Enables explicit method chaining on the wrapper object. @@ -1815,7 +1840,7 @@ _(users).chain() ### `_.prototype.commit()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5647 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5695 "View in source") [Ⓣ][1] Executes the chained sequence and returns the wrapped result. @@ -1847,7 +1872,7 @@ console.log(array); ### `_.prototype.plant()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5674 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5722 "View in source") [Ⓣ][1] Creates a clone of the chained sequence planting `value` as the wrapped value. @@ -1877,7 +1902,7 @@ wrapper.value(); ### `_.prototype.reverse()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5712 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5760 "View in source") [Ⓣ][1] Reverses the wrapped array so the first element becomes the last, the second element becomes the second to last, and so on. @@ -1905,7 +1930,7 @@ console.log(array); ### `_.prototype.toString()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5737 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5785 "View in source") [Ⓣ][1] Produces the result of coercing the unwrapped value to a string. @@ -1924,7 +1949,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5754 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5802 "View in source") [Ⓣ][1] Executes the chained sequence to extract the unwrapped value. @@ -1949,7 +1974,7 @@ _([1, 2, 3]).value(); ### `_.at(collection, [props])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5780 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5828 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.at "See the npm package") Creates an array of elements corresponding to the given keys, or indexes, of `collection`. Keys may be specified as individual arguments or as arrays @@ -1964,8 +1989,8 @@ of keys. #### Example ```js -_.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); -// => ['a', 'c', 'e'] +_.at(['a', 'b', 'c'], [0, 2]); +// => ['a', 'c'] _.at(['fred', 'barney', 'pebbles'], 0, 2); // => ['fred', 'pebbles'] @@ -1977,7 +2002,7 @@ _.at(['fred', 'barney', 'pebbles'], 0, 2); ### `_.countBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5876 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5877 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.countby "See the npm package") Creates an object composed of keys generated from the results of running each element of `collection` through `iteratee`. The corresponding value @@ -2009,10 +2034,14 @@ object, else `false`. #### Example ```js -_.countBy([4.3, 6.1, 6.4], function(n) { return Math.floor(n); }); +_.countBy([4.3, 6.1, 6.4], function(n) { + return Math.floor(n); +}); // => { '4': 1, '6': 2 } -_.countBy([4.3, 6.1, 6.4], function(n) { return this.floor(n); }, Math); +_.countBy([4.3, 6.1, 6.4], function(n) { + return this.floor(n); +}, Math); // => { '4': 1, '6': 2 } _.countBy(['one', 'two', 'three'], 'length'); @@ -2025,7 +2054,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5928 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5929 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.every "See the npm package") Checks if `predicate` returns truthy for **all** elements of `collection`. The predicate is bound to `thisArg` and invoked with three arguments; @@ -2083,7 +2112,7 @@ _.every(users, 'active'); ### `_.filter(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5983 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L5986 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.filter "See the npm package") Iterates over elements of `collection`, returning an array of all elements `predicate` returns truthy for. The predicate is bound to `thisArg` and @@ -2113,8 +2142,10 @@ object, else `false`. #### Example ```js -var evens = _.filter([1, 2, 3, 4], function(n) { return n % 2 == 0; }); -// => [2, 4] +_.filter([4, 5, 6], function(n) { + return n % 2 == 0; +}); +// => [4, 6] var users = [ { 'user': 'barney', 'age': 36, 'active': true }, @@ -2140,7 +2171,7 @@ _.pluck(_.filter(users, 'active'), 'user'); ### `_.find(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6037 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6042 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.find "See the npm package") Iterates over elements of `collection`, returning the first element `predicate` returns truthy for. The predicate is bound to `thisArg` and @@ -2176,7 +2207,9 @@ var users = [ { 'user': 'pebbles', 'age': 1, 'active': true } ]; -_.result(_.find(users, function(chr) { return chr.age < 40; }), 'user'); +_.result(_.find(users, function(chr) { + return chr.age < 40; +}), 'user'); // => 'barney' // using the `_.matches` callback shorthand @@ -2198,7 +2231,7 @@ _.result(_.find(users, 'active'), 'user'); ### `_.findLast(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6063 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6070 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlast "See the npm package") This method is like `_.find` except that it iterates over elements of `collection` from right to left. @@ -2213,7 +2246,9 @@ This method is like `_.find` except that it iterates over elements of #### Example ```js -_.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; }); +_.findLast([1, 2, 3, 4], function(n) { + return n % 2 == 1; +}); // => 3 ``` * * * @@ -2223,7 +2258,7 @@ _.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; }); ### `_.findWhere(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6097 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6104 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findwhere "See the npm package") Performs a deep comparison between each element in `collection` and the source object, returning the first element that has equivalent property @@ -2262,7 +2297,7 @@ _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); ### `_.forEach(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6127 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6138 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreach "See the npm package") Iterates over elements of `collection` invoking `iteratee` for each element. The `iteratee` is bound to `thisArg` and invoked with three arguments; @@ -2284,10 +2319,14 @@ may be used for object iteration. #### Example ```js -_([1, 2, 3]).forEach(function(n) { console.log(n); }).value(); +_([1, 2]).forEach(function(n) { + console.log(n); +}).value(); // => logs each value from left to right and returns the array -_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); }); +_.forEach({ 'a': 1, 'b': 2 }, function(n, key) { + console.log(n, key); +}); // => logs each value-key pair and returns the object (iteration order is not guaranteed) ``` * * * @@ -2297,7 +2336,7 @@ _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, ### `_.forEachRight(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6150 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6163 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreachright "See the npm package") This method is like `_.forEach` except that it iterates over elements of `collection` from right to left. @@ -2312,7 +2351,9 @@ This method is like `_.forEach` except that it iterates over elements of #### Example ```js -_([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); +_([1, 2]).forEachRight(function(n) { + console.log(n); +}).join(','); // => logs each value from right to left and returns the array ``` * * * @@ -2322,7 +2363,7 @@ _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); ### `_.groupBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6194 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6211 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.groupby "See the npm package") Creates an object composed of keys generated from the results of running each element of `collection` through `iteratee`. The corresponding value @@ -2354,10 +2395,14 @@ object, else `false`. #### Example ```js -_.groupBy([4.2, 6.1, 6.4], function(n) { return Math.floor(n); }); +_.groupBy([4.2, 6.1, 6.4], function(n) { + return Math.floor(n); +}); // => { '4': [4.2], '6': [6.1, 6.4] } -_.groupBy([4.2, 6.1, 6.4], function(n) { return this.floor(n); }, Math); +_.groupBy([4.2, 6.1, 6.4], function(n) { + return this.floor(n); +}, Math); // => { '4': [4.2], '6': [6.1, 6.4] } // using the `_.property` callback shorthand @@ -2371,7 +2416,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.includes(collection, target, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L5820 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6251 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.includes "See the npm package") Checks if `value` is in `collection` using `SameValueZero` for equality comparisons. If `fromIndex` is negative, it is used as the offset from @@ -2412,7 +2457,7 @@ _.includes('pebbles', 'eb'); ### `_.indexBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6244 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6316 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexby "See the npm package") Creates an object composed of keys generated from the results of running each element of `collection` through `iteratee`. The corresponding value @@ -2452,10 +2497,14 @@ var keyData = [ _.indexBy(keyData, 'dir'); // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } -_.indexBy(keyData, function(object) { return String.fromCharCode(object.code); }); +_.indexBy(keyData, function(object) { + return String.fromCharCode(object.code); +}); // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } -_.indexBy(keyData, function(object) { return this.fromCharCode(object.code); }, String); +_.indexBy(keyData, function(object) { + return this.fromCharCode(object.code); +}, String); // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } ``` * * * @@ -2465,7 +2514,7 @@ _.indexBy(keyData, function(object) { return this.fromCharCode(object.code); }, ### `_.invoke(collection, methodName, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6270 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6342 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invoke "See the npm package") Invokes the method named by `methodName` on each element in `collection`, returning an array of the results of each invoked method. Any additional @@ -2495,7 +2544,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6326 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6402 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.map "See the npm package") Creates an array of values by running each element in `collection` through `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three @@ -2536,11 +2585,15 @@ The guarded methods are:
#### Example ```js -_.map([1, 2, 3], function(n) { return n * 3; }); -// => [3, 6, 9] +function timesThree(n) { + return n * 3; +} -_.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; }); -// => [3, 6, 9] (iteration order is not guaranteed) +_.map([1, 2], timesThree); +// => [3, 6] + +_.map({ 'a': 1, 'b': 2 }, timesThree); +// => [3, 6] (iteration order is not guaranteed) var users = [ { 'user': 'barney' }, @@ -2558,7 +2611,7 @@ _.map(users, 'user'); ### `_.max(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6377 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6455 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.max "See the npm package") Gets the maximum value of `collection`. If `collection` is empty or falsey `-Infinity` is returned. If an iteratee function is provided it is invoked @@ -2601,7 +2654,9 @@ var users = [ { 'user': 'fred', 'age': 40 } ]; -_.max(users, function(chr) { return chr.age; }); +_.max(users, function(chr) { + return chr.age; +}); // => { 'user': 'fred', 'age': 40 }; // using the `_.property` callback shorthand @@ -2615,7 +2670,7 @@ _.max(users, 'age'); ### `_.min(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6424 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6504 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.min "See the npm package") Gets the minimum value of `collection`. If `collection` is empty or falsey `Infinity` is returned. If an iteratee function is provided it is invoked @@ -2658,7 +2713,9 @@ var users = [ { 'user': 'fred', 'age': 40 } ]; -_.min(users, function(chr) { return chr.age; }); +_.min(users, function(chr) { + return chr.age; +}); // => { 'user': 'barney', 'age': 36 }; // using the `_.property` callback shorthand @@ -2672,7 +2729,7 @@ _.min(users, 'age'); ### `_.partition(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6479 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6565 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partition "See the npm package") Creates an array of elements split into two groups, the first of which contains elements `predicate` returns truthy for, while the second of which @@ -2703,10 +2760,14 @@ object, else `false`. #### Example ```js -_.partition([1, 2, 3], function(n) { return n % 2; }); +_.partition([1, 2, 3], function(n) { + return n % 2; +}); // => [[1, 3], [2]] -_.partition([1.2, 2.3, 3.4], function(n) { return this.floor(n) % 2; }, Math); +_.partition([1.2, 2.3, 3.4], function(n) { + return this.floor(n) % 2; +}, Math); // => [[1, 3], [2]] var users = [ @@ -2715,7 +2776,9 @@ var users = [ { 'user': 'pebbles', 'age': 1, 'active': false } ]; -var mapper = function(array) { return _.pluck(array, 'user'); }; +var mapper = function(array) { + return _.pluck(array, 'user'); +}; // using the `_.matches` callback shorthand _.map(_.partition(users, { 'age': 1, 'active': false }), mapper); @@ -2736,7 +2799,7 @@ _.map(_.partition(users, 'active'), mapper); ### `_.pluck(collection, key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6506 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6592 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pluck "See the npm package") Gets the value of `key` from all elements in `collection`. @@ -2768,7 +2831,7 @@ _.pluck(userIndex, 'age'); ### `_.reduce(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6544 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6632 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduce "See the npm package") Reduces `collection` to a value which is the accumulated result of running each element in `collection` through `iteratee`, where each successive @@ -2796,14 +2859,16 @@ The guarded methods are:
#### Example ```js -var sum = _.reduce([1, 2, 3], function(sum, n) { return sum + n; }); -// => 6 +_.reduce([1, 2], function(sum, n) { + return sum + n; +}); +// => 3 -var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { +_.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { result[key] = n * 3; return result; }, {}); -// => { 'a': 3, 'b': 6, 'c': 9 } (iteration order is not guaranteed) +// => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) ``` * * * @@ -2812,7 +2877,7 @@ var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { ### `_.reduceRight(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6568 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6659 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduceright "See the npm package") This method is like `_.reduce` except that it iterates over elements of `collection` from right to left. @@ -2829,7 +2894,10 @@ This method is like `_.reduce` except that it iterates over elements of #### Example ```js var array = [[0, 1], [2, 3], [4, 5]]; -_.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []); + +_.reduceRight(array, function(flattened, other) { + return flattened.concat(other); +}, []); // => [4, 5, 2, 3, 0, 1] ``` * * * @@ -2839,7 +2907,7 @@ _.reduceRight(array, function(flattened, other) { return flattened.concat(other) ### `_.reject(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6618 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6711 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reject "See the npm package") The opposite of `_.filter`; this method returns the elements of `collection` that `predicate` does **not** return truthy for. @@ -2868,7 +2936,9 @@ object, else `false`. #### Example ```js -var odds = _.reject([1, 2, 3, 4], function(n) { return n % 2 == 0; }); +_.reject([1, 2, 3, 4], function(n) { + return n % 2 == 0; +}); // => [1, 3] var users = [ @@ -2895,7 +2965,7 @@ _.pluck(_.reject(users, 'active'), 'user'); ### `_.sample(collection, [n])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6644 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6737 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sample "See the npm package") Gets a random element or `n` random elements from a collection. @@ -2921,7 +2991,7 @@ _.sample([1, 2, 3, 4], 2); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6670 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6763 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.shuffle "See the npm package") Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle) @@ -2945,7 +3015,7 @@ _.shuffle([1, 2, 3, 4]); ### `_.size(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6707 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6800 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.size "See the npm package") Gets the size of `collection` by returning `collection.length` for array-like values or the number of own enumerable properties for objects. @@ -2958,12 +3028,12 @@ array-like values or the number of own enumerable properties for objects. #### Example ```js -_.size([1, 2]); -// => 2 - -_.size({ 'one': 1, 'two': 2, 'three': 3 }); +_.size([1, 2, 3]); // => 3 +_.size({ 'a': 1, 'b': 2 }); +// => 2 + _.size('pebbles'); // => 7 ``` @@ -2974,7 +3044,7 @@ _.size('pebbles'); ### `_.some(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6761 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6854 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.some "See the npm package") Checks if `predicate` returns truthy for **any** element of `collection`. The function returns as soon as it finds a passing value and does not iterate @@ -3015,7 +3085,7 @@ var users = [ ]; // using the `_.matches` callback shorthand -_.some(users, { user': 'barney', 'active': false }); +_.some(users, { 'user': 'barney', 'active': false }); // => false // using the `_.matchesProperty` callback shorthand @@ -3033,7 +3103,7 @@ _.some(users, 'active'); ### `_.sortBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6814 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6911 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortby "See the npm package") Creates an array of elements, sorted in ascending order by the results of running each element in a collection through `iteratee`. This method performs @@ -3065,10 +3135,14 @@ object, else `false`. #### Example ```js -_.sortBy([1, 2, 3], function(n) { return Math.sin(n); }); +_.sortBy([1, 2, 3], function(n) { + return Math.sin(n); +}); // => [3, 1, 2] -_.sortBy([1, 2, 3], function(n) { return this.sin(n); }, Math); +_.sortBy([1, 2, 3], function(n) { + return this.sin(n); +}, Math); // => [3, 1, 2] var users = [ @@ -3088,7 +3162,7 @@ _.pluck(_.sortBy(users, 'user'), 'user'); ### `_.sortByAll(collection, props)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6852 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L6949 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortbyall "See the npm package") This method is like `_.sortBy` except that it sorts by property names instead of an iteratee function. @@ -3119,7 +3193,7 @@ _.map(_.sortByAll(users, ['user', 'age']), _.values); ### `_.where(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6903 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7000 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.where "See the npm package") Performs a deep comparison between each element in `collection` and the source object, returning an array of all elements that have equivalent @@ -3164,14 +3238,16 @@ _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); ### `_.now` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6921 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7020 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.now "See the npm package") Gets the number of milliseconds that have elapsed since the Unix epoch (1 January 1970 00:00:00 UTC). #### Example ```js -_.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); +_.defer(function(stamp) { + console.log(_.now() - stamp); +}, _.now()); // => logs the number of milliseconds it took for the deferred function to be invoked ``` * * * @@ -3187,7 +3263,7 @@ _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); ### `_.after(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6950 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7049 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.after "See the npm package") The opposite of `_.before`; this method creates a function that invokes `func` once it is called `n` or more times. @@ -3219,7 +3295,7 @@ _.forEach(saves, function(type) { ### `_.ary(func, [n=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L6984 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7083 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ary "See the npm package") Creates a function that accepts up to `n` arguments ignoring any additional arguments. @@ -3243,7 +3319,7 @@ _.map(['6', '8', '10'], _.ary(parseInt, 1)); ### `_.before(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7008 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7107 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.before "See the npm package") Creates a function that invokes `func`, with the `this` binding and arguments of the created function, while it is called less than `n` times. Subsequent @@ -3268,7 +3344,7 @@ jQuery('#add').on('click', _.before(5, addContactToList)); ### `_.bind(func, thisArg, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7064 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7163 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bind "See the npm package") Creates a function that invokes `func` with the `this` binding of `thisArg` and prepends any additional `_.bind` arguments to those provided to the @@ -3314,7 +3390,7 @@ bound('hi'); ### `_.bindAll(object, [methodNames])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7202 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindall "See the npm package") Binds methods of an object to the object itself, overwriting the existing method. Method names may be specified as individual arguments or as arrays @@ -3335,7 +3411,9 @@ properties, own and inherited, of `object` are bound. ```js var view = { 'label': 'docs', - 'onClick': function() { console.log('clicked ' + this.label); } + 'onClick': function() { + console.log('clicked ' + this.label); + } }; _.bindAll(view); @@ -3349,7 +3427,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7153 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7254 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindkey "See the npm package") Creates a function that invokes the method at `object[key]` and prepends any additional `_.bindKey` arguments to those provided to the bound function. @@ -3404,7 +3482,7 @@ bound('hi'); ### `_.curry(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7204 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7305 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curry "See the npm package") Creates a function that accepts one or more arguments of `func` that when called either invokes `func` returning its result, if all `func` arguments @@ -3454,7 +3532,7 @@ curried(1)(_, 3)(2); ### `_.curryRight(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7250 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7351 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curryright "See the npm package") This method is like `_.curry` except that arguments are applied to `func` in the manner of `_.partialRight` instead of `_.partial`. @@ -3501,7 +3579,7 @@ curried(3)(1, _)(2); ### `_.debounce(func, wait, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7321 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7422 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.debounce "See the npm package") Creates a function that delays invoking `func` until after `wait` milliseconds have elapsed since the last time it was invoked. The created function comes @@ -3571,7 +3649,7 @@ delete models.todo; ### `_.defer(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7450 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7553 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defer "See the npm package") Defers invoking the `func` until the current call stack has cleared. Any additional arguments are provided to `func` when it is invoked. @@ -3585,7 +3663,9 @@ additional arguments are provided to `func` when it is invoked. #### Example ```js -_.defer(function(text) { console.log(text); }, 'deferred'); +_.defer(function(text) { + console.log(text); +}, 'deferred'); // logs 'deferred' after one or more milliseconds ``` * * * @@ -3595,7 +3675,7 @@ _.defer(function(text) { console.log(text); }, 'deferred'); ### `_.delay(func, wait, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7470 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7575 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.delay "See the npm package") Invokes `func` after `wait` milliseconds. Any additional arguments are provided to `func` when it is invoked. @@ -3610,7 +3690,9 @@ provided to `func` when it is invoked. #### Example ```js -_.delay(function(text) { console.log(text); }, 1000, 'later'); +_.delay(function(text) { + console.log(text); +}, 1000, 'later'); // => logs 'later' after one second ``` * * * @@ -3620,7 +3702,7 @@ _.delay(function(text) { console.log(text); }, 1000, 'later'); ### `_.flow([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7498 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7603 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flow "See the npm package") Creates a function that returns the result of invoking the provided functions with the `this` binding of the created function, where each @@ -3653,7 +3735,7 @@ addSquare(1, 2); ### `_.flowRight([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7543 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7648 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flowright "See the npm package") This method is like `_.flow` except that it creates a function that invokes the provided functions from right to left. @@ -3685,7 +3767,7 @@ addSquare(1, 2); ### `_.memoize(func, [resolver])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7617 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7722 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.memoize "See the npm package") Creates a function that memoizes the result of `func`. If `resolver` is provided it determines the cache key for storing the result based on the @@ -3748,7 +3830,7 @@ identity(other); ### `_.negate(predicate)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7655 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7760 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.negate "See the npm package") Creates a function that negates the result of the predicate `func`. The `func` predicate is invoked with the `this` binding and arguments of the @@ -3776,7 +3858,7 @@ _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); ### `_.once(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7681 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7786 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.once "See the npm package") Creates a function that is restricted to invoking `func` once. Repeat calls to the function return the value of the first call. The `func` is invoked @@ -3802,7 +3884,7 @@ initialize(); ### `_.partial(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7717 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7822 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partial "See the npm package") Creates a function that invokes `func` with `partial` arguments prepended to those provided to the new function. This method is like `_.bind` except @@ -3845,7 +3927,7 @@ greetFred('hi'); ### `_.partialRight(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7755 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7860 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partialright "See the npm package") This method is like `_.partial` except that partially applied arguments are appended to those provided to the new function. @@ -3887,7 +3969,7 @@ sayHelloTo('fred'); ### `_.rearg(func, indexes)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7788 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7895 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rearg "See the npm package") Creates a function that invokes `func` with arguments arranged according to the specified indexes where the argument value at the first index is @@ -3911,7 +3993,9 @@ rearged('b', 'c', 'a') // => ['a', 'b', 'c'] var map = _.rearg(_.map, [1, 0]); -map(function(n) { return n * 3; }, [1, 2, 3]); +map(function(n) { + return n * 3; +}, [1, 2, 3]); // => [3, 6, 9] ``` * * * @@ -3921,7 +4005,7 @@ map(function(n) { return n * 3; }, [1, 2, 3]); ### `_.spread(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7823 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7930 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.spread "See the npm package") Creates a function that invokes `func` with the `this` binding of the created function and the array of arguments provided to the created @@ -3960,7 +4044,7 @@ numbers.then(_.spread(function(x, y) { ### `_.throttle(func, wait, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7870 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L7978 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.throttle "See the npm package") Creates a function that only invokes `func` at most once per every `wait` milliseconds. The created function comes with a `cancel` method to cancel @@ -3994,8 +4078,9 @@ for details over the differences between `_.throttle` and `_.debounce`. jQuery(window).on('scroll', _.throttle(updatePosition, 100)); // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes -var throttled = _.throttle(renewToken, 300000, { 'trailing': false }) -jQuery('.interactive').on('click', throttled); +jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + 'trailing': false +})); // cancel a trailing throttled call jQuery(window).on('popstate', throttled.cancel); @@ -4007,7 +4092,7 @@ jQuery(window).on('popstate', throttled.cancel); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7910 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8018 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.wrap "See the npm package") Creates a function that provides `value` to the wrapper function as its first argument. Any additional arguments provided to the function are @@ -4043,7 +4128,7 @@ p('fred, barney, & pebbles'); ### `_.clone(value, [isDeep], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L7966 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8076 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clone "See the npm package") Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, otherwise they are assigned by reference. If `customizer` is provided it is @@ -4084,15 +4169,17 @@ deep[0] === users[0]; // => false // using a customizer callback -var body = _.clone(document.body, function(value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; +var el = _.clone(document.body, function(value) { + if (_.isElement(value)) { + return value.cloneNode(false); + } }); -body === document.body +el === document.body // => false -body.nodeName +el.nodeName // => BODY -body.childNodes.length; +el.childNodes.length; // => 0 ``` * * * @@ -4102,7 +4189,7 @@ body.childNodes.length; ### `_.cloneDeep(value, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8020 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8134 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeep "See the npm package") Creates a deep clone of `value`. If `customizer` is provided it is invoked to produce the cloned values. If `customizer` returns `undefined` cloning @@ -4138,14 +4225,16 @@ deep[0] === users[0]; // using a customizer callback var el = _.cloneDeep(document.body, function(value) { - return _.isElement(value) ? value.cloneNode(true) : undefined; + if (_.isElement(value)) { + return value.cloneNode(true); + } }); -body === document.body +el === document.body // => false -body.nodeName +el.nodeName // => BODY -body.childNodes.length; +el.childNodes.length; // => 20 ``` * * * @@ -4155,7 +4244,7 @@ body.childNodes.length; ### `_.isArguments(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8041 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8155 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the npm package") Checks if `value` is classified as an `arguments` object. @@ -4167,7 +4256,7 @@ Checks if `value` is classified as an `arguments` object. #### Example ```js -(function() { return _.isArguments(arguments); })(); +_.isArguments(function() { return arguments; }()); // => true _.isArguments([1, 2, 3]); @@ -4180,7 +4269,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8070 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8184 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm package") Checks if `value` is classified as an `Array` object. @@ -4195,7 +4284,7 @@ Checks if `value` is classified as an `Array` object. _.isArray([1, 2, 3]); // => true -(function() { return _.isArray(arguments); })(); +_.isArray(function() { return arguments; }()); // => false ``` * * * @@ -4205,7 +4294,7 @@ _.isArray([1, 2, 3]); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8204 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isboolean "See the npm package") Checks if `value` is classified as a boolean primitive or object. @@ -4230,7 +4319,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8110 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8224 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm package") Checks if `value` is classified as a `Date` object. @@ -4255,7 +4344,7 @@ _.isDate('Mon April 23 2012'); ### `_.isElement(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8130 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8244 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the npm package") Checks if `value` is a DOM element. @@ -4280,7 +4369,7 @@ _.isElement(''); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8168 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8282 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isempty "See the npm package") Checks if a value is empty. A value is considered empty unless it is an `arguments` object, array, string, or jQuery-like collection with a length @@ -4316,7 +4405,7 @@ _.isEmpty({ 'a': 1 }); ### `_.isEqual(value, other, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8221 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8337 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isequal "See the npm package") Performs a deep comparison between two values to determine if they are equivalent. If `customizer` is provided it is invoked to compare values. @@ -4356,7 +4445,9 @@ var array = ['hello', 'goodbye']; var other = ['hi', 'goodbye']; _.isEqual(array, other, function(value, other) { - return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; + if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) { + return true; + } }); // => true ``` @@ -4367,7 +4458,7 @@ _.isEqual(array, other, function(value, other) { ### `_.isError(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8247 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8363 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iserror "See the npm package") Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, `SyntaxError`, `TypeError`, or `URIError` object. @@ -4393,7 +4484,7 @@ _.isError(Error); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8280 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8396 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfinite "See the npm package") Checks if `value` is a finite primitive number.
@@ -4432,7 +4523,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8300 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8416 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the npm package") Checks if `value` is classified as a `Function` object. @@ -4457,7 +4548,7 @@ _.isFunction(/abc/); ### `_.isMatch(object, source, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8383 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8491 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatch "See the npm package") Performs a deep comparison between `object` and `source` to determine if `object` contains equivalent property values. If `customizer` is provided @@ -4506,7 +4597,7 @@ _.isMatch(object, source, function(value, other) { ### `_.isNaN(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8432 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8540 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm package") Checks if `value` is `NaN`.
@@ -4542,7 +4633,7 @@ _.isNaN(undefined); ### `_.isNative(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8454 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8562 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the npm package") Checks if `value` is a native function. @@ -4567,7 +4658,7 @@ _.isNative(_); ### `_.isNull(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8481 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8589 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm package") Checks if `value` is `null`. @@ -4592,7 +4683,7 @@ _.isNull(void 0); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8507 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8615 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnumber "See the npm package") Checks if `value` is classified as a `Number` primitive or object.
@@ -4624,7 +4715,7 @@ _.isNumber('8.4'); ### `_.isObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8337 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8445 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isobject "See the npm package") Checks if `value` is the language type of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) @@ -4656,7 +4747,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8541 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8649 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isplainobject "See the npm package") Checks if `value` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`. @@ -4696,7 +4787,7 @@ _.isPlainObject(Object.create(null)); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8569 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8677 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the npm package") Checks if `value` is classified as a `RegExp` object. @@ -4721,7 +4812,7 @@ _.isRegExp('/abc/'); ### `_.isString(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8589 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8697 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isstring "See the npm package") Checks if `value` is classified as a `String` primitive or object. @@ -4746,7 +4837,7 @@ _.isString(1); ### `_.isTypedArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8609 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8717 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See the npm package") Checks if `value` is classified as a typed array. @@ -4771,7 +4862,7 @@ _.isTypedArray([]); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8629 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8737 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the npm package") Checks if `value` is `undefined`. @@ -4796,7 +4887,7 @@ _.isUndefined(null); ### `_.toArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8646 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8756 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm package") Converts `value` to an array. @@ -4808,7 +4899,9 @@ Converts `value` to an array. #### Example ```js -(function() { return _.toArray(arguments).slice(1); })(1, 2, 3); +(function() { + return _.toArray(arguments).slice(1); +}(1, 2, 3)); // => [2, 3] ``` * * * @@ -4818,7 +4911,7 @@ Converts `value` to an array. ### `_.toPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8682 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8792 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toplainobject "See the npm package") Converts `value` to a plain object flattening inherited enumerable properties of `value` to own properties of the plain object. @@ -4855,8 +4948,48 @@ _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); +### `_.inRange(n, [start=0], end)` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9722 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.inrange "See the npm package") + +Checks if `n` is between `start` and up to but not including, `end`. If +`end` is not specified it defaults to `start` with `start` becoming `0`. + +#### Arguments +1. `n` *(number)*: The number to check. +2. `[start=0]` *(number)*: The start of the range. +3. `end` *(number)*: The end of the range. + +#### Returns +*(boolean)*: Returns `true` if `n` is in the range, else `false`. + +#### Example +```js +_.inRange(3, 2, 4); +// => true + +_.inRange(4, 8); +// => true + +_.inRange(4, 2); +// => false + +_.inRange(2, 2); +// => false + +_.inRange(1.2, 2); +// => true + +_.inRange(5.2, 4); +// => false +``` +* * * + + + + + ### `_.random([min=0], [max=1], [floating])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9586 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9760 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.random "See the npm package") Produces a random number between `min` and `max` (inclusive). If only one argument is provided a number between `0` and the given number is returned. @@ -4898,7 +5031,7 @@ _.random(1.2, 5.2); ### `_.assign(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8717 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8827 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assign "See the npm package") Assigns own enumerable properties of source object(s) to the destination object. Subsequent sources overwrite property assignments of previous sources. @@ -4935,7 +5068,7 @@ defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.create(prototype, [properties])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8751 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8863 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.create "See the npm package") Creates an object that inherits from the given `prototype` object. If a `properties` object is provided its own enumerable properties are assigned @@ -4959,7 +5092,9 @@ function Circle() { Shape.call(this); } -Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle }); +Circle.prototype = _.create(Shape.prototype, { + 'constructor': Circle +}); var circle = new Circle; circle instanceof Circle; @@ -4975,7 +5110,7 @@ circle instanceof Shape; ### `_.defaults(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8775 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8887 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaults "See the npm package") Assigns own enumerable properties of source object(s) to the destination object for all destination properties that resolve to `undefined`. Once a @@ -5000,7 +5135,7 @@ _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.findKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8830 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8944 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findkey "See the npm package") This method is like `_.findIndex` except that it returns the key of the first element `predicate` returns truthy for, instead of the element itself. @@ -5035,7 +5170,9 @@ var users = { 'pebbles': { 'age': 1, 'active': true } }; -_.findKey(users, function(chr) { return chr.age < 40; }); +_.findKey(users, function(chr) { + return chr.age < 40; +}); // => 'barney' (iteration order is not guaranteed) // using the `_.matches` callback shorthand @@ -5057,7 +5194,7 @@ _.findKey(users, 'active'); ### `_.findLastKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8881 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L8997 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastkey "See the npm package") This method is like `_.findKey` except that it iterates over elements of a collection in the opposite order. @@ -5092,7 +5229,9 @@ var users = { 'pebbles': { 'age': 1, 'active': true } }; -_.findLastKey(users, function(chr) { return chr.age < 40; }); +_.findLastKey(users, function(chr) { + return chr.age < 40; +}); // => returns `pebbles` assuming `_.findKey` returns `barney` // using the `_.matches` callback shorthand @@ -5114,7 +5253,7 @@ _.findLastKey(users, 'active'); ### `_.forIn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8913 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9029 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forin "See the npm package") Iterates over own and inherited enumerable properties of an object invoking `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked @@ -5150,7 +5289,7 @@ _.forIn(new Foo, function(value, key) { ### `_.forInRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8945 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9061 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forinright "See the npm package") This method is like `_.forIn` except that it iterates over properties of `object` in the opposite order. @@ -5184,7 +5323,7 @@ _.forInRight(new Foo, function(value, key) { ### `_.forOwn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8970 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9093 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forown "See the npm package") Iterates over own enumerable properties of an object invoking `iteratee` for each property. The `iteratee` is bound to `thisArg` and invoked with @@ -5201,10 +5340,17 @@ early by explicitly returning `false`. #### Example ```js -_.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { +function Foo() { + this.a = 1; + this.b = 2; +} + +Foo.prototype.c = 3; + +_.forOwn(new Foo, function(value, key) { console.log(key); }); -// => logs '0', '1', and 'length' (iteration order is not guaranteed) +// => logs 'a' and 'b' (iteration order is not guaranteed) ``` * * * @@ -5213,7 +5359,7 @@ _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { ### `_.forOwnRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L8995 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9125 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forownright "See the npm package") This method is like `_.forOwn` except that it iterates over properties of `object` in the opposite order. @@ -5228,10 +5374,17 @@ This method is like `_.forOwn` except that it iterates over properties of #### Example ```js -_.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { +function Foo() { + this.a = 1; + this.b = 2; +} + +Foo.prototype.c = 3; + +_.forOwnRight(new Foo, function(value, key) { console.log(key); }); -// => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' +// => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b' ``` * * * @@ -5240,7 +5393,7 @@ _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9015 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9145 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functions "See the npm package") Creates an array of function property names from all enumerable properties, own and inherited, of `object`. @@ -5254,7 +5407,7 @@ own and inherited, of `object`. #### Example ```js _.functions(_); -// => ['all', 'any', 'bind', ...] +// => ['after', 'ary', 'assign', ...] ``` * * * @@ -5263,7 +5416,7 @@ _.functions(_); ### `_.has(object, key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9034 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9166 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.has "See the npm package") Checks if `key` exists as a direct property of `object` instead of an inherited property. @@ -5277,7 +5430,9 @@ inherited property. #### Example ```js -_.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); +var object = { 'a': 1, 'b': 2, 'c': 3 }; + +_.has(object, 'b'); // => true ``` * * * @@ -5287,7 +5442,7 @@ _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); ### `_.invert(object, [multiValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9063 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9193 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invert "See the npm package") Creates an object composed of the inverted keys and values of `object`. If `object` contains duplicate values, subsequent values overwrite property @@ -5302,16 +5457,14 @@ assignments of previous values unless `multiValue` is `true`. #### Example ```js -_.invert({ 'first': 'fred', 'second': 'barney' }); -// => { 'fred': 'first', 'barney': 'second' } +var object = { 'a': 1, 'b': 2, 'c': 1 }; -// without `multiValue` -_.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }); -// => { 'fred': 'third', 'barney': 'second' } +_.invert(object); +// => { '1': 'c', '2': 'b' } // with `multiValue` -_.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true); -// => { 'fred': ['first', 'third'], 'barney': ['second'] } +_.invert(object, true); +// => { '1': ['a', 'c'], '2': ['b'] } ``` * * * @@ -5320,7 +5473,7 @@ _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true); ### `_.keys(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9117 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9247 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keys "See the npm package") Creates an array of the own enumerable property names of `object`.
@@ -5357,7 +5510,7 @@ _.keys('hi'); ### `_.keysIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9151 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9281 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keysin "See the npm package") Creates an array of the own and inherited enumerable property names of `object`.
@@ -5389,7 +5542,7 @@ _.keysIn(new Foo); ### `_.mapValues(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9248 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9380 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapvalues "See the npm package") Creates an object with the same keys as `object` and values generated by running each own enumerable property of `object` through `iteratee`. The @@ -5420,8 +5573,10 @@ object, else `false`. #### Example ```js -_.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(n) { return n * 3; }); -// => { 'a': 3, 'b': 6, 'c': 9 } +_.mapValues({ 'a': 1, 'b': 2 }, function(n) { + return n * 3; +}); +// => { 'a': 3, 'b': 6 } var users = { 'fred': { 'user': 'fred', 'age': 40 }, @@ -5439,7 +5594,7 @@ _.mapValues(users, 'age'); ### `_.merge(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9304 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9438 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.merge "See the npm package") Recursively merges own enumerable properties of the source object(s), that don't resolve to `undefined` into the destination object. Subsequent sources @@ -5483,7 +5638,9 @@ var other = { }; _.merge(object, other, function(a, b) { - return _.isArray(a) ? a.concat(b) : undefined; + if (_.isArray(a)) { + return a.concat(b); + } }); // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } ``` @@ -5494,7 +5651,7 @@ _.merge(object, other, function(a, b) { ### `_.omit(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9334 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9468 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.omit "See the npm package") The opposite of `_.pick`; this method creates an object composed of the own and inherited enumerable properties of `object` that are not omitted. @@ -5529,7 +5686,7 @@ _.omit(object, _.isNumber); ### `_.pairs(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9362 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9496 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pairs "See the npm package") Creates a two dimensional array of the key-value pairs for `object`, e.g. `[[key1, value1], [key2, value2]]`. @@ -5552,7 +5709,7 @@ _.pairs({ 'barney': 36, 'fred': 40 }); ### `_.pick(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9401 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9535 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pick "See the npm package") Creates an object composed of the picked `object` properties. Property names may be specified as individual arguments or as arrays of property @@ -5585,7 +5742,7 @@ _.pick(object, _.isString); ### `_.result(object, key, [defaultValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9440 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9574 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.result "See the npm package") Resolves the value of property `key` on `object`. If the value of `key` is a function it is invoked with the `this` binding of `object` and its result @@ -5623,7 +5780,7 @@ _.result(object, 'status', _.constant('busy')); ### `_.transform(object, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9479 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9611 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.transform "See the npm package") An alternative to `_.reduce`; this method transforms `object` to a new `accumulator` object which is the result of running each of its own enumerable @@ -5643,18 +5800,16 @@ may exit iteration early by explicitly returning `false`. #### Example ```js -var squares = _.transform([1, 2, 3, 4, 5, 6], function(result, n) { - n *= n; - if (n % 2) { - return result.push(n) < 3; - } +_.transform([2, 3, 4], function(result, n) { + result.push(n *= n); + return n % 2 == 0; }); -// => [1, 9, 25] +// => [4, 9] -var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { +_.transform({ 'a': 1, 'b': 2 }, function(result, n, key) { result[key] = n * 3; }); -// => { 'a': 3, 'b': 6, 'c': 9 } +// => { 'a': 3, 'b': 6 } ``` * * * @@ -5663,7 +5818,7 @@ var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9526 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9658 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.values "See the npm package") Creates an array of the own enumerable property values of `object`.
@@ -5698,7 +5853,7 @@ _.values('hi'); ### `_.valuesIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9553 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9685 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.valuesin "See the npm package") Creates an array of the own and inherited enumerable property values of `object`. @@ -5737,7 +5892,7 @@ _.valuesIn(new Foo); ### `_.camelCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9643 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9817 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.camelcase "See the npm package") Converts `string` to camel case. See [Wikipedia](https://en.wikipedia.org/wiki/CamelCase) for more details. @@ -5766,7 +5921,7 @@ _.camelCase('__foo_bar__'); ### `_.capitalize([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9661 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9835 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.capitalize "See the npm package") Capitalizes the first character of `string`. @@ -5788,7 +5943,7 @@ _.capitalize('fred'); ### `_.deburr([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9681 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9855 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.deburr "See the npm package") Deburrs `string` by converting latin-1 supplementary letters to basic latin letters. See [Wikipedia](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) @@ -5812,7 +5967,7 @@ _.deburr('déjà vu'); ### `_.endsWith([string=''], [target], [position=string.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9707 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9881 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.endswith "See the npm package") Checks if `string` ends with the given target string. @@ -5842,7 +5997,7 @@ _.endsWith('abc', 'b', 2); ### `_.escape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9748 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9922 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escape "See the npm package") Converts the characters "&", "<", ">", '"', "'", and '`', in `string` to their corresponding HTML entities. @@ -5887,7 +6042,7 @@ _.escape('fred, barney, & pebbles'); ### `_.escapeRegExp([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9770 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9944 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escaperegexp "See the npm package") Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", "+", "(", ")", "[", "]", "{" and "}" in `string`. @@ -5910,9 +6065,9 @@ _.escapeRegExp('[lodash](https://lodash.com/)'); ### `_.kebabCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9798 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9972 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.kebabcase "See the npm package") -Converts `string` to kebab case (a.k.a. spinal case). +Converts `string` to kebab case. See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for more details. @@ -5940,7 +6095,7 @@ _.kebabCase('__foo_bar__'); ### `_.pad([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9825 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L9999 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pad "See the npm package") Pads `string` on the left and right sides if it is shorter then the given padding length. The `chars` string may be truncated if the number of padding @@ -5972,7 +6127,7 @@ _.pad('abc', 3); ### `_.padLeft([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9864 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10038 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padleft "See the npm package") Pads `string` on the left side if it is shorter then the given padding length. The `chars` string may be truncated if the number of padding @@ -6004,7 +6159,7 @@ _.padLeft('abc', 3); ### `_.padRight([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9892 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10066 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padright "See the npm package") Pads `string` on the right side if it is shorter then the given padding length. The `chars` string may be truncated if the number of padding @@ -6036,7 +6191,7 @@ _.padRight('abc', 3); ### `_.parseInt(string, [radix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9920 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10094 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.parseint "See the npm package") Converts `string` to an integer of the specified radix. If `radix` is `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal, @@ -6068,7 +6223,7 @@ _.map(['6', '08', '10'], _.parseInt); ### `_.repeat([string=''], [n=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L9962 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10136 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.repeat "See the npm package") Repeats the given string `n` times. @@ -6097,7 +6252,7 @@ _.repeat('abc', 0); ### `_.snakeCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10002 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10176 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.snakecase "See the npm package") Converts `string` to snake case. See [Wikipedia](https://en.wikipedia.org/wiki/Snake_case) for more details. @@ -6126,7 +6281,7 @@ _.snakeCase('--foo-bar'); ### `_.startCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10027 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10201 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startcase "See the npm package") Converts `string` to start case. See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage) @@ -6156,7 +6311,7 @@ _.startCase('__foo_bar__'); ### `_.startsWith([string=''], [target], [position=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10052 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10226 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startswith "See the npm package") Checks if `string` starts with the given target string. @@ -6186,7 +6341,7 @@ _.startsWith('abc', 'b', 1); ### `_.template([string=''], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10154 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10328 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.template "See the npm package") Creates a compiled template function that can interpolate data properties in "interpolate" delimiters, HTML-escape interpolated data properties in @@ -6273,10 +6428,10 @@ compiled(data); var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); compiled.source; // => function(data) { - var __t, __p = ''; - __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; - return __p; -} +// var __t, __p = ''; +// __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; +// return __p; +// } // using the `source` property to inline compiled templates for meaningful // line numbers in error messages and a stack trace @@ -6293,7 +6448,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.trim([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10281 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10455 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trim "See the npm package") Removes leading and trailing whitespace or specified characters from `string`. @@ -6322,7 +6477,7 @@ _.map([' foo ', ' bar '], _.trim); ### `_.trimLeft([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10312 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10486 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimleft "See the npm package") Removes leading whitespace or specified characters from `string`. @@ -6348,7 +6503,7 @@ _.trimLeft('-_-abc-_-', '_-'); ### `_.trimRight([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10342 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10516 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimright "See the npm package") Removes trailing whitespace or specified characters from `string`. @@ -6374,7 +6529,7 @@ _.trimRight('-_-abc-_-', '_-'); ### `_.trunc([string=''], [options], [options.length=30], [options.omission='...'], [options.separator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10386 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10568 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trunc "See the npm package") Truncates `string` if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the omission @@ -6398,13 +6553,21 @@ _.trunc('hi-diddly-ho there, neighborino'); _.trunc('hi-diddly-ho there, neighborino', 24); // => 'hi-diddly-ho there, n...' -_.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); +_.trunc('hi-diddly-ho there, neighborino', { + 'length': 24, + 'separator': ' ' +}); // => 'hi-diddly-ho there,...' -_.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); +_.trunc('hi-diddly-ho there, neighborino', { + 'length': 24, + 'separator': /,? +/ +}); //=> 'hi-diddly-ho there...' -_.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); +_.trunc('hi-diddly-ho there, neighborino', { + 'omission': ' [...]' +}); // => 'hi-diddly-ho there, neig [...]' ``` * * * @@ -6414,7 +6577,7 @@ _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); ### `_.unescape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10456 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10638 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unescape "See the npm package") The inverse of `_.escape`; this method converts the HTML entities `&`, `<`, `>`, `"`, `'`, and ``` in `string` to their @@ -6442,7 +6605,7 @@ _.unescape('fred, barney, & pebbles'); ### `_.words([string=''], [pattern])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10481 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10663 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.words "See the npm package") Splits `string` into an array of its words. @@ -6474,7 +6637,7 @@ _.words('fred, barney, & pebbles', /[^, ]+/g); ### `_.attempt(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10511 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10693 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.attempt "See the npm package") Attempts to invoke `func`, returning either the result or the caught error object. Any additional arguments are provided to `func` when it is invoked. @@ -6503,7 +6666,7 @@ if (_.isError(elements)) { ### `_.callback([func=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10555 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10746 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.callback "See the npm package") Creates a function that invokes `func` with the `this` binding of `thisArg` and arguments of the created function. If `func` is a property name the @@ -6532,7 +6695,9 @@ _.callback = _.wrap(_.callback, function(callback, func, thisArg) { return callback(func, thisArg); } return function(object) { - return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3]; + return match[2] == 'gt' + ? object[match[1]] > match[3] + : object[match[1]] < match[3]; }; }); @@ -6546,7 +6711,7 @@ _.filter(users, 'age__gt36'); ### `_.constant(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10579 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10771 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.constant "See the npm package") Creates a function that returns `value`. @@ -6560,6 +6725,7 @@ Creates a function that returns `value`. ```js var object = { 'user': 'fred' }; var getter = _.constant(object); + getter() === object; // => true ``` @@ -6570,7 +6736,7 @@ getter() === object; ### `_.identity(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10599 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10792 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.identity "See the npm package") This method returns the first argument provided to it. @@ -6583,6 +6749,7 @@ This method returns the first argument provided to it. #### Example ```js var object = { 'user': 'fred' }; + _.identity(object) === object; // => true ``` @@ -6593,7 +6760,7 @@ _.identity(object) === object; ### `_.matches(source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10628 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10821 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matches "See the npm package") Creates a function which performs a deep comparison between a given object and `source`, returning `true` if the given object has equivalent property @@ -6628,7 +6795,7 @@ _.filter(users, _.matches({ 'age': 40, 'active': false })); ### `_.matchesProperty(key, value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10657 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10850 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matchesproperty "See the npm package") Creates a function which compares the property value of `key` on a given object to `value`. @@ -6663,7 +6830,7 @@ _.find(users, _.matchesProperty('user', 'fred')); ### `_.mixin([object=this], source, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10697 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10890 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mixin "See the npm package") Adds all own enumerable function properties of a source object to the destination object. If `object` is a function then methods are added to @@ -6707,7 +6874,7 @@ _('fred').vowels(); ### `_.noConflict()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10760 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10953 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noconflict "See the npm package") Reverts the `_` variable to its previous value and returns a reference to the `lodash` function. @@ -6726,13 +6893,15 @@ var lodash = _.noConflict(); ### `_.noop()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10777 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10972 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noop "See the npm package") -A no-operation function. +A no-operation function which returns `undefined` regardless of the +arguments it receives. #### Example ```js var object = { 'user': 'fred' }; + _.noop(object) === undefined; // => true ``` @@ -6743,7 +6912,7 @@ _.noop(object) === undefined; ### `_.property(key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10804 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L10999 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.property "See the npm package") Creates a function which returns the property value of `key` on a given object. @@ -6775,7 +6944,7 @@ _.pluck(_.sortBy(users, getName), 'user'); ### `_.propertyOf(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10827 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L11022 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.propertyof "See the npm package") The inverse of `_.property`; this method creates a function which returns the property value of a given key on `object`. @@ -6788,11 +6957,11 @@ the property value of a given key on `object`. #### Example ```js -var object = { 'user': 'fred', 'age': 40, 'active': true }; -_.map(['active', 'user'], _.propertyOf(object)); -// => [true, 'fred'] - var object = { 'a': 3, 'b': 1, 'c': 2 }; + +_.map(['a', 'c'], _.propertyOf(object)); +// => [3, 2] + _.sortBy(['a', 'b', 'c'], _.propertyOf(object)); // => ['b', 'c', 'a'] ``` @@ -6803,11 +6972,12 @@ _.sortBy(['a', 'b', 'c'], _.propertyOf(object)); ### `_.range([start=0], end, [step=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10865 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L11061 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.range "See the npm package") Creates an array of numbers (positive and/or negative) progressing from -`start` up to, but not including, `end`. If `start` is less than `end` a -zero-length range is created unless a negative `step` is specified. +`start` up to, but not including, `end`. If `end` is not specified it +defaults to `start` with `start` becoming `0`. If `start` is less than +`end` a zero-length range is created unless a negative `step` is specified. #### Arguments 1. `[start=0]` *(number)*: The start of the range. @@ -6844,7 +7014,7 @@ _.range(0); ### `_.runInContext([context=root])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L689 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L703 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.runincontext "See the npm package") Create a new pristine `lodash` function using the given `context` object. @@ -6888,7 +7058,7 @@ var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; ### `_.times(n, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10914 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L11114 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.times "See the npm package") Invokes the iteratee function `n` times, returning an array of the results of each invocation. The `iteratee` is bound to `thisArg` and invoked with @@ -6907,10 +7077,14 @@ one argument; (index). var diceRolls = _.times(3, _.partial(_.random, 1, 6, false)); // => [3, 6, 4] -_.times(3, function(n) { mage.castSpell(n); }); +_.times(3, function(n) { + mage.castSpell(n); +}); // => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2` respectively -_.times(3, function(n) { this.cast(n); }, mage); +_.times(3, function(n) { + this.cast(n); +}, mage); // => also invokes `mage.castSpell(n)` three times ``` * * * @@ -6920,7 +7094,7 @@ _.times(3, function(n) { this.cast(n); }, mage); ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L10952 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L11152 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqueid "See the npm package") Generates a unique ID. If `prefix` is provided the ID is appended to it. @@ -6951,7 +7125,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1164 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1191 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -6968,7 +7142,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L11220 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L11423 "View in source") [Ⓣ][1] (string): The semantic version number. @@ -6979,7 +7153,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L953 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L980 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.support "See the npm package") (Object): An object environment feature flags. @@ -6990,7 +7164,7 @@ A reference to the `lodash` function. ### `_.support.argsTag` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L970 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L997 "View in source") [Ⓣ][1] (boolean): Detect if the `toStringTag` of `arguments` objects is resolvable (all but Firefox < 4, IE < 9). @@ -7002,7 +7176,7 @@ A reference to the `lodash` function. ### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L979 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1006 "View in source") [Ⓣ][1] (boolean): Detect if `name` or `message` properties of `Error.prototype` are enumerable by default (IE < 9, Safari < 5.1). @@ -7014,7 +7188,7 @@ enumerable by default (IE < 9, Safari < 5.1). ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L993 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1020 "View in source") [Ⓣ][1] (boolean): Detect if `prototype` properties are enumerable by default.
@@ -7031,7 +7205,7 @@ property to `true`. ### `_.support.funcDecomp` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1003 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1030 "View in source") [Ⓣ][1] (boolean): Detect if functions can be decompiled by `Function#toString` (all but Firefox OS certified apps, older Opera mobile browsers, and @@ -7044,7 +7218,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.funcNames` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1011 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1038 "View in source") [Ⓣ][1] (boolean): Detect if `Function#name` is supported (all but IE). @@ -7055,7 +7229,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.nodeTag` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1019 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1046 "View in source") [Ⓣ][1] (boolean): Detect if the `toStringTag` of DOM nodes is resolvable (all but IE < 9). @@ -7066,7 +7240,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1040 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1067 "View in source") [Ⓣ][1] (boolean): Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -7082,7 +7256,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.nonEnumStrings` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1028 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1055 "View in source") [Ⓣ][1] (boolean): Detect if string indexes are non-enumerable (IE < 9, RingoJS, Rhino, Narwhal). @@ -7094,7 +7268,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.ownLast` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1048 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1075 "View in source") [Ⓣ][1] (boolean): Detect if own properties are iterated after inherited properties (IE < 9). @@ -7105,7 +7279,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.spliceObjects` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1063 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1090 "View in source") [Ⓣ][1] (boolean): Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -7124,7 +7298,7 @@ is buggy regardless of mode in IE < 9. ### `_.support.unindexedChars` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1074 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1101 "View in source") [Ⓣ][1] (boolean): Detect lack of support for accessing string characters by index.
@@ -7139,7 +7313,7 @@ by index on string literals, not string objects. ### `_.templateSettings` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1116 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1143 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.templatesettings "See the npm package") (Object): By default, the template delimiters used by lodash are like those in embedded Ruby (ERB). Change the following template settings to use @@ -7152,7 +7326,7 @@ alternative delimiters. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1124 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1151 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to be HTML-escaped. @@ -7163,7 +7337,7 @@ alternative delimiters. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1132 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1159 "View in source") [Ⓣ][1] (RegExp): Used to detect code to be evaluated. @@ -7174,7 +7348,7 @@ alternative delimiters. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1156 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1183 "View in source") [Ⓣ][1] (Object): Used to import variables into the compiled template. @@ -7185,7 +7359,7 @@ alternative delimiters. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1140 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1167 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to inject. @@ -7196,7 +7370,7 @@ alternative delimiters. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.2.0/lodash.src.js#L1148 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.0/lodash.src.js#L1175 "View in source") [Ⓣ][1] (string): Used to reference the data object in the template text. diff --git a/lodash.js b/lodash.js index 7fb5e4c0e7..941668b11a 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * lodash 3.2.0 (Custom Build) + * lodash 3.3.0 (Custom Build) * Build: `lodash modern -o ./lodash.js` * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.7.0 @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '3.2.0'; + var VERSION = '3.3.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -326,6 +326,20 @@ return -1; } + /** + * The base implementation of `_.isFunction` without support for environments + * with incorrect `typeof` results. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + */ + function baseIsFunction(value) { + // Avoid a Chakra JIT bug in compatibility modes of IE 11. + // See https://github.com/jashkenas/underscore/issues/1621 for more details. + return typeof value == 'function' || false; + } + /** * The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer` * to define the sort order of `array` and replaces criteria objects with their @@ -850,11 +864,15 @@ * var wrapped = _([1, 2, 3]); * * // returns an unwrapped value - * wrapped.reduce(function(sum, n) { return sum + n; }); + * wrapped.reduce(function(sum, n) { + * return sum + n; + * }); * // => 6 * * // returns a wrapped value - * var squares = wrapped.map(function(n) { return n * n; }); + * var squares = wrapped.map(function(n) { + * return n * n; + * }); * * _.isArray(squares); * // => false @@ -874,6 +892,15 @@ return new LodashWrapper(value); } + /** + * The function whose prototype all chaining wrappers inherit from. + * + * @private + */ + function baseLodash() { + // No operation performed. + } + /** * The base constructor for creating `lodash` wrapper objects. * @@ -2362,8 +2389,10 @@ * @returns {Object} Returns the destination object. */ function baseMerge(object, source, customizer, stackA, stackB) { + if (!isObject(object)) { + return object; + } var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source)); - (isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) { if (isObjectLike(srcValue)) { stackA || (stackA = []); @@ -3647,7 +3676,8 @@ } else { prereq = type == 'string' && index in object; } - return prereq && object[index] === value; + var other = object[index]; + return prereq && (value === value ? value === other : other !== other); } /** @@ -4042,7 +4072,7 @@ * @returns {Array} Returns the new array of filtered values. * @example * - * _.difference([1, 2, 3], [5, 2, 10]); + * _.difference([1, 2, 3], [4, 2]); * // => [1, 3] */ function difference() { @@ -4155,7 +4185,9 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.dropRightWhile([1, 2, 3], function(n) { return n > 1; }); + * _.dropRightWhile([1, 2, 3], function(n) { + * return n > 1; + * }); * // => [1] * * var users = [ @@ -4212,7 +4244,9 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.dropWhile([1, 2, 3], function(n) { return n < 3; }); + * _.dropWhile([1, 2, 3], function(n) { + * return n < 3; + * }); * // => [3] * * var users = [ @@ -4302,7 +4336,9 @@ * { 'user': 'pebbles', 'active': true } * ]; * - * _.findIndex(users, function(chr) { return chr.user == 'barney'; }); + * _.findIndex(users, function(chr) { + * return chr.user == 'barney'; + * }); * // => 0 * * // using the `_.matches` callback shorthand @@ -4361,7 +4397,9 @@ * { 'user': 'pebbles', 'active': false } * ]; * - * _.findLastIndex(users, function(chr) { return chr.user == 'pebbles'; }); + * _.findLastIndex(users, function(chr) { + * return chr.user == 'pebbles'; + * }); * // => 2 * * // using the `_.matches` callback shorthand @@ -4421,11 +4459,11 @@ * @returns {Array} Returns the new flattened array. * @example * - * _.flatten([1, [2], [3, [[4]]]]); - * // => [1, 2, 3, [[4]]]; + * _.flatten([1, [2, 3, [4]]]); + * // => [1, 2, 3, [4]]; * * // using `isDeep` - * _.flatten([1, [2], [3, [[4]]]], true); + * _.flatten([1, [2, 3, [4]]], true); * // => [1, 2, 3, 4]; */ function flatten(array, isDeep, guard) { @@ -4446,7 +4484,7 @@ * @returns {Array} Returns the new flattened array. * @example * - * _.flattenDeep([1, [2], [3, [[4]]]]); + * _.flattenDeep([1, [2, 3, [4]]]); * // => [1, 2, 3, 4]; */ function flattenDeep(array) { @@ -4475,15 +4513,15 @@ * @returns {number} Returns the index of the matched value, else `-1`. * @example * - * _.indexOf([1, 2, 3, 1, 2, 3], 2); - * // => 1 + * _.indexOf([1, 2, 1, 2], 2); + * // => 2 * * // using `fromIndex` - * _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); - * // => 4 + * _.indexOf([1, 2, 1, 2], 2, 2); + * // => 3 * * // performing a binary search - * _.indexOf([4, 4, 5, 5, 6, 6], 5, true); + * _.indexOf([1, 1, 2, 2], 2, true); * // => 2 */ function indexOf(array, value, fromIndex) { @@ -4534,9 +4572,8 @@ * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of shared values. * @example - * - * _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]); - * // => [1, 2] + * _.intersection([1, 2], [4, 2], [2, 1]); + * // => [2] */ function intersection() { var args = [], @@ -4612,15 +4649,15 @@ * @returns {number} Returns the index of the matched value, else `-1`. * @example * - * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); - * // => 4 + * _.lastIndexOf([1, 2, 1, 2], 2); + * // => 3 * * // using `fromIndex` - * _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); + * _.lastIndexOf([1, 2, 1, 2], 2, 2); * // => 1 * * // performing a binary search - * _.lastIndexOf([4, 4, 5, 5, 6, 6], 5, true); + * _.lastIndexOf([1, 1, 2, 2], 2, true); * // => 3 */ function lastIndexOf(array, value, fromIndex) { @@ -4666,6 +4703,7 @@ * @example * * var array = [1, 2, 3, 1, 2, 3]; + * * _.pull(array, 2, 3); * console.log(array); * // => [1, 1] @@ -4707,7 +4745,7 @@ * @example * * var array = [5, 10, 15, 20]; - * var evens = _.pullAt(array, [1, 3]); + * var evens = _.pullAt(array, 1, 3); * * console.log(array); * // => [5, 15] @@ -4748,7 +4786,9 @@ * @example * * var array = [1, 2, 3, 4]; - * var evens = _.remove(array, function(n) { return n % 2 == 0; }); + * var evens = _.remove(array, function(n) { + * return n % 2 == 0; + * }); * * console.log(array); * // => [1, 3] @@ -4850,7 +4890,7 @@ * _.sortedIndex([30, 50], 40); * // => 1 * - * _.sortedIndex([4, 4, 5, 5, 6, 6], 5); + * _.sortedIndex([4, 4, 5, 5], 5); * // => 2 * * var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } }; @@ -4889,7 +4929,7 @@ * into `array`. * @example * - * _.sortedLastIndex([4, 4, 5, 5, 6, 6], 5); + * _.sortedLastIndex([4, 4, 5, 5], 5); * // => 4 */ function sortedLastIndex(array, value, iteratee, thisArg) { @@ -4996,7 +5036,9 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.takeRightWhile([1, 2, 3], function(n) { return n > 1; }); + * _.takeRightWhile([1, 2, 3], function(n) { + * return n > 1; + * }); * // => [2, 3] * * var users = [ @@ -5053,7 +5095,9 @@ * @returns {Array} Returns the slice of `array`. * @example * - * _.takeWhile([1, 2, 3], function(n) { return n < 3; }); + * _.takeWhile([1, 2, 3], function(n) { + * return n < 3; + * }); * // => [1, 2] * * var users = [ @@ -5101,8 +5145,8 @@ * @returns {Array} Returns the new array of combined values. * @example * - * _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]); - * // => [1, 2, 3, 5, 4] + * _.union([1, 2], [4, 2], [2, 1]); + * // => [1, 2, 4] */ function union() { return baseUniq(baseFlatten(arguments, false, true)); @@ -5151,7 +5195,9 @@ * // => [1, 2] * * // using an iteratee function - * _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math); + * _.uniq([1, 2.5, 1.5, 2], function(n) { + * return this.floor(n); + * }, Math); * // => [1, 2.5] * * // using the `_.property` callback shorthand @@ -5163,8 +5209,7 @@ if (!length) { return []; } - // Juggle arguments. - if (typeof isSorted != 'boolean' && isSorted != null) { + if (isSorted != null && typeof isSorted != 'boolean') { thisArg = iteratee; iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; isSorted = false; @@ -5224,8 +5269,8 @@ * @returns {Array} Returns the new array of filtered values. * @example * - * _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); - * // => [2, 3, 4] + * _.without([1, 2, 1, 3], 1, 2); + * // => [3] */ function without(array) { return baseDifference(array, baseSlice(arguments, 1)); @@ -5243,11 +5288,8 @@ * @returns {Array} Returns the new array of values. * @example * - * _.xor([1, 2, 3], [5, 2, 1, 4]); - * // => [3, 5, 4] - * - * _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]); - * // => [1, 4, 5] + * _.xor([1, 2], [4, 2]); + * // => [1, 4] */ function xor() { var index = -1, @@ -5346,7 +5388,9 @@ * * var youngest = _.chain(users) * .sortBy('age') - * .map(function(chr) { return chr.user + ' is ' + chr.age; }) + * .map(function(chr) { + * return chr.user + ' is ' + chr.age; + * }) * .first() * .value(); * // => 'pebbles is 1' @@ -5373,7 +5417,9 @@ * @example * * _([1, 2, 3]) - * .tap(function(array) { array.pop(); }) + * .tap(function(array) { + * array.pop(); + * }) * .reverse() * .value(); * // => [2, 1] @@ -5397,7 +5443,9 @@ * * _([1, 2, 3]) * .last() - * .thru(function(value) { return [value]; }) + * .thru(function(value) { + * return [value]; + * }) * .value(); * // => [3] */ @@ -5490,7 +5538,7 @@ var result, parent = this; - while (parent instanceof LodashWrapper) { + while (parent instanceof baseLodash) { var clone = wrapperClone(parent); if (result) { previous.__wrapped__ = clone; @@ -5586,8 +5634,8 @@ * @returns {Array} Returns the new array of picked elements. * @example * - * _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); - * // => ['a', 'c', 'e'] + * _.at(['a', 'b', 'c'], [0, 2]); + * // => ['a', 'c'] * * _.at(['fred', 'barney', 'pebbles'], 0, 2); * // => ['fred', 'pebbles'] @@ -5600,57 +5648,6 @@ return baseAt(collection, baseFlatten(arguments, false, false, 1)); } - /** - * Checks if `value` is in `collection` using `SameValueZero` for equality - * comparisons. If `fromIndex` is negative, it is used as the offset from - * the end of `collection`. - * - * **Note:** `SameValueZero` comparisons are like strict equality comparisons, - * e.g. `===`, except that `NaN` matches `NaN`. See the - * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) - * for more details. - * - * @static - * @memberOf _ - * @alias contains, include - * @category Collection - * @param {Array|Object|string} collection The collection to search. - * @param {*} target The value to search for. - * @param {number} [fromIndex=0] The index to search from. - * @returns {boolean} Returns `true` if a matching element is found, else `false`. - * @example - * - * _.includes([1, 2, 3], 1); - * // => true - * - * _.includes([1, 2, 3], 1, 2); - * // => false - * - * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); - * // => true - * - * _.includes('pebbles', 'eb'); - * // => true - */ - function includes(collection, target, fromIndex) { - var length = collection ? collection.length : 0; - if (!isLength(length)) { - collection = values(collection); - length = collection.length; - } - if (!length) { - return false; - } - if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); - } else { - fromIndex = 0; - } - return (typeof collection == 'string' || !isArray(collection) && isString(collection)) - ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1) - : (getIndexOf(collection, target, fromIndex) > -1); - } - /** * Creates an object composed of keys generated from the results of running * each element of `collection` through `iteratee`. The corresponding value @@ -5679,10 +5676,14 @@ * @returns {Object} Returns the composed aggregate object. * @example * - * _.countBy([4.3, 6.1, 6.4], function(n) { return Math.floor(n); }); + * _.countBy([4.3, 6.1, 6.4], function(n) { + * return Math.floor(n); + * }); * // => { '4': 1, '6': 2 } * - * _.countBy([4.3, 6.1, 6.4], function(n) { return this.floor(n); }, Math); + * _.countBy([4.3, 6.1, 6.4], function(n) { + * return this.floor(n); + * }, Math); * // => { '4': 1, '6': 2 } * * _.countBy(['one', 'two', 'three'], 'length'); @@ -5775,8 +5776,10 @@ * @returns {Array} Returns the new filtered array. * @example * - * var evens = _.filter([1, 2, 3, 4], function(n) { return n % 2 == 0; }); - * // => [2, 4] + * _.filter([4, 5, 6], function(n) { + * return n % 2 == 0; + * }); + * // => [4, 6] * * var users = [ * { 'user': 'barney', 'age': 36, 'active': true }, @@ -5834,7 +5837,9 @@ * { 'user': 'pebbles', 'age': 1, 'active': true } * ]; * - * _.result(_.find(users, function(chr) { return chr.age < 40; }), 'user'); + * _.result(_.find(users, function(chr) { + * return chr.age < 40; + * }), 'user'); * // => 'barney' * * // using the `_.matches` callback shorthand @@ -5872,7 +5877,9 @@ * @returns {*} Returns the matched element, else `undefined`. * @example * - * _.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; }); + * _.findLast([1, 2, 3, 4], function(n) { + * return n % 2 == 1; + * }); * // => 3 */ function findLast(collection, predicate, thisArg) { @@ -5933,10 +5940,14 @@ * @returns {Array|Object|string} Returns `collection`. * @example * - * _([1, 2, 3]).forEach(function(n) { console.log(n); }).value(); + * _([1, 2]).forEach(function(n) { + * console.log(n); + * }).value(); * // => logs each value from left to right and returns the array * - * _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); }); + * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { + * console.log(n, key); + * }); * // => logs each value-key pair and returns the object (iteration order is not guaranteed) */ function forEach(collection, iteratee, thisArg) { @@ -5959,7 +5970,9 @@ * @returns {Array|Object|string} Returns `collection`. * @example * - * _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(','); + * _([1, 2]).forEachRight(function(n) { + * console.log(n); + * }).join(','); * // => logs each value from right to left and returns the array */ function forEachRight(collection, iteratee, thisArg) { @@ -5996,10 +6009,14 @@ * @returns {Object} Returns the composed aggregate object. * @example * - * _.groupBy([4.2, 6.1, 6.4], function(n) { return Math.floor(n); }); + * _.groupBy([4.2, 6.1, 6.4], function(n) { + * return Math.floor(n); + * }); * // => { '4': [4.2], '6': [6.1, 6.4] } * - * _.groupBy([4.2, 6.1, 6.4], function(n) { return this.floor(n); }, Math); + * _.groupBy([4.2, 6.1, 6.4], function(n) { + * return this.floor(n); + * }, Math); * // => { '4': [4.2], '6': [6.1, 6.4] } * * // using the `_.property` callback shorthand @@ -6014,6 +6031,57 @@ } }); + /** + * Checks if `value` is in `collection` using `SameValueZero` for equality + * comparisons. If `fromIndex` is negative, it is used as the offset from + * the end of `collection`. + * + * **Note:** `SameValueZero` comparisons are like strict equality comparisons, + * e.g. `===`, except that `NaN` matches `NaN`. See the + * [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) + * for more details. + * + * @static + * @memberOf _ + * @alias contains, include + * @category Collection + * @param {Array|Object|string} collection The collection to search. + * @param {*} target The value to search for. + * @param {number} [fromIndex=0] The index to search from. + * @returns {boolean} Returns `true` if a matching element is found, else `false`. + * @example + * + * _.includes([1, 2, 3], 1); + * // => true + * + * _.includes([1, 2, 3], 1, 2); + * // => false + * + * _.includes({ 'user': 'fred', 'age': 40 }, 'fred'); + * // => true + * + * _.includes('pebbles', 'eb'); + * // => true + */ + function includes(collection, target, fromIndex) { + var length = collection ? collection.length : 0; + if (!isLength(length)) { + collection = values(collection); + length = collection.length; + } + if (!length) { + return false; + } + if (typeof fromIndex == 'number') { + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); + } else { + fromIndex = 0; + } + return (typeof collection == 'string' || !isArray(collection) && isString(collection)) + ? (fromIndex < length && collection.indexOf(target, fromIndex) > -1) + : (getIndexOf(collection, target, fromIndex) > -1); + } + /** * Creates an object composed of keys generated from the results of running * each element of `collection` through `iteratee`. The corresponding value @@ -6050,10 +6118,14 @@ * _.indexBy(keyData, 'dir'); * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } * - * _.indexBy(keyData, function(object) { return String.fromCharCode(object.code); }); + * _.indexBy(keyData, function(object) { + * return String.fromCharCode(object.code); + * }); * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } * - * _.indexBy(keyData, function(object) { return this.fromCharCode(object.code); }, String); + * _.indexBy(keyData, function(object) { + * return this.fromCharCode(object.code); + * }, String); * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } */ var indexBy = createAggregator(function(result, value, key) { @@ -6123,11 +6195,15 @@ * @returns {Array} Returns the new mapped array. * @example * - * _.map([1, 2, 3], function(n) { return n * 3; }); - * // => [3, 6, 9] + * function timesThree(n) { + * return n * 3; + * } + * + * _.map([1, 2], timesThree); + * // => [3, 6] * - * _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; }); - * // => [3, 6, 9] (iteration order is not guaranteed) + * _.map({ 'a': 1, 'b': 2 }, timesThree); + * // => [3, 6] (iteration order is not guaranteed) * * var users = [ * { 'user': 'barney' }, @@ -6182,7 +6258,9 @@ * { 'user': 'fred', 'age': 40 } * ]; * - * _.max(users, function(chr) { return chr.age; }); + * _.max(users, function(chr) { + * return chr.age; + * }); * // => { 'user': 'fred', 'age': 40 }; * * // using the `_.property` callback shorthand @@ -6229,7 +6307,9 @@ * { 'user': 'fred', 'age': 40 } * ]; * - * _.min(users, function(chr) { return chr.age; }); + * _.min(users, function(chr) { + * return chr.age; + * }); * // => { 'user': 'barney', 'age': 36 }; * * // using the `_.property` callback shorthand @@ -6265,10 +6345,14 @@ * @returns {Array} Returns the array of grouped elements. * @example * - * _.partition([1, 2, 3], function(n) { return n % 2; }); + * _.partition([1, 2, 3], function(n) { + * return n % 2; + * }); * // => [[1, 3], [2]] * - * _.partition([1.2, 2.3, 3.4], function(n) { return this.floor(n) % 2; }, Math); + * _.partition([1.2, 2.3, 3.4], function(n) { + * return this.floor(n) % 2; + * }, Math); * // => [[1, 3], [2]] * * var users = [ @@ -6277,7 +6361,9 @@ * { 'user': 'pebbles', 'age': 1, 'active': false } * ]; * - * var mapper = function(array) { return _.pluck(array, 'user'); }; + * var mapper = function(array) { + * return _.pluck(array, 'user'); + * }; * * // using the `_.matches` callback shorthand * _.map(_.partition(users, { 'age': 1, 'active': false }), mapper); @@ -6347,14 +6433,16 @@ * @returns {*} Returns the accumulated value. * @example * - * var sum = _.reduce([1, 2, 3], function(sum, n) { return sum + n; }); - * // => 6 + * _.reduce([1, 2], function(sum, n) { + * return sum + n; + * }); + * // => 3 * - * var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { * result[key] = n * 3; * return result; * }, {}); - * // => { 'a': 3, 'b': 6, 'c': 9 } (iteration order is not guaranteed) + * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed) */ function reduce(collection, iteratee, accumulator, thisArg) { var func = isArray(collection) ? arrayReduce : baseReduce; @@ -6377,7 +6465,10 @@ * @example * * var array = [[0, 1], [2, 3], [4, 5]]; - * _.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []); + * + * _.reduceRight(array, function(flattened, other) { + * return flattened.concat(other); + * }, []); * // => [4, 5, 2, 3, 0, 1] */ function reduceRight(collection, iteratee, accumulator, thisArg) { @@ -6410,7 +6501,9 @@ * @returns {Array} Returns the new filtered array. * @example * - * var odds = _.reject([1, 2, 3, 4], function(n) { return n % 2 == 0; }); + * _.reject([1, 2, 3, 4], function(n) { + * return n % 2 == 0; + * }); * // => [1, 3] * * var users = [ @@ -6510,12 +6603,12 @@ * @returns {number} Returns the size of `collection`. * @example * - * _.size([1, 2]); - * // => 2 - * - * _.size({ 'one': 1, 'two': 2, 'three': 3 }); + * _.size([1, 2, 3]); * // => 3 * + * _.size({ 'a': 1, 'b': 2 }); + * // => 2 + * * _.size('pebbles'); * // => 7 */ @@ -6562,7 +6655,7 @@ * ]; * * // using the `_.matches` callback shorthand - * _.some(users, { 'user': 'barney', 'active': false }); + * _.some(users, { user': 'barney', 'active': false }); * // => false * * // using the `_.matchesProperty` callback shorthand @@ -6610,10 +6703,14 @@ * @returns {Array} Returns the new sorted array. * @example * - * _.sortBy([1, 2, 3], function(n) { return Math.sin(n); }); + * _.sortBy([1, 2, 3], function(n) { + * return Math.sin(n); + * }); * // => [3, 1, 2] * - * _.sortBy([1, 2, 3], function(n) { return this.sin(n); }, Math); + * _.sortBy([1, 2, 3], function(n) { + * return this.sin(n); + * }, Math); * // => [3, 1, 2] * * var users = [ @@ -6730,7 +6827,9 @@ * @category Date * @example * - * _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now()); + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); * // => logs the number of milliseconds it took for the deferred function to be invoked */ var now = nativeNow || function() { @@ -6906,7 +7005,9 @@ * * var view = { * 'label': 'docs', - * 'onClick': function() { console.log('clicked ' + this.label); } + * 'onClick': function() { + * console.log('clicked ' + this.label); + * } * }; * * _.bindAll(view); @@ -7259,7 +7360,9 @@ * @returns {number} Returns the timer id. * @example * - * _.defer(function(text) { console.log(text); }, 'deferred'); + * _.defer(function(text) { + * console.log(text); + * }, 'deferred'); * // logs 'deferred' after one or more milliseconds */ function defer(func) { @@ -7279,7 +7382,9 @@ * @returns {number} Returns the timer id. * @example * - * _.delay(function(text) { console.log(text); }, 1000, 'later'); + * _.delay(function(text) { + * console.log(text); + * }, 1000, 'later'); * // => logs 'later' after one second */ function delay(func, wait) { @@ -7317,7 +7422,7 @@ if (!length) { return function() { return arguments[0]; }; } - if (!arrayEvery(funcs, isFunction)) { + if (!arrayEvery(funcs, baseIsFunction)) { throw new TypeError(FUNC_ERROR_TEXT); } return function() { @@ -7362,7 +7467,7 @@ if (fromIndex < 0) { return function() { return arguments[0]; }; } - if (!arrayEvery(funcs, isFunction)) { + if (!arrayEvery(funcs, baseIsFunction)) { throw new TypeError(FUNC_ERROR_TEXT); } return function() { @@ -7597,7 +7702,9 @@ * // => ['a', 'b', 'c'] * * var map = _.rearg(_.map, [1, 0]); - * map(function(n) { return n * 3; }, [1, 2, 3]); + * map(function(n) { + * return n * 3; + * }, [1, 2, 3]); * // => [3, 6, 9] */ function rearg(func) { @@ -7676,8 +7783,9 @@ * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); * * // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes - * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }) - * jQuery('.interactive').on('click', throttled); + * jQuery('.interactive').on('click', _.throttle(renewToken, 300000, { + * 'trailing': false + * })); * * // cancel a trailing throttled call * jQuery(window).on('popstate', throttled.cancel); @@ -7767,22 +7875,26 @@ * // => false * * // using a customizer callback - * var body = _.clone(document.body, function(value) { - * return _.isElement(value) ? value.cloneNode(false) : undefined; + * var el = _.clone(document.body, function(value) { + * if (_.isElement(value)) { + * return value.cloneNode(false); + * } * }); * - * body === document.body + * el === document.body * // => false - * body.nodeName + * el.nodeName * // => BODY - * body.childNodes.length; + * el.childNodes.length; * // => 0 */ function clone(value, isDeep, customizer, thisArg) { - // Juggle arguments. - if (typeof isDeep != 'boolean' && isDeep != null) { + if (isDeep && typeof isDeep != 'boolean' && isIterateeCall(value, isDeep, customizer)) { + isDeep = false; + } + else if (typeof isDeep == 'function') { thisArg = customizer; - customizer = isIterateeCall(value, isDeep, thisArg) ? null : isDeep; + customizer = isDeep; isDeep = false; } customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); @@ -7822,14 +7934,16 @@ * * // using a customizer callback * var el = _.cloneDeep(document.body, function(value) { - * return _.isElement(value) ? value.cloneNode(true) : undefined; + * if (_.isElement(value)) { + * return value.cloneNode(true); + * } * }); * - * body === document.body + * el === document.body * // => false - * body.nodeName + * el.nodeName * // => BODY - * body.childNodes.length; + * el.childNodes.length; * // => 20 */ function cloneDeep(value, customizer, thisArg) { @@ -7847,7 +7961,7 @@ * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. * @example * - * (function() { return _.isArguments(arguments); })(); + * _.isArguments(function() { return arguments; }()); * // => true * * _.isArguments([1, 2, 3]); @@ -7871,7 +7985,7 @@ * _.isArray([1, 2, 3]); * // => true * - * (function() { return _.isArray(arguments); })(); + * _.isArray(function() { return arguments; }()); * // => false */ var isArray = nativeIsArray || function(value) { @@ -8021,7 +8135,9 @@ * var other = ['hi', 'goodbye']; * * _.isEqual(array, other, function(value, other) { - * return _.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/) || undefined; + * if (_.every([value, other], RegExp.prototype.test, /^h(?:i|ello)$/)) { + * return true; + * } * }); * // => true */ @@ -8104,20 +8220,12 @@ * _.isFunction(/abc/); * // => false */ - function isFunction(value) { - // Avoid a Chakra JIT bug in compatibility modes of IE 11. - // See https://github.com/jashkenas/underscore/issues/1621 for more details. - return typeof value == 'function' || false; - } - // Fallback for environments that return incorrect `typeof` operator results. - if (isFunction(/x/) || (Uint8Array && !isFunction(Uint8Array))) { - isFunction = function(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in older versions of Chrome and Safari which return 'function' for regexes - // and Safari 8 equivalents which return 'object' for typed array constructors. - return objToString.call(value) == funcTag; - }; - } + var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in older versions of Chrome and Safari which return 'function' for regexes + // and Safari 8 equivalents which return 'object' for typed array constructors. + return objToString.call(value) == funcTag; + }; /** * Checks if `value` is the language type of `Object`. @@ -8446,7 +8554,9 @@ * @returns {Array} Returns the converted array. * @example * - * (function() { return _.toArray(arguments).slice(1); })(1, 2, 3); + * (function() { + * return _.toArray(arguments).slice(1); + * }(1, 2, 3)); * // => [2, 3] */ function toArray(value) { @@ -8543,7 +8653,9 @@ * Shape.call(this); * } * - * Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle }); + * Circle.prototype = _.create(Shape.prototype, { + * 'constructor': Circle + * }); * * var circle = new Circle; * circle instanceof Circle; @@ -8616,7 +8728,9 @@ * 'pebbles': { 'age': 1, 'active': true } * }; * - * _.findKey(users, function(chr) { return chr.age < 40; }); + * _.findKey(users, function(chr) { + * return chr.age < 40; + * }); * // => 'barney' (iteration order is not guaranteed) * * // using the `_.matches` callback shorthand @@ -8667,7 +8781,9 @@ * 'pebbles': { 'age': 1, 'active': true } * }; * - * _.findLastKey(users, function(chr) { return chr.age < 40; }); + * _.findLastKey(users, function(chr) { + * return chr.age < 40; + * }); * // => returns `pebbles` assuming `_.findKey` returns `barney` * * // using the `_.matches` callback shorthand @@ -8766,10 +8882,17 @@ * @returns {Object} Returns `object`. * @example * - * _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwn(new Foo, function(value, key) { * console.log(key); * }); - * // => logs '0', '1', and 'length' (iteration order is not guaranteed) + * // => logs 'a' and 'b' (iteration order is not guaranteed) */ function forOwn(object, iteratee, thisArg) { if (typeof iteratee != 'function' || typeof thisArg != 'undefined') { @@ -8791,10 +8914,17 @@ * @returns {Object} Returns `object`. * @example * - * _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(n, key) { + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.forOwnRight(new Foo, function(value, key) { * console.log(key); * }); - * // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length' + * // => logs 'b' and 'a' assuming `_.forOwn` logs 'a' and 'b' */ function forOwnRight(object, iteratee, thisArg) { iteratee = bindCallback(iteratee, thisArg, 3); @@ -8814,7 +8944,7 @@ * @example * * _.functions(_); - * // => ['all', 'any', 'bind', ...] + * // => ['after', 'ary', 'assign', ...] */ function functions(object) { return baseFunctions(object, keysIn(object)); @@ -8832,7 +8962,9 @@ * @returns {boolean} Returns `true` if `key` is a direct property, else `false`. * @example * - * _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); + * var object = { 'a': 1, 'b': 2, 'c': 3 }; + * + * _.has(object, 'b'); * // => true */ function has(object, key) { @@ -8853,16 +8985,14 @@ * @returns {Object} Returns the new inverted object. * @example * - * _.invert({ 'first': 'fred', 'second': 'barney' }); - * // => { 'fred': 'first', 'barney': 'second' } + * var object = { 'a': 1, 'b': 2, 'c': 1 }; * - * // without `multiValue` - * _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }); - * // => { 'fred': 'third', 'barney': 'second' } + * _.invert(object); + * // => { '1': 'c', '2': 'b' } * * // with `multiValue` - * _.invert({ 'first': 'fred', 'second': 'barney', 'third': 'fred' }, true); - * // => { 'fred': ['first', 'third'], 'barney': ['second'] } + * _.invert(object, true); + * // => { '1': ['a', 'c'], '2': ['b'] } */ function invert(object, multiValue, guard) { if (guard && isIterateeCall(object, multiValue, guard)) { @@ -9008,8 +9138,10 @@ * @returns {Object} Returns the new mapped object. * @example * - * _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(n) { return n * 3; }); - * // => { 'a': 3, 'b': 6, 'c': 9 } + * _.mapValues({ 'a': 1, 'b': 2 }, function(n) { + * return n * 3; + * }); + * // => { 'a': 3, 'b': 6 } * * var users = { * 'fred': { 'user': 'fred', 'age': 40 }, @@ -9072,7 +9204,9 @@ * }; * * _.merge(object, other, function(a, b) { - * return _.isArray(a) ? a.concat(b) : undefined; + * if (_.isArray(a)) { + * return a.concat(b); + * } * }); * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } */ @@ -9238,18 +9372,16 @@ * @returns {*} Returns the accumulated value. * @example * - * var squares = _.transform([1, 2, 3, 4, 5, 6], function(result, n) { - * n *= n; - * if (n % 2) { - * return result.push(n) < 3; - * } + * _.transform([2, 3, 4], function(result, n) { + * result.push(n *= n); + * return n % 2 == 0; * }); - * // => [1, 9, 25] + * // => [4, 9] * - * var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) { + * _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) { * result[key] = n * 3; * }); - * // => { 'a': 3, 'b': 6, 'c': 9 } + * // => { 'a': 3, 'b': 6 } */ function transform(object, iteratee, accumulator, thisArg) { var isArr = isArray(object) || isTypedArray(object); @@ -9331,6 +9463,48 @@ /*------------------------------------------------------------------------*/ + /** + * Checks if `n` is between `start` and up to but not including, `end`. If + * `end` is not specified it defaults to `start` with `start` becoming `0`. + * + * @static + * @memberOf _ + * @category Number + * @param {number} n The number to check. + * @param {number} [start=0] The start of the range. + * @param {number} end The end of the range. + * @returns {boolean} Returns `true` if `n` is in the range, else `false`. + * @example + * + * _.inRange(3, 2, 4); + * // => true + * + * _.inRange(4, 8); + * // => true + * + * _.inRange(4, 2); + * // => false + * + * _.inRange(2, 2); + * // => false + * + * _.inRange(1.2, 2); + * // => true + * + * _.inRange(5.2, 4); + * // => false + */ + function inRange(value, start, end) { + start = +start || 0; + if (typeof end === 'undefined') { + end = start; + start = 0; + } else { + end = +end || 0; + } + return value >= start && value < end; + } + /** * Produces a random number between `min` and `max` (inclusive). If only one * argument is provided a number between `0` and the given number is returned. @@ -9550,7 +9724,7 @@ } /** - * Converts `string` to kebab case (a.k.a. spinal case). + * Converts `string` to kebab case. * See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for * more details. * @@ -10149,13 +10323,21 @@ * _.trunc('hi-diddly-ho there, neighborino', 24); * // => 'hi-diddly-ho there, n...' * - * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': ' ' }); + * _.trunc('hi-diddly-ho there, neighborino', { + * 'length': 24, + * 'separator': ' ' + * }); * // => 'hi-diddly-ho there,...' * - * _.trunc('hi-diddly-ho there, neighborino', { 'length': 24, 'separator': /,? +/ }); + * _.trunc('hi-diddly-ho there, neighborino', { + * 'length': 24, + * 'separator': /,? +/ + * }); * //=> 'hi-diddly-ho there...' * - * _.trunc('hi-diddly-ho there, neighborino', { 'omission': ' [...]' }); + * _.trunc('hi-diddly-ho there, neighborino', { + * 'omission': ' [...]' + * }); * // => 'hi-diddly-ho there, neig [...]' */ function trunc(string, options, guard) { @@ -10283,9 +10465,16 @@ * elements = []; * } */ - function attempt(func) { + function attempt() { + var length = arguments.length, + func = arguments[0]; + try { - return func.apply(undefined, baseSlice(arguments, 1)); + var args = Array(length ? length - 1 : 0); + while (--length > 0) { + args[length - 1] = arguments[length]; + } + return func.apply(undefined, args); } catch(e) { return isError(e) ? e : new Error(e); } @@ -10320,7 +10509,9 @@ * return callback(func, thisArg); * } * return function(object) { - * return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3]; + * return match[2] == 'gt' + * ? object[match[1]] > match[3] + * : object[match[1]] < match[3]; * }; * }); * @@ -10348,6 +10539,7 @@ * * var object = { 'user': 'fred' }; * var getter = _.constant(object); + * * getter() === object; * // => true */ @@ -10368,6 +10560,7 @@ * @example * * var object = { 'user': 'fred' }; + * * _.identity(object) === object; * // => true */ @@ -10538,7 +10731,8 @@ } /** - * A no-operation function. + * A no-operation function which returns `undefined` regardless of the + * arguments it receives. * * @static * @memberOf _ @@ -10546,6 +10740,7 @@ * @example * * var object = { 'user': 'fred' }; + * * _.noop(object) === undefined; * // => true */ @@ -10591,11 +10786,11 @@ * @returns {Function} Returns the new function. * @example * - * var object = { 'user': 'fred', 'age': 40, 'active': true }; - * _.map(['active', 'user'], _.propertyOf(object)); - * // => [true, 'fred'] - * * var object = { 'a': 3, 'b': 1, 'c': 2 }; + * + * _.map(['a', 'c'], _.propertyOf(object)); + * // => [3, 2] + * * _.sortBy(['a', 'b', 'c'], _.propertyOf(object)); * // => ['b', 'c', 'a'] */ @@ -10607,8 +10802,9 @@ /** * Creates an array of numbers (positive and/or negative) progressing from - * `start` up to, but not including, `end`. If `start` is less than `end` a - * zero-length range is created unless a negative `step` is specified. + * `start` up to, but not including, `end`. If `end` is not specified it + * defaults to `start` with `start` becoming `0`. If `start` is less than + * `end` a zero-length range is created unless a negative `step` is specified. * * @static * @memberOf _ @@ -10680,10 +10876,14 @@ * var diceRolls = _.times(3, _.partial(_.random, 1, 6, false)); * // => [3, 6, 4] * - * _.times(3, function(n) { mage.castSpell(n); }); + * _.times(3, function(n) { + * mage.castSpell(n); + * }); * // => invokes `mage.castSpell(n)` three times with `n` of `0`, `1`, and `2` respectively * - * _.times(3, function(n) { this.cast(n); }, mage); + * _.times(3, function(n) { + * this.cast(n); + * }, mage); * // => also invokes `mage.castSpell(n)` three times */ function times(n, iteratee, thisArg) { @@ -10731,11 +10931,13 @@ /*------------------------------------------------------------------------*/ - // Ensure `new LodashWrapper` is an instance of `lodash`. - LodashWrapper.prototype = baseCreate(lodash.prototype); + // Ensure wrappers are instances of `baseLodash`. + lodash.prototype = baseLodash.prototype; + + LodashWrapper.prototype = baseCreate(baseLodash.prototype); + LodashWrapper.prototype.constructor = LodashWrapper; - // Ensure `new LazyWraper` is an instance of `LodashWrapper` - LazyWrapper.prototype = baseCreate(LodashWrapper.prototype); + LazyWrapper.prototype = baseCreate(baseLodash.prototype); LazyWrapper.prototype.constructor = LazyWrapper; // Add functions to the `Map` cache. @@ -10893,6 +11095,7 @@ lodash.identity = identity; lodash.includes = includes; lodash.indexOf = indexOf; + lodash.inRange = inRange; lodash.isArguments = isArguments; lodash.isArray = isArray; lodash.isBoolean = isBoolean; @@ -11164,7 +11367,7 @@ LazyWrapper.prototype.reverse = lazyReverse; LazyWrapper.prototype.value = lazyValue; - // Add chaining functions to the lodash wrapper. + // Add chaining functions to the `lodash` wrapper. lodash.prototype.chain = wrapperChain; lodash.prototype.commit = wrapperCommit; lodash.prototype.plant = wrapperPlant; @@ -11172,7 +11375,7 @@ lodash.prototype.toString = wrapperToString; lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; - // Add function aliases to the lodash wrapper. + // Add function aliases to the `lodash` wrapper. lodash.prototype.collect = lodash.prototype.map; lodash.prototype.head = lodash.prototype.first; lodash.prototype.select = lodash.prototype.filter; diff --git a/lodash.min.js b/lodash.min.js index e29d33a988..8a9315fc55 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,88 +1,88 @@ /** * @license - * lodash 3.2.0 (Custom Build) lodash.com/license | Underscore.js 1.7.0 underscorejs.org/LICENSE + * lodash 3.3.0 (Custom Build) lodash.com/license | Underscore.js 1.7.0 underscorejs.org/LICENSE * Build: `lodash modern -o ./lodash.js` */ -;(function(){function n(n,t){if(n!==t){var r=n===n,e=t===t;if(n>t||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n) -}function g(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Yt(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++ui(r,a)&&u.push(a);return u}function or(n,t){var r=n?n.length:0;if(!oe(r))return _r(n,t);for(var e=-1,u=pe(n);++et&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=wu(u);++eu(a,s)&&((r||f)&&a.push(s),c.push(l))}return c}function Cr(n,t){for(var r=-1,e=t.length,u=wu(e);++r>>1,i=n[o];(r?i<=t:it||null==r)return r;if(3=o&&f<=i&&(e=O&&t>u||e>u&&t>=O)||o)&&(t&x&&(r[2]=p[2],f|=e&x?0:j),(e=p[3])&&(u=r[3],r[3]=u?Fr(u,e,p[4]):zt(e),r[4]=u?g(r[3],B):zt(p[4])),(e=p[5])&&(u=r[5],r[5]=u?Lr(u,e,p[6]):zt(e),r[6]=u?g(r[5],B):zt(p[6])),(e=p[7])&&(r[7]=zt(e)),t&C&&(r[8]=null==r[8]?p[8]:oo(r[8],p[8])),null==r[9]&&(r[9]=p[9]),r[0]=p[0],r[1]=f),t=r[1],f=r[9] -}return r[9]=null==f?a?0:n.length:uo(f-c,0)||0,(p?bo:jo)(t==x?zr(r[0],r[2]):t!=R&&t!=(x|R)||r[4].length?Pr.apply(w,r):Vr.apply(w,r),r)}function Zr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length,l=true;if(a!=c&&(!u||c<=a))return false;for(;l&&++fu)||i===e&&i===o)&&(u=i,o=n)}),o}function Hr(n,t,r){var e=Wt.callback||_u,e=e===_u?tr:e;return r?e(n,t,r):e}function Qr(n,r,e){var u=Wt.indexOf||de,u=u===de?t:u;return n?u(n,r,e):u}function ne(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&Uu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function te(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Eu),new n -}function re(n,t,r){var e=n.constructor;switch(t){case J:return Ur(n);case M:case q:return new e(+n);case X:case H:case Q:case nt:case tt:case rt:case et:case ut:case ot:return t=n.buffer,new e(r?Ur(t):t,n.byteOffset,n.length);case V:case G:return new e(n);case Z:var u=new e(n.source,yt.exec(n));u.lastIndex=n.lastIndex}return u}function ee(n,t){return n=+n,t=null==t?vo:t,-1t?0:t)):[]}function ge(n,t,r){var e=n?n.length:0; -return e?((r?ue(n,t,r):null==t)&&(t=1),t=e-(+t||0),Rr(n,0,0>t?0:t)):[]}function ve(n,t,r){var e=-1,u=n?n.length:0;for(t=Hr(t,r,3);++ee?uo(u+e,0):e||0;else if(e)return e=Sr(n,r),n=n[e],(r===r?r===n:n!==n)?e:-1;return t(n,r,e)}function me(n){return _e(n,1)}function we(n,r,e,u){if(!n||!n.length)return[];typeof r!="boolean"&&null!=r&&(u=e,e=ue(n,r,u)?null:r,r=false); -var o=Hr();if((o!==tr||null!=e)&&(e=o(e,u,3)),r&&Qr()==t){r=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e>>0,e=wu(r);++tr?uo(e+r,0):r||0:0,typeof n=="string"||!So(n)&&tu(n)?rarguments.length,or)}function We(n,t,r,e){return(So(n)?Zt:Er)(n,Hr(t,e,4),r,3>arguments.length,ir)}function Ne(n,t,r){return(r?ue(n,t,r):null==t)?(n=se(n),t=n.length,0t?0:+t||0,n.length),n)}function Ue(n){n=se(n); -for(var t=-1,r=n.length,e=wu(r);++t=r||r>t?(f&&qu(f),r=p,f=s=p=w,r&&(h=To(),a=n.apply(l,i),s||f||(i=l=null))):s=Gu(e,r)}function u(){s&&qu(s),f=s=p=w,(g||_!==t)&&(h=To(),a=n.apply(l,i),s||f||(i=l=null)) -}function o(){if(i=arguments,c=To(),l=this,p=g&&(s||!v),false===_)var r=v&&!s;else{f||v||(h=c);var o=_-(c-h),y=0>=o||o>_;y?(f&&(f=qu(f)),h=c,a=n.apply(l,i)):f||(f=Gu(u,o))}return y&&s?s=qu(s):s||t===_||(s=Gu(e,t)),r&&(y=true,a=n.apply(l,i)),!y||s||f||(i=l=null),a}var i,f,a,c,l,s,p,h=0,_=false,g=true;if(typeof n!="function")throw new Ou($);if(t=0>t?0:t,true===r)var v=true,g=false;else Xe(r)&&(v=r.leading,_="maxWait"in r&&uo(+r.maxWait||0,t),g="trailing"in r?r.trailing:g);return o.cancel=function(){s&&qu(s),f&&qu(f),f=s=p=w -},o}function qe(){var n=arguments,t=n.length-1;if(0>t)return function(n){return n};if(!qt(n,Je))throw new Ou($);return function(){for(var r=t,e=n[r].apply(this,arguments);r--;)e=n[r].call(this,e);return e}}function Pe(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(typeof n!="function"||t&&typeof t!="function")throw new Ou($);return r.cache=new Pe.Cache,r}function Ke(n){var t=Rr(arguments,1),r=g(t,Ke.placeholder); -return Yr(n,R,null,t,r)}function Ve(n){var t=Rr(arguments,1),r=g(t,Ve.placeholder);return Yr(n,I,null,t,r)}function Ye(n){return oe(h(n)?n.length:w)&&Lu.call(n)==z||false}function Ze(n){return n&&1===n.nodeType&&h(n)&&-1t||!n||!ro(t))return r;do t%2&&(r+=n),t=Pu(t/2),n+=n;while(t);return r}function su(n,t,r){var u=n;return(n=e(n))?(r?ue(u,t,r):null==t)?n.slice(v(n),y(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n -}function pu(n,t,r){return r&&ue(n,t,r)&&(t=null),n=e(n),n.match(t||Rt)||[]}function hu(n){try{return n.apply(w,Rr(arguments,1))}catch(t){return Ge(t)?t:new xu(t)}}function _u(n,t,r){return r&&ue(n,t,r)&&(t=null),h(n)?yu(n):tr(n,t)}function gu(n){return function(){return n}}function vu(n){return n}function yu(n){return br(rr(n,true))}function du(n,t,r){if(null==r){var e=Xe(t),u=e&&Fo(t);((u=u&&u.length&&vr(t,u))?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=vr(t,Fo(t)));var o=true,e=-1,i=Je(n),f=u.length; -!1===r?o=false:Xe(r)&&"chain"in r&&(o=r.chain);for(;++e>>1,go=Qu?Qu.BYTES_PER_ELEMENT:0,vo=ju.pow(2,53)-1,yo=Hu&&new Hu,mo=Wt.support={};!function(n){mo.funcDecomp=!He(_.WinRTError)&&kt.test(m),mo.funcNames=typeof Au.name=="string";try{mo.dom=11===Su.createDocumentFragment().nodeType -}catch(t){mo.dom=false}try{mo.nonEnumArgs=!Yu.call(arguments,1)}catch(r){mo.nonEnumArgs=true}}(0,0),Wt.templateSettings={escape:ht,evaluate:_t,interpolate:gt,variable:"",imports:{_:Wt}};var wo=function(){function n(){}return function(t){if(Xe(t)){n.prototype=t;var r=new n;n.prototype=null}return r||_.Object()}}(),bo=yo?function(n,t){return yo.set(n,t),n}:vu;Du||(Ur=zu&&Xu?function(n){var t=n.byteLength,r=Qu?Pu(t/go):0,e=r*go,u=new zu(t);if(r){var o=new Qu(u,0,r);o.set(new Qu(n,0,r))}return t!=e&&(o=new Xu(u,e),o.set(new Xu(n,e))),u -}:gu(null));var xo=to&&Zu?function(n){return new Lt(n)}:gu(null),Ao=yo?function(n){return yo.get(n)}:mu,jo=function(){var n=0,t=0;return function(r,e){var u=To(),o=N-(u-t);if(t=u,0=W)return r}else n=0;return bo(r,e)}}(),ko=$r(function(n,t,r){Uu.call(n,r)?++n[r]:n[r]=1}),Eo=$r(function(n,t,r){Uu.call(n,r)?n[r].push(t):n[r]=[t]}),Ro=$r(function(n,t,r){n[r]=t}),Io=qr(Vt),Oo=qr(function(n){for(var t=-1,r=n.length,e=so;++t--n?t.apply(this,arguments):void 0}},Wt.ary=function(n,t,r){return r&&ue(n,t,r)&&(t=null),t=n&&null==t?n.length:uo(+t||0,0),Yr(n,C,null,null,null,null,t)},Wt.assign=Uo,Wt.at=function(n){return oe(n?n.length:0)&&(n=se(n)),Qt(n,lr(arguments,false,false,1))},Wt.before=Le,Wt.bind=$e,Wt.bindAll=function(n){for(var t=n,r=1r&&(r=-r>u?0:u+r),e=typeof e=="undefined"||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r(s?Bt(s,f):o(l,f))){for(r=e;--r;){var p=u[r];if(0>(p?Bt(p,f):o(n[r],f)))continue n}s&&s.push(f),l.push(f)}return l},Wt.invert=function(n,t,r){r&&ue(n,t,r)&&(t=null),r=-1; -for(var e=Fo(n),u=e.length,o={};++rt?0:t)):[]},Wt.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?ue(n,t,r):null==t)&&(t=1),t=e-(+t||0),Rr(n,0>t?0:t)):[]},Wt.takeRightWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];for(t=Hr(t,r,3);e--&&t(n[e],e,n););return Rr(n,e+1)},Wt.takeWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];var u=-1;for(t=Hr(t,r,3);++un||!ro(n))return[];var e=-1,u=wu(oo(n,po));for(t=Nr(t,r,1);++er?0:+r||0,u))-t.length,0<=r&&n.indexOf(t,r)==r},Wt.escape=function(n){return(n=e(n))&&pt.test(n)?n.replace(lt,l):n},Wt.escapeRegExp=au,Wt.every=Ee,Wt.find=Ie,Wt.findIndex=ve,Wt.findKey=function(n,t,r){return t=Hr(t,r,3),cr(n,t,_r,true)},Wt.findLast=function(n,t,r){return t=Hr(t,r,3),cr(n,t,ir)},Wt.findLastIndex=function(n,t,r){var e=n?n.length:0; -for(t=Hr(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Wt.findLastKey=function(n,t,r){return t=Hr(t,r,3),cr(n,t,gr,true)},Wt.findWhere=function(n,t){return Ie(n,br(t))},Wt.first=ye,Wt.has=function(n,t){return n?Uu.call(n,t):false},Wt.identity=vu,Wt.includes=ke,Wt.indexOf=de,Wt.isArguments=Ye,Wt.isArray=So,Wt.isBoolean=function(n){return true===n||false===n||h(n)&&Lu.call(n)==M||false},Wt.isDate=function(n){return h(n)&&Lu.call(n)==q||false},Wt.isElement=Ze,Wt.isEmpty=function(n){if(null==n)return true;var t=n.length; -return oe(t)&&(So(n)||tu(n)||Ye(n)||h(n)&&Je(n.splice))?!t:!Fo(n).length},Wt.isEqual=function(n,t,r,e){return r=typeof r=="function"&&Nr(r,e,3),!r&&ie(n)&&ie(t)?n===t:(e=r?r(n,t):w,typeof e=="undefined"?dr(n,t,r):!!e)},Wt.isError=Ge,Wt.isFinite=Wo,Wt.isFunction=Je,Wt.isMatch=function(n,t,r,e){var u=Fo(t),o=u.length;if(r=typeof r=="function"&&Nr(r,e,3),!r&&1==o){var i=u[0];if(e=t[i],ie(e))return null!=n&&e===n[i]&&Uu.call(n,i)}for(var i=wu(o),f=wu(o);o--;)e=i[o]=t[u[o]],f[o]=ie(e);return mr(n,u,i,f,r) -},Wt.isNaN=function(n){return Qe(n)&&n!=+n},Wt.isNative=He,Wt.isNull=function(n){return null===n},Wt.isNumber=Qe,Wt.isObject=Xe,Wt.isPlainObject=No,Wt.isRegExp=nu,Wt.isString=tu,Wt.isTypedArray=ru,Wt.isUndefined=function(n){return typeof n=="undefined"},Wt.kebabCase=Bo,Wt.last=function(n){var t=n?n.length:0;return t?n[t-1]:w},Wt.lastIndexOf=function(n,t,r){var e=n?n.length:0;if(!e)return-1;var u=e;if(typeof r=="number")u=(0>r?uo(e+r,0):oo(r||0,e-1))+1;else if(r)return u=Sr(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1; -if(t!==t)return p(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Wt.max=Io,Wt.min=Oo,Wt.noConflict=function(){return _._=$u,this},Wt.noop=mu,Wt.now=To,Wt.pad=function(n,t,r){n=e(n),t=+t;var u=n.length;return ur?0:+r||0,n.length),n.lastIndexOf(t,r)==r -},Wt.template=function(n,t,r){var u=Wt.templateSettings;r&&ue(n,t,r)&&(t=r=null),n=e(n),t=Ht(Ht({},r||t),u,Xt),r=Ht(Ht({},t.imports),u.imports,Xt);var o,i,f=Fo(r),a=Cr(r,f),c=0;r=t.interpolate||xt;var l="__p+='";r=Ru((t.escape||xt).source+"|"+r.source+"|"+(r===gt?vt:xt).source+"|"+(t.evaluate||xt).source+"|$","g");var p="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Et,s),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t -}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(it,""):l).replace(ft,"$1").replace(at,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=hu(function(){return Au(f,p+"return "+l).apply(w,a)}),t.source=l,Ge(t))throw t;return t},Wt.trim=su,Wt.trimLeft=function(n,t,r){var u=n;return(n=e(n))?n.slice((r?ue(u,t,r):null==t)?v(n):o(n,t+"")):n -},Wt.trimRight=function(n,t,r){var u=n;return(n=e(n))?(r?ue(u,t,r):null==t)?n.slice(0,y(n)+1):n.slice(0,i(n,t+"")+1):n},Wt.trunc=function(n,t,r){r&&ue(n,t,r)&&(t=null);var u=T;if(r=S,null!=t)if(Xe(t)){var o="separator"in t?t.separator:o,u="length"in t?+t.length||0:u;r="omission"in t?e(t.omission):r}else u=+t||0;if(n=e(n),u>=n.length)return n;if(u-=r.length,1>u)return r;if(t=n.slice(0,u),null==o)return t+r;if(nu(o)){if(n.slice(u).search(o)){var i,f=n.slice(0,u);for(o.global||(o=Ru(o.source,(yt.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index; -t=t.slice(0,null==i?u:i)}}else n.indexOf(o,u)!=u&&(o=t.lastIndexOf(o),-1o.__dir__,f.push({iteratee:Hr(n,u,3),type:t}),o}}),Mt(["drop","take"],function(n,t){var r="__"+n+"Count__",e=n+"While";Ut.prototype[n]=function(e){e=null==e?1:uo(Pu(e)||0,0); -var u=this.clone();if(u.__filtered__){var o=u[r];u[r]=t?oo(o,e):o+e}else(u.__views__||(u.__views__=[])).push({size:e,type:n+(0>u.__dir__?"Right":"")});return u},Ut.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},Ut.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),Mt(["first","last"],function(n,t){var r="take"+(t?"Right":"");Ut.prototype[n]=function(){return this[r](1).value()[0]}}),Mt(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right"); -Ut.prototype[n]=function(){return this[r](1)}}),Mt(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?br:jr;Ut.prototype[n]=function(n){return this[r](e(n))}}),Ut.prototype.compact=function(){return this.filter(vu)},Ut.prototype.dropWhile=function(n,t){var r;return n=Hr(n,t,3),this.filter(function(t,e,u){return r||(r=!n(t,e,u))})},Ut.prototype.reject=function(n,t){return n=Hr(n,t,3),this.filter(function(t,r,e){return!n(t,r,e)})},Ut.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n); -return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},Ut.prototype.toArray=function(){return this.drop(0)},_r(Ut.prototype,function(n,t){var r=Wt[t],e=/^(?:first|last)$/.test(t);Wt.prototype[t]=function(){function t(n){return n=[n],Vu.apply(n,o),r.apply(Wt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,f=!!this.__actions__.length,a=u instanceof Ut,c=a&&!f;return e&&!i?c?n.call(u):r.call(Wt,this.value()):a||So(u)?(u=n.apply(c?u:new Ut(this),o),e||!f&&!u.__actions__||(u.__actions__||(u.__actions__=[])).push({func:je,args:[t],thisArg:Wt}),new Nt(u,i)):this.thru(t) -}}),Mt("concat join pop push shift sort splice unshift".split(" "),function(n){var t=Cu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n);Wt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),Ut.prototype.clone=function(){var n=this.__actions__,t=this.__iteratees__,r=this.__views__,e=new Ut(this.__wrapped__);return e.__actions__=n?zt(n):null,e.__dir__=this.__dir__,e.__dropCount__=this.__dropCount__,e.__filtered__=this.__filtered__,e.__iteratees__=t?zt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?zt(r):null,e -},Ut.prototype.reverse=function(){if(this.__filtered__){var n=new Ut(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Ut.prototype.value=function(){var n=this.__wrapped__.value();if(!So(n))return Tr(n,this.__actions__);var t,r=this.__dir__,e=0>r;t=n.length;for(var u=this.__views__,o=0,i=-1,f=u?u.length:0;++i"'`]/g,st=RegExp(ct.source),pt=RegExp(lt.source),ht=/<%-([\s\S]+?)%>/g,_t=/<%([\s\S]+?)%>/g,gt=/<%=([\s\S]+?)%>/g,vt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yt=/\w*$/,dt=/^\s*function[ \n\r\t]+\w/,mt=/^0[xX]/,wt=/^\[object .+?Constructor\]$/,bt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,xt=/($^)/,At=/[.*+?^${}()|[\]\/\\]/g,jt=RegExp(At.source),kt=/\bthis\b/,Et=/['\n\r\u2028\u2029\\]/g,Rt=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),It=" \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",Ot="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),Ct={}; -Ct[X]=Ct[H]=Ct[Q]=Ct[nt]=Ct[tt]=Ct[rt]=Ct[et]=Ct[ut]=Ct[ot]=true,Ct[z]=Ct[D]=Ct[J]=Ct[M]=Ct[q]=Ct[P]=Ct[K]=Ct["[object Map]"]=Ct[V]=Ct[Y]=Ct[Z]=Ct["[object Set]"]=Ct[G]=Ct["[object WeakMap]"]=false;var Tt={};Tt[z]=Tt[D]=Tt[J]=Tt[M]=Tt[q]=Tt[X]=Tt[H]=Tt[Q]=Tt[nt]=Tt[tt]=Tt[V]=Tt[Y]=Tt[Z]=Tt[G]=Tt[rt]=Tt[et]=Tt[ut]=Tt[ot]=true,Tt[P]=Tt[K]=Tt["[object Map]"]=Tt["[object Set]"]=Tt["[object WeakMap]"]=false;var St={leading:false,maxWait:0,trailing:false},Wt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Nt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ut={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ft={"function":true,object:true},Lt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$t=Ft[typeof window]&&window!==(this&&this.window)?window:this,Bt=Ft[typeof exports]&&exports&&!exports.nodeType&&exports,Ft=Ft[typeof module]&&module&&!module.nodeType&&module,zt=Bt&&Ft&&typeof global=="object"&&global; -!zt||zt.global!==zt&&zt.window!==zt&&zt.self!==zt||($t=zt);var zt=Ft&&Ft.exports===Bt&&Bt,Dt=m();typeof define=="function"&&typeof define.amd=="object"&&define.amd?($t._=Dt, define(function(){return Dt})):Bt&&Ft?zt?(Ft.exports=Dt)._=Dt:Bt._=Dt:$t._=Dt}).call(this); \ No newline at end of file +;(function(){function n(n,t){if(n!==t){var r=n===n,e=t===t;if(n>t||!r||typeof n=="undefined"&&e)return 1;if(n=n&&9<=n&&13>=n||32==n||160==n||5760==n||6158==n||8192<=n&&(8202>=n||8232==n||8233==n||8239==n||8287==n||12288==n||65279==n) +}function v(n,t){for(var r=-1,e=n.length,u=-1,o=[];++re&&(e=u)}return e}function Gt(n,t,r,e){var u=-1,o=n.length;for(e&&o&&(r=n[++u]);++ui(r,a)&&u.push(a);return u}function fr(n,t){var r=n?n.length:0;if(!fe(r))return vr(n,t);for(var e=-1,u=_e(n);++et&&(t=-t>u?0:u+t),r=typeof r=="undefined"||r>u?u:+r||0,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=bu(u);++eu(a,s)&&((r||f)&&a.push(s),c.push(l))}return c}function Sr(n,t){for(var r=-1,e=t.length,u=bu(e);++r>>1,i=n[o];(r?i<=t:it||null==r)return r;if(3=o&&f<=i&&(e=C&&t>u||e>u&&t>=C)||o)&&(t&A&&(r[2]=p[2],f|=e&A?0:k),(e=p[3])&&(u=r[3],r[3]=u?$r(u,e,p[4]):qt(e),r[4]=u?v(r[3],z):qt(p[4])),(e=p[5])&&(u=r[5],r[5]=u?Br(u,e,p[6]):qt(e),r[6]=u?v(r[5],z):qt(p[6])),(e=p[7])&&(r[7]=qt(e)),t&T&&(r[8]=null==r[8]?p[8]:io(r[8],p[8])),null==r[9]&&(r[9]=p[9]),r[0]=p[0],r[1]=f),t=r[1],f=r[9] +}return r[9]=null==f?a?0:n.length:oo(f-c,0)||0,(p?xo:ko)(t==A?Mr(r[0],r[2]):t!=I&&t!=(A|I)||r[4].length?Vr.apply(b,r):Zr.apply(b,r),r)}function Jr(n,t,r,e,u,o,i){var f=-1,a=n.length,c=t.length,l=true;if(a!=c&&(!u||c<=a))return false;for(;l&&++fu)||i===e&&i===o)&&(u=i,o=n)}),o}function ne(n,t,r){var e=Nt.callback||gu,e=e===gu?er:e;return r?e(n,t,r):e}function te(n,r,e){var u=Nt.indexOf||we,u=u===we?t:u;return n?u(n,r,e):u}function re(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&Fu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function ee(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Ru),new n +}function ue(n,t,r){var e=n.constructor;switch(t){case X:return Lr(n);case q:case P:return new e(+n);case H:case Q:case nt:case tt:case rt:case et:case ut:case ot:case it:return t=n.buffer,new e(r?Lr(t):t,n.byteOffset,n.length);case Y:case J:return new e(n);case G:var u=new e(n.source,dt.exec(n));u.lastIndex=n.lastIndex}return u}function oe(n,t){return n=+n,t=null==t?yo:t,-1t?0:t)):[]}function ye(n,t,r){var e=n?n.length:0; +return e?((r?ie(n,t,r):null==t)&&(t=1),t=e-(+t||0),Or(n,0,0>t?0:t)):[]}function de(n,t,r){var e=-1,u=n?n.length:0;for(t=ne(t,r,3);++ee?oo(u+e,0):e||0;else if(e)return e=Nr(n,r),n=n[e],(r===r?r===n:n!==n)?e:-1;return t(n,r,e)}function be(n){return ve(n,1)}function xe(n,r,e,u){if(!n||!n.length)return[];null!=r&&typeof r!="boolean"&&(u=e,e=ie(n,r,u)?null:r,r=false); +var o=ne();if((o!==er||null!=e)&&(e=o(e,u,3)),r&&te()==t){r=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e>>0,e=bu(r);++tr?oo(e+r,0):r||0:0,typeof n=="string"||!Wo(n)&&ru(n)?rarguments.length,fr)}function Ue(n,t,r,e){return(Wo(n)?Jt:Ir)(n,ne(t,e,4),r,3>arguments.length,ar)}function Fe(n,t,r){return(r?ie(n,t,r):null==t)?(n=he(n),t=n.length,0t?0:+t||0,n.length),n) +}function Le(n){n=he(n);for(var t=-1,r=n.length,e=bu(r);++t=r||r>t?(f&&Pu(f),r=p,f=s=p=b,r&&(h=So(),a=n.apply(l,i),s||f||(i=l=null))):s=Ju(e,r)}function u(){s&&Pu(s),f=s=p=b,(g||_!==t)&&(h=So(),a=n.apply(l,i),s||f||(i=l=null)) +}function o(){if(i=arguments,c=So(),l=this,p=g&&(s||!v),false===_)var r=v&&!s;else{f||v||(h=c);var o=_-(c-h),y=0>=o||o>_;y?(f&&(f=Pu(f)),h=c,a=n.apply(l,i)):f||(f=Ju(u,o))}return y&&s?s=Pu(s):s||t===_||(s=Ju(e,t)),r&&(y=true,a=n.apply(l,i)),!y||s||f||(i=l=null),a}var i,f,a,c,l,s,p,h=0,_=false,g=true;if(typeof n!="function")throw new Cu(B);if(t=0>t?0:t,true===r)var v=true,g=false;else He(r)&&(v=r.leading,_="maxWait"in r&&oo(+r.maxWait||0,t),g="trailing"in r?r.trailing:g);return o.cancel=function(){s&&Pu(s),f&&Pu(f),f=s=p=b +},o}function Ke(){var n=arguments,t=n.length-1;if(0>t)return function(n){return n};if(!Kt(n,r))throw new Cu(B);return function(){for(var r=t,e=n[r].apply(this,arguments);r--;)e=n[r].call(this,e);return e}}function Ve(n,t){function r(){var e=r.cache,u=t?t.apply(this,arguments):arguments[0];if(e.has(u))return e.get(u);var o=n.apply(this,arguments);return e.set(u,o),o}if(typeof n!="function"||t&&typeof t!="function")throw new Cu(B);return r.cache=new Ve.Cache,r}function Ye(n){var t=Or(arguments,1),r=v(t,Ye.placeholder); +return Gr(n,I,null,t,r)}function Ze(n){var t=Or(arguments,1),r=v(t,Ze.placeholder);return Gr(n,O,null,t,r)}function Ge(n){return fe(_(n)?n.length:b)&&$u.call(n)==D||false}function Je(n){return n&&1===n.nodeType&&_(n)&&-1<$u.call(n).indexOf("Element")||false}function Xe(n){return _(n)&&typeof n.message=="string"&&$u.call(n)==K||false}function He(n){var t=typeof n;return"function"==t||n&&"object"==t||false}function Qe(n){return null==n?false:$u.call(n)==V?zu.test(Nu.call(n)):_(n)&&bt.test(n)||false}function nu(n){return typeof n=="number"||_(n)&&$u.call(n)==Y||false +}function tu(n){return _(n)&&$u.call(n)==G||false}function ru(n){return typeof n=="string"||_(n)&&$u.call(n)==J||false}function eu(n){return _(n)&&fe(n.length)&&Tt[$u.call(n)]||false}function uu(n){return rr(n,iu(n))}function ou(n){return dr(n,iu(n))}function iu(n){if(null==n)return[];He(n)||(n=Ru(n));for(var t=n.length,t=t&&fe(t)&&(Wo(n)||wo.nonEnumArgs&&Ge(n))&&t||0,r=n.constructor,e=-1,r=typeof r=="function"&&r.prototype===n,u=bu(t),o=0t||!n||!eo(t))return r;do t%2&&(r+=n),t=Ku(t/2),n+=n;while(t);return r}function pu(n,t,r){var e=n;return(n=u(n))?(r?ie(e,t,r):null==t)?n.slice(y(n),d(n)+1):(t+="",n.slice(i(n,t),f(n,t)+1)):n}function hu(n,t,r){return r&&ie(n,t,r)&&(t=null),n=u(n),n.match(t||It)||[] +}function _u(){var n=arguments.length,t=arguments[0];try{for(var r=bu(n?n-1:0);0<--n;)r[n-1]=arguments[n];return t.apply(b,r)}catch(e){return Xe(e)?e:new Au(e)}}function gu(n,t,r){return r&&ie(n,t,r)&&(t=null),_(n)?du(n):er(n,t)}function vu(n){return function(){return n}}function yu(n){return n}function du(n){return Ar(ur(n,true))}function mu(n,t,r){if(null==r){var e=He(t),u=e&&$o(t);((u=u&&u.length&&dr(t,u))?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=dr(t,$o(t)));var o=true,e=-1,i=Uo(n),f=u.length;false===r?o=false:He(r)&&"chain"in r&&(o=r.chain); +for(;++e>>1,vo=no?no.BYTES_PER_ELEMENT:0,yo=ku.pow(2,53)-1,mo=Qu&&new Qu,wo=Nt.support={};!function(n){wo.funcDecomp=!Qe(g.WinRTError)&&Et.test(w),wo.funcNames=typeof ju.name=="string";try{wo.dom=11===Wu.createDocumentFragment().nodeType +}catch(t){wo.dom=false}try{wo.nonEnumArgs=!Zu.call(arguments,1)}catch(r){wo.nonEnumArgs=true}}(0,0),Nt.templateSettings={escape:_t,evaluate:gt,interpolate:vt,variable:"",imports:{_:Nt}};var bo=function(){function n(){}return function(t){if(He(t)){n.prototype=t;var r=new n;n.prototype=null}return r||g.Object()}}(),xo=mo?function(n,t){return mo.set(n,t),n}:yu;Mu||(Lr=Du&&Hu?function(n){var t=n.byteLength,r=no?Ku(t/vo):0,e=r*vo,u=new Du(t);if(r){var o=new no(u,0,r);o.set(new no(n,0,r))}return t!=e&&(o=new Hu(u,e),o.set(new Hu(n,e))),u +}:vu(null));var Ao=ro&&Gu?function(n){return new zt(n)}:vu(null),jo=mo?function(n){return mo.get(n)}:wu,ko=function(){var n=0,t=0;return function(r,e){var u=So(),o=U-(u-t);if(t=u,0=N)return r}else n=0;return xo(r,e)}}(),Eo=zr(function(n,t,r){Fu.call(n,r)?++n[r]:n[r]=1}),Ro=zr(function(n,t,r){Fu.call(n,r)?n[r].push(t):n[r]=[t]}),Io=zr(function(n,t,r){n[r]=t}),Oo=Kr(Zt),Co=Kr(function(n){for(var t=-1,r=n.length,e=po;++t--n?t.apply(this,arguments):void 0}},Nt.ary=function(n,t,r){return r&&ie(n,t,r)&&(t=null),t=n&&null==t?n.length:oo(+t||0,0),Gr(n,T,null,null,null,null,t)},Nt.assign=Lo,Nt.at=function(n){return fe(n?n.length:0)&&(n=he(n)),tr(n,pr(arguments,false,false,1))},Nt.before=Be,Nt.bind=ze,Nt.bindAll=function(n){for(var t=n,r=1r&&(r=-r>u?0:u+r),e=typeof e=="undefined"||e>u?u:+e||0,0>e&&(e+=u),u=r>e?0:e>>>0,r>>>=0;r(s?Dt(s,f):o(l,f))){for(r=e;--r;){var p=u[r];if(0>(p?Dt(p,f):o(n[r],f)))continue n}s&&s.push(f),l.push(f)}return l},Nt.invert=function(n,t,r){r&&ie(n,t,r)&&(t=null),r=-1; +for(var e=$o(n),u=e.length,o={};++rt?0:t)):[]},Nt.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?ie(n,t,r):null==t)&&(t=1),t=e-(+t||0),Or(n,0>t?0:t)):[]},Nt.takeRightWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];for(t=ne(t,r,3);e--&&t(n[e],e,n););return Or(n,e+1)},Nt.takeWhile=function(n,t,r){var e=n?n.length:0;if(!e)return[];var u=-1;for(t=ne(t,r,3);++un||!eo(n))return[];var e=-1,u=bu(io(n,ho));for(t=Fr(t,r,1);++er?0:+r||0,e))-t.length,0<=r&&n.indexOf(t,r)==r},Nt.escape=function(n){return(n=u(n))&&ht.test(n)?n.replace(st,s):n},Nt.escapeRegExp=cu,Nt.every=Re,Nt.find=Oe,Nt.findIndex=de,Nt.findKey=function(n,t,r){return t=ne(t,r,3),sr(n,t,vr,true)},Nt.findLast=function(n,t,r){return t=ne(t,r,3),sr(n,t,ar)},Nt.findLastIndex=function(n,t,r){var e=n?n.length:0; +for(t=ne(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Nt.findLastKey=function(n,t,r){return t=ne(t,r,3),sr(n,t,yr,true)},Nt.findWhere=function(n,t){return Oe(n,Ar(t))},Nt.first=me,Nt.has=function(n,t){return n?Fu.call(n,t):false},Nt.identity=yu,Nt.includes=Se,Nt.indexOf=we,Nt.inRange=function(n,t,r){return t=+t||0,"undefined"===typeof r?(r=t,t=0):r=+r||0,n>=t&&nr?oo(e+r,0):io(r||0,e-1))+1; +else if(r)return u=Nr(n,t,true)-1,n=n[u],(t===t?t===n:n!==n)?u:-1;if(t!==t)return h(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Nt.max=Oo,Nt.min=Co,Nt.noConflict=function(){return g._=Bu,this},Nt.noop=wu,Nt.now=So,Nt.pad=function(n,t,r){n=u(n),t=+t;var e=n.length;return er?0:+r||0,n.length),n.lastIndexOf(t,r)==r},Nt.template=function(n,t,r){var e=Nt.templateSettings;r&&ie(n,t,r)&&(t=r=null),n=u(n),t=nr(nr({},r||t),e,Qt),r=nr(nr({},t.imports),e.imports,Qt);var o,i,f=$o(r),a=Sr(r,f),c=0;r=t.interpolate||At;var l="__p+='";r=Iu((t.escape||At).source+"|"+r.source+"|"+(r===vt?yt:At).source+"|"+(t.evaluate||At).source+"|$","g"); +var s="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,u,f,a){return e||(e=u),l+=n.slice(c,a).replace(Rt,p),r&&(o=true,l+="'+__e("+r+")+'"),f&&(i=true,l+="';"+f+";\n__p+='"),e&&(l+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),l+="';",(t=t.variable)||(l="with(obj){"+l+"}"),l=(i?l.replace(ft,""):l).replace(at,"$1").replace(ct,"$1;"),l="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}",t=_u(function(){return ju(f,s+"return "+l).apply(b,a) +}),t.source=l,Xe(t))throw t;return t},Nt.trim=pu,Nt.trimLeft=function(n,t,r){var e=n;return(n=u(n))?n.slice((r?ie(e,t,r):null==t)?y(n):i(n,t+"")):n},Nt.trimRight=function(n,t,r){var e=n;return(n=u(n))?(r?ie(e,t,r):null==t)?n.slice(0,d(n)+1):n.slice(0,f(n,t+"")+1):n},Nt.trunc=function(n,t,r){r&&ie(n,t,r)&&(t=null);var e=S;if(r=W,null!=t)if(He(t)){var o="separator"in t?t.separator:o,e="length"in t?+t.length||0:e;r="omission"in t?u(t.omission):r}else e=+t||0;if(n=u(n),e>=n.length)return n;if(e-=r.length,1>e)return r; +if(t=n.slice(0,e),null==o)return t+r;if(tu(o)){if(n.slice(e).search(o)){var i,f=n.slice(0,e);for(o.global||(o=Iu(o.source,(dt.exec(o)||"")+"g")),o.lastIndex=0;n=o.exec(f);)i=n.index;t=t.slice(0,null==i?e:i)}}else n.indexOf(o,e)!=e&&(o=t.lastIndexOf(o),-1o.__dir__,f.push({iteratee:ne(n,u,3),type:t}),o +}}),Pt(["drop","take"],function(n,t){var r="__"+n+"Count__",e=n+"While";Lt.prototype[n]=function(e){e=null==e?1:oo(Ku(e)||0,0);var u=this.clone();if(u.__filtered__){var o=u[r];u[r]=t?io(o,e):o+e}else(u.__views__||(u.__views__=[])).push({size:e,type:n+(0>u.__dir__?"Right":"")});return u},Lt.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()},Lt.prototype[n+"RightWhile"]=function(n,t){return this.reverse()[e](n,t).reverse()}}),Pt(["first","last"],function(n,t){var r="take"+(t?"Right":""); +Lt.prototype[n]=function(){return this[r](1).value()[0]}}),Pt(["initial","rest"],function(n,t){var r="drop"+(t?"":"Right");Lt.prototype[n]=function(){return this[r](1)}}),Pt(["pluck","where"],function(n,t){var r=t?"filter":"map",e=t?Ar:Er;Lt.prototype[n]=function(n){return this[r](e(n))}}),Lt.prototype.compact=function(){return this.filter(yu)},Lt.prototype.dropWhile=function(n,t){var r;return n=ne(n,t,3),this.filter(function(t,e,u){return r||(r=!n(t,e,u))})},Lt.prototype.reject=function(n,t){return n=ne(n,t,3),this.filter(function(t,r,e){return!n(t,r,e) +})},Lt.prototype.slice=function(n,t){n=null==n?0:+n||0;var r=0>n?this.takeRight(-n):this.drop(n);return typeof t!="undefined"&&(t=+t||0,r=0>t?r.dropRight(-t):r.take(t-n)),r},Lt.prototype.toArray=function(){return this.drop(0)},vr(Lt.prototype,function(n,t){var r=Nt[t],e=/^(?:first|last)$/.test(t);Nt.prototype[t]=function(){function t(n){return n=[n],Yu.apply(n,o),r.apply(Nt,n)}var u=this.__wrapped__,o=arguments,i=this.__chain__,f=!!this.__actions__.length,a=u instanceof Lt,c=a&&!f;return e&&!i?c?n.call(u):r.call(Nt,this.value()):a||Wo(u)?(u=n.apply(c?u:new Lt(this),o),e||!f&&!u.__actions__||(u.__actions__||(u.__actions__=[])).push({func:Ee,args:[t],thisArg:Nt}),new Ft(u,i)):this.thru(t) +}}),Pt("concat join pop push shift sort splice unshift".split(" "),function(n){var t=Tu[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:join|pop|shift)$/.test(n);Nt.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),Lt.prototype.clone=function(){var n=this.__actions__,t=this.__iteratees__,r=this.__views__,e=new Lt(this.__wrapped__);return e.__actions__=n?qt(n):null,e.__dir__=this.__dir__,e.__dropCount__=this.__dropCount__,e.__filtered__=this.__filtered__,e.__iteratees__=t?qt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?qt(r):null,e +},Lt.prototype.reverse=function(){if(this.__filtered__){var n=new Lt(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n},Lt.prototype.value=function(){var n=this.__wrapped__.value();if(!Wo(n))return Wr(n,this.__actions__);var t,r=this.__dir__,e=0>r;t=n.length;for(var u=this.__views__,o=0,i=-1,f=u?u.length:0;++i"'`]/g,pt=RegExp(lt.source),ht=RegExp(st.source),_t=/<%-([\s\S]+?)%>/g,gt=/<%([\s\S]+?)%>/g,vt=/<%=([\s\S]+?)%>/g,yt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,mt=/^\s*function[ \n\r\t]+\w/,wt=/^0[xX]/,bt=/^\[object .+?Constructor\]$/,xt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,At=/($^)/,jt=/[.*+?^${}()|[\]\/\\]/g,kt=RegExp(jt.source),Et=/\bthis\b/,Rt=/['\n\r\u2028\u2029\\]/g,It=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]{2,}(?=[A-Z\\xc0-\\xd6\\xd8-\\xde][a-z\\xdf-\\xf6\\xf8-\\xff]+)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+|[A-Z\\xc0-\\xd6\\xd8-\\xde]+|[0-9]+","g"),Ot=" \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",Ct="Array ArrayBuffer Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Math Number Object RegExp Set String _ clearTimeout document isFinite parseInt setTimeout TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap window WinRTError".split(" "),Tt={}; +Tt[H]=Tt[Q]=Tt[nt]=Tt[tt]=Tt[rt]=Tt[et]=Tt[ut]=Tt[ot]=Tt[it]=true,Tt[D]=Tt[M]=Tt[X]=Tt[q]=Tt[P]=Tt[K]=Tt[V]=Tt["[object Map]"]=Tt[Y]=Tt[Z]=Tt[G]=Tt["[object Set]"]=Tt[J]=Tt["[object WeakMap]"]=false;var St={};St[D]=St[M]=St[X]=St[q]=St[P]=St[H]=St[Q]=St[nt]=St[tt]=St[rt]=St[Y]=St[Z]=St[G]=St[J]=St[et]=St[ut]=St[ot]=St[it]=true,St[K]=St[V]=St["[object Map]"]=St["[object Set]"]=St["[object WeakMap]"]=false;var Wt={leading:false,maxWait:0,trailing:false},Nt={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss"},Ut={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Ft={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Lt={"function":true,object:true},$t={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Bt=Lt[typeof window]&&window!==(this&&this.window)?window:this,zt=Lt[typeof exports]&&exports&&!exports.nodeType&&exports,Lt=Lt[typeof module]&&module&&!module.nodeType&&module,Dt=zt&&Lt&&typeof global=="object"&&global; +!Dt||Dt.global!==Dt&&Dt.window!==Dt&&Dt.self!==Dt||(Bt=Dt);var Dt=Lt&&Lt.exports===zt&&zt,Mt=w();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(Bt._=Mt, define(function(){return Mt})):zt&&Lt?Dt?(Lt.exports=Mt)._=Mt:zt._=Mt:Bt._=Mt}).call(this); \ No newline at end of file diff --git a/lodash.src.js b/lodash.src.js index 5f1c095c2b..80a6cc5bc8 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -1,6 +1,6 @@ /** * @license - * lodash 3.2.0 + * lodash 3.3.0 * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.7.0 * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors @@ -12,7 +12,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '3.2.0'; + var VERSION = '3.3.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, From d942189bc671e675ec12afa6ab9d60012829a89a Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 19 Feb 2015 23:38:18 -0800 Subject: [PATCH 27/27] Bump to v3.3.0. --- README.md | 6 +++--- bower.json | 2 +- component.json | 2 +- package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a1d253d942..ca8f2b5f6b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash v3.2.0 +# lodash v3.3.0 The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) with packages for [Bower](http://bower.io/), [Component](http://component.github.io/), & [Volo](http://volojs.org/). @@ -12,8 +12,8 @@ $ lodash modern -o ./lodash.js lodash is also available in a variety of other builds & module formats. * npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds - * AMD modules for [modern](https://github.com/lodash/lodash/tree/3.2.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.2.0-amd) builds - * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.2.0-es) build + * AMD modules for [modern](https://github.com/lodash/lodash/tree/3.3.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.3.0-amd) builds + * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.3.0-es) build ## Further Reading diff --git a/bower.json b/bower.json index a4a1a263d6..0ee8e0225c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "3.2.0", + "version": "3.3.0", "main": "lodash.js", "ignore": [ ".*", diff --git a/component.json b/component.json index cf7b6479db..e3b503d227 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "lodash", "repo": "lodash/lodash", - "version": "3.2.0", + "version": "3.3.0", "description": "The modern build of lodash.", "license": "MIT", "main": "lodash.js", diff --git a/package.json b/package.json index c7ea952ece..75eefc4aa8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "3.2.0", + "version": "3.3.0", "main": "lodash.src.js", "private": true, "devDependencies": {