From f2eee8896cb70ff876a3aad8f7bcd0412cbf3d2a Mon Sep 17 00:00:00 2001 From: Juliano Castilho Date: Tue, 24 Feb 2015 20:15:26 -0400 Subject: [PATCH 01/46] Fix code example typo in `_.dropRightWhile`. [ci skip] --- doc/README.md | 2 +- lodash.src.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/README.md b/doc/README.md index ff8e9bf46f..2c1ad3b95c 100644 --- a/doc/README.md +++ b/doc/README.md @@ -500,7 +500,7 @@ var users = [ ]; // using the `_.matches` callback shorthand -_.pluck(_.dropRightWhile(users, { 'user': pebbles, 'active': false }), 'user'); +_.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); // => ['barney', 'fred'] // using the `_.matchesProperty` callback shorthand diff --git a/lodash.src.js b/lodash.src.js index d65e6061af..014b2fcf88 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -4385,7 +4385,7 @@ * ]; * * // using the `_.matches` callback shorthand - * _.pluck(_.dropRightWhile(users, { 'user': pebbles, 'active': false }), 'user'); + * _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); * // => ['barney', 'fred'] * * // using the `_.matchesProperty` callback shorthand From eeb4ede60d8d5934e7825b56a7ac7d433c44f9ff Mon Sep 17 00:00:00 2001 From: James Kyle Date: Sat, 21 Feb 2015 15:44:46 -0800 Subject: [PATCH 02/46] Add _.add/_.sum methods --- lodash.src.js | 40 ++++++++++++++++++++++++++++++++++++++ test/test.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index 014b2fcf88..0f0f9b4a9c 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -11159,6 +11159,44 @@ /*------------------------------------------------------------------------*/ + /** + * Adds two numbers. + * + * @static + * @memberOf _ + * @category Math + * @param {number} augend The first number to add. + * @param {number} addend The second number to add. + * @returns {number} Returns the sum. + * @example + * + * _.add(6, 4); + * // => 10 + */ + function add(augend, addend) { + return augend + addend; + } + + /** + * Calculates the sum of an array of numbers. + * + * @static + * @memberOf _ + * @category Math + * @param {number} array The numbers to add. + * @returns {number} Returns the sum. + * @example + * + * _.sum([4, 6, 2]); + * // => 12 + */ + function sum(array) { + if (!isArray(array) || array.length === 0) return NaN; + return arrayReduce(array, add, 0); + } + + /*------------------------------------------------------------------------*/ + // Ensure wrappers are instances of `baseLodash`. lodash.prototype = baseLodash.prototype; @@ -11301,6 +11339,7 @@ /*------------------------------------------------------------------------*/ // Add functions that return unwrapped values when chaining. + lodash.add = add; lodash.attempt = attempt; lodash.camelCase = camelCase; lodash.capitalize = capitalize; @@ -11370,6 +11409,7 @@ lodash.sortedLastIndex = sortedLastIndex; lodash.startCase = startCase; lodash.startsWith = startsWith; + lodash.sum = sum; lodash.template = template; lodash.trim = trim; lodash.trimLeft = trimLeft; diff --git a/test/test.js b/test/test.js index 26c611115f..0b97ff59c1 100644 --- a/test/test.js +++ b/test/test.js @@ -15098,6 +15098,28 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.add'); + + (function() { + test('should add two numbers together', 1, function() { + var actual = _.add(6, 4); + equal(actual, 10); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('lodash.sum'); + + (function() { + test('should return the sum of an array of numbers', 1, function() { + var actual = _.sum([6, 4, 2]); + equal(actual, 12); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash(...).commit'); (function() { @@ -15579,6 +15601,7 @@ (function() { var funcs = [ + 'add', 'clone', 'contains', 'every', @@ -15610,6 +15633,7 @@ 'parseInt', 'pop', 'shift', + 'sum', 'random', 'reduce', 'reduceRight', @@ -15756,6 +15780,33 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('"Math" category methods'); + + (function() { + var mathArrayMethods = [ + 'sum' + ]; + + _.each(mathArrayMethods, function(methodName) { + var func = _[methodName]; + + test('`_.' + methodName + '` should return NaN when passing a value other than an array', 5, function() { + var values = [undefined, null, 0, 'foo', {}]; + _.each(values, function(value) { + var actual = _[methodName](value); + deepEqual(actual, NaN); + }); + }); + + test('`_.' + methodName + '` should return NaN when passing an empty array', 1, function() { + var actual = _[methodName]([]); + deepEqual(actual, NaN); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash methods'); (function() { @@ -15832,7 +15883,7 @@ var acceptFalsey = _.difference(allMethods, rejectFalsey); - test('should accept falsey arguments', 209, function() { + test('should accept falsey arguments', 211, function() { var emptyArrays = _.map(falsey, _.constant([])), isExposed = '_' in root, oldDash = root._; From 42d23dbc700451fea6a918c7de2a86742fa4986a Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 25 Feb 2015 23:01:32 -0800 Subject: [PATCH 03/46] Simplify `_.sum`. --- lodash.src.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 0f0f9b4a9c..3b0e4f5161 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -11191,8 +11191,13 @@ * // => 12 */ function sum(array) { - if (!isArray(array) || array.length === 0) return NaN; - return arrayReduce(array, add, 0); + var length = array ? array.length : 0, + result = 0; + + while (length--) { + result += array[length]; + } + return result; } /*------------------------------------------------------------------------*/ From a024152c123d9d96fff72fe8bb4b94f0f649bcb3 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 25 Feb 2015 23:01:50 -0800 Subject: [PATCH 04/46] Add `add` and `sum` to `lodash` doc notes. [ci skip] --- lodash.src.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 3b0e4f5161..0e6ba7bd91 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -892,7 +892,7 @@ * `zip`, and `zipObject` * * The wrapper methods that are **not** chainable by default are: - * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, + * `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, * `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, @@ -903,8 +903,8 @@ * `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, * `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`, * `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, - * `startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, - * `trunc`, `unescape`, `uniqueId`, `value`, and `words` + * `startCase`, `startsWith`, `sum`, `template`, `trim`, `trimLeft`, + * `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words` * * The wrapper method `sample` will return a wrapped value when `n` is provided, * otherwise an unwrapped value is returned. From f081e2b799fae7898ba2c6810f653e20b7087d37 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 25 Feb 2015 23:03:01 -0800 Subject: [PATCH 05/46] Cleanup `_.sum` tests. --- test/test.js | 79 ++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 49 deletions(-) diff --git a/test/test.js b/test/test.js index 0b97ff59c1..a617419538 100644 --- a/test/test.js +++ b/test/test.js @@ -956,6 +956,16 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.add'); + + (function() { + test('should add two numbers together', 1, function() { + equal(_.add(6, 4), 10); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.after'); (function() { @@ -13080,6 +13090,26 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.sum'); + + (function() { + test('should return the sum of an array of numbers', 1, function() { + equal(_.sum([6, 4, 2]), 12); + }); + + test('should return `0` when passing empty `array` values', 1, function() { + var expected = _.map(empties, _.constant(0)); + + var actual = _.map(empties, function(value) { + return _.sum(value); + }); + + deepEqual(actual, expected); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.support'); (function() { @@ -15098,28 +15128,6 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.add'); - - (function() { - test('should add two numbers together', 1, function() { - var actual = _.add(6, 4); - equal(actual, 10); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('lodash.sum'); - - (function() { - test('should return the sum of an array of numbers', 1, function() { - var actual = _.sum([6, 4, 2]); - equal(actual, 12); - }); - }()); - - /*--------------------------------------------------------------------------*/ - QUnit.module('lodash(...).commit'); (function() { @@ -15780,33 +15788,6 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('"Math" category methods'); - - (function() { - var mathArrayMethods = [ - 'sum' - ]; - - _.each(mathArrayMethods, function(methodName) { - var func = _[methodName]; - - test('`_.' + methodName + '` should return NaN when passing a value other than an array', 5, function() { - var values = [undefined, null, 0, 'foo', {}]; - _.each(values, function(value) { - var actual = _[methodName](value); - deepEqual(actual, NaN); - }); - }); - - test('`_.' + methodName + '` should return NaN when passing an empty array', 1, function() { - var actual = _[methodName]([]); - deepEqual(actual, NaN); - }); - }); - }()); - - /*--------------------------------------------------------------------------*/ - QUnit.module('lodash methods'); (function() { From 9f213c119c6d138ae1c0c27c9ef1bcb4c3082b38 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 25 Feb 2015 23:35:16 -0800 Subject: [PATCH 06/46] Add more chaining tests. --- test/test.js | 135 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 120 insertions(+), 15 deletions(-) diff --git a/test/test.js b/test/test.js index a617419538..603b641298 100644 --- a/test/test.js +++ b/test/test.js @@ -962,6 +962,24 @@ test('should add two numbers together', 1, function() { equal(_.add(6, 4), 10); }); + + test('should return an unwrapped value when implicitly chaining', 1, function() { + if (!isNpm) { + strictEqual(_(1).add(2), 3); + } + else { + skipTest(); + } + }); + + test('should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_(1).chain().add(2) instanceof _); + } + else { + skipTest(); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -1248,7 +1266,7 @@ } }); - test('should return an unwrapped value when chaining', 1, function() { + test('should return an unwrapped value when implicitly chaining', 1, function() { if (!isNpm) { strictEqual(_(_.constant('x')).attempt(), 'x'); } @@ -1256,6 +1274,15 @@ skipTest(); } }); + + test('should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_(_.constant('x')).chain().attempt() instanceof _); + } + else { + skipTest(); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -1643,7 +1670,7 @@ strictEqual(func({ 'toString': _.constant(string) }), converted); }); - test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() { + test('`_.' + methodName + '` should return an unwrapped value implicitly when chaining', 1, function() { if (!isNpm) { strictEqual(_('foo bar')[methodName](), converted); } @@ -1651,6 +1678,15 @@ skipTest(); } }); + + test('`_.' + methodName + '` should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_('foo bar').chain()[methodName]() instanceof _); + } + else { + skipTest(); + } + }); }); /*--------------------------------------------------------------------------*/ @@ -1690,7 +1726,7 @@ strictEqual(_.capitalize(' fred'), ' fred'); }); - test('should return an unwrapped value when chaining', 1, function() { + test('should return an unwrapped value when implicitly chaining', 1, function() { if (!isNpm) { strictEqual(_('fred').capitalize(), 'Fred'); } @@ -1698,6 +1734,15 @@ skipTest(); } }); + + test('should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_('fred').chain().capitalize() instanceof _); + } + else { + skipTest(); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -4559,7 +4604,7 @@ deepEqual(actual, [1, 4, 7]); }); - test('should return an unwrapped value when chaining', 1, function() { + test('should return an unwrapped value when implicitly chaining', 1, function() { if (!isNpm) { strictEqual(_(array).first(), 1); } @@ -4568,6 +4613,15 @@ } }); + test('should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_(array).chain().first() instanceof _); + } + else { + skipTest(); + } + }); + test('should work in a lazy chain sequence', 1, function() { if (!isNpm) { var array = [1, 2, 3, 4]; @@ -5308,7 +5362,7 @@ func = _[methodName], isBaseEach = methodName == '_baseEach'; - test('`_.' + methodName + '` should return a wrapped value when chaining', 1, function() { + test('`_.' + methodName + '` should return a wrapped value when implicitly chaining', 1, function() { if (!(isBaseEach || isNpm)) { var wrapped = _(array)[methodName](_.noop); ok(wrapped instanceof _); @@ -5323,7 +5377,7 @@ var array = [1, 2, 3], func = _[methodName]; - test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() { + test('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', 1, function() { if (!isNpm) { var wrapped = _(array)[methodName](_.noop); ok(!(wrapped instanceof _)); @@ -5332,6 +5386,16 @@ skipTest(); } }); + + test('`_.' + methodName + '` should return a wrapped value when implicitly chaining', 1, function() { + if (!isNpm) { + var wrapped = _(array).chain()[methodName](_.noop); + ok(wrapped instanceof _); + } + else { + skipTest(); + } + }); }); _.each(_.difference(methods, arrayMethods, forInMethods), function(methodName) { @@ -5992,7 +6056,7 @@ }); }); - test('should work with ' + key + ' and return an unwrapped value when chaining', 1, function() { + test('should work with ' + key + ' and return an unwrapped value implicitly when chaining', 1, function() { if (!isNpm) { strictEqual(_(collection).includes(3), true); } @@ -6000,6 +6064,15 @@ skipTest(); } }); + + test('should work with ' + key + ' and return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_(collection).chain().includes(3) instanceof _); + } + else { + skipTest(); + } + }); }); _.each({ @@ -8776,7 +8849,7 @@ deepEqual(actual, [3, 6, 9]); }); - test('should return an unwrapped value when chaining', 1, function() { + test('should return an unwrapped value when implicitly chaining', 1, function() { if (!isNpm) { strictEqual(_(array).last(), 3); } @@ -8785,6 +8858,15 @@ } }); + test('should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_(array).chain().last() instanceof _); + } + else { + skipTest(); + } + }); + test('should work in a lazy chain sequence', 1, function() { if (!isNpm) { var array = [1, 2, 3, 4]; @@ -11865,13 +11947,18 @@ strictEqual(_.reduce(object, _.noop), undefined); }); - test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() { + test('`_.' + methodName + '` should return an unwrapped value when implicityly chaining', 1, function() { if (!isNpm) { - var actual = _(array)[methodName](function(sum, num) { - return sum + num; - }); + strictEqual(_(array)[methodName](add), 6); + } + else { + skipTest(); + } + }); - strictEqual(actual, 6); + test('`_.' + methodName + '` should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_(array).chain()[methodName](add) instanceof _); } else { skipTest(); @@ -12343,6 +12430,15 @@ } }); + test('should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + ok(_(array).chain().sample() instanceof _); + } + else { + skipTest(); + } + }); + test('should use a stored reference to `_.sample` when chaining', 2, function() { if (!isNpm) { var sample = _.sample; @@ -14510,7 +14606,7 @@ deepEqual(actual, [trimmed, trimmed, trimmed]); }); - test('`_.' + methodName + '` should return an unwrapped value when chaining', 1, function() { + test('`_.' + methodName + '` should return an unwrapped value when implicitly chaining', 1, function() { if (!isNpm) { var string = whitespace + 'a b c' + whitespace, expected = (index == 2 ? whitespace : '') + 'a b c' + (index == 1 ? whitespace : ''); @@ -14521,6 +14617,16 @@ skipTest(); } }); + + test('`_.' + methodName + '` should return a wrapped value when explicitly chaining', 1, function() { + if (!isNpm) { + var string = whitespace + 'a b c' + whitespace; + ok(_(string).chain()[methodName]() instanceof _); + } + else { + skipTest(); + } + }); }); /*--------------------------------------------------------------------------*/ @@ -15609,7 +15715,6 @@ (function() { var funcs = [ - 'add', 'clone', 'contains', 'every', From 6bb3b9a6847614246c6ea7bc7b96b282a9aa98f1 Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 26 Feb 2015 00:58:27 -0800 Subject: [PATCH 07/46] Disable lazy optimizations if the iteratee has more than one param. [closes #997] --- lodash.src.js | 16 ++-- test/test.js | 218 ++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 195 insertions(+), 39 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 0e6ba7bd91..fda325208c 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -11484,7 +11484,7 @@ iteratees = result.__iteratees__ || (result.__iteratees__ = []); result.__filtered__ = result.__filtered__ || isFilter; - iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index }); + iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 1), 'type': index }); return result; }; }); @@ -11554,7 +11554,7 @@ lastIndex, isRight = this.__dir__ < 0; - predicate = getCallback(predicate, thisArg, 3); + predicate = getCallback(predicate, thisArg, 1); return this.filter(function(value, index, array) { done = done && (isRight ? index < lastIndex : index > lastIndex); lastIndex = index; @@ -11563,7 +11563,7 @@ }; LazyWrapper.prototype.reject = function(predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); + predicate = getCallback(predicate, thisArg, 1); return this.filter(function(value, index, array) { return !predicate(value, index, array); }); @@ -11587,6 +11587,7 @@ // Add `LazyWrapper` methods to `lodash.prototype`. baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName], + checkIteratee = /(?:filter|map|reject|While)/.test(methodName), retUnwrapped = /^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { @@ -11594,9 +11595,14 @@ args = arguments, chainAll = this.__chain__, isHybrid = !!this.__actions__.length, - isLazy = value instanceof LazyWrapper, - onlyLazy = isLazy && !isHybrid; + isLazy = value instanceof LazyWrapper; + if (isLazy && checkIteratee) { + // avoid lazy use if the iteratee has a `length` other than `1` + var iteratee = args[0]; + isLazy = !(typeof iteratee == 'function' && iteratee.length != 1); + } + var onlyLazy = isLazy && !isHybrid; if (retUnwrapped && !chainAll) { return onlyLazy ? func.call(value) diff --git a/test/test.js b/test/test.js index 603b641298..294e2a2986 100644 --- a/test/test.js +++ b/test/test.js @@ -3973,18 +3973,37 @@ } }); - test('should provide the correct `predicate` arguments in a lazy chain sequence', 1, function() { + test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { if (!isNpm) { - var args; + var args, + expected = [16, 3, [1, 4, 9 ,16]]; - _(array).map(square).dropRightWhile(function() { + _(array).map(square).dropRightWhile(function(value, index, array) { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); + + _(array).map(square).dropRightWhile(function(value, index) { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); + + _(array).map(square).dropRightWhile(function(value) { args = slice.call(arguments); }).value(); deepEqual(args, [16, 3, array]); + + _(array).map(square).dropRightWhile(function() { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); } else { - skipTest(1); + skipTest(4); } }); }()); @@ -4055,18 +4074,37 @@ } }); - test('should provide the correct `predicate` arguments in a lazy chain sequence', 1, function() { + test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { if (!isNpm) { - var args; + var args, + expected = [1, 0, [1, 4, 9, 16]]; - _(array).map(square).dropWhile(function() { + _(array).map(square).dropWhile(function(value, index, array) { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); + + _(array).map(square).dropWhile(function(value, index) { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); + + _(array).map(square).dropWhile(function(index) { args = slice.call(arguments); }).value(); deepEqual(args, [1, 0, array]); + + _(array).map(square).dropWhile(function() { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); } else { - skipTest(1); + skipTest(4); } }); }()); @@ -4855,32 +4893,52 @@ deepEqual(_.takeRightWhile(objects, 'b'), objects.slice(1)); }); - test('should return a wrapped value when chaining', 2, function() { + test('should work in a lazy chain sequence', 3, function() { if (!isNpm) { var wrapped = _(array).takeRightWhile(function(num) { return num > 2; }); - ok(wrapped instanceof _); deepEqual(wrapped.value(), [3, 4]); + deepEqual(wrapped.reverse().value(), [4, 3]); + strictEqual(wrapped.last(), 4); } else { - skipTest(2); + skipTest(3); } }); - test('should provide the correct `predicate` arguments in a lazy chain sequence', 1, function() { + test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { if (!isNpm) { - var args; + var args, + expected = [16, 3, [1, 4, 9 , 16]]; - _(array).map(square).takeRightWhile(function() { + _(array).map(square).takeRightWhile(function(value, index, array) { + args = slice.call(arguments) + }).value(); + + deepEqual(args, expected); + + _(array).map(square).takeRightWhile(function(value, index) { + args = slice.call(arguments) + }).value(); + + deepEqual(args, expected); + + _(array).map(square).takeRightWhile(function(index) { args = slice.call(arguments); }).value(); deepEqual(args, [16, 3, array]); + + _(array).map(square).takeRightWhile(function() { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); } else { - skipTest(1); + skipTest(4); } }); }()); @@ -4950,18 +5008,37 @@ } }); - test('should provide the correct `predicate` arguments in a lazy chain sequence', 1, function() { + test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { if (!isNpm) { - var args; + var args, + expected = [1, 0, [1, 4, 9, 16]]; - _(array).map(square).takeWhile(function() { + _(array).map(square).takeWhile(function(value, index, array) { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); + + _(array).map(square).takeWhile(function(value, index) { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); + + _(array).map(square).takeWhile(function(value) { args = slice.call(arguments); }).value(); deepEqual(args, [1, 0, array]); + + _(array).map(square).takeWhile(function() { + args = slice.call(arguments); + }).value(); + + deepEqual(args, expected); } else { - skipTest(1); + skipTest(4); } }); }()); @@ -5934,7 +6011,7 @@ if (!isNpm) { var array = [1, 2, 1, 3], iteratee = function(value) { value.push(value[0]); return value; }, - predicate = function(value, index) { return index; }, + predicate = function(value) { return value[0] > 1; }, actual = _(array).groupBy(_.identity).map(iteratee).filter(predicate).take().value(); deepEqual(actual, [[2, 2]]); @@ -9099,6 +9176,43 @@ } }); + test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { + if (!isNpm) { + var args, + expected = [1, 0, [1, 4, 9]]; + + _(array).map(square).map(function(value, index, array) { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, expected); + + args = null; + _(array).map(square).map(function(value, index) { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, expected); + + args = null; + _(array).map(square).map(function(value) { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, [1, 0, array]); + + args = null; + _(array).map(square).map(function() { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, expected); + } + else { + skipTest(4); + } + }); + test('should be aliased', 1, function() { strictEqual(_.collect, _.map); }); @@ -10307,10 +10421,11 @@ test('should produce methods that work in a lazy chain sequence', 1, function() { if (!isNpm) { - var predicate = function(value) { return value > 2; }; _.mixin({ 'a': _.countBy, 'b': _.filter }); - var actual = _([1, 2, 1, 3]).a(_.identity).map(square).b(predicate).take().value(); + var predicate = function(value) { return value > 2; }, + actual = _([1, 2, 1, 3]).a(_.identity).map(square).b(predicate).take().value(); + deepEqual(actual, [4]); delete _.a; @@ -11987,8 +12102,10 @@ QUnit.module('filter methods'); _.each(['filter', 'reject'], function(methodName) { - var func = _[methodName], - isFilter = methodName == 'filter'; + var array = [1, 2, 3, 4], + func = _[methodName], + isFilter = methodName == 'filter', + objects = [{ 'a': 0 }, { 'a': 1 }]; test('`_.' + methodName + '` should not modify the resulting value from within `predicate`', 1, function() { var actual = func([0], function(num, index, array) { @@ -12000,18 +12117,16 @@ }); test('`_.' + methodName + '` should work with a "_.property" style `predicate`', 1, function() { - var objects = [{ 'a': 0 }, { 'a': 1 }]; deepEqual(func(objects, 'a'), [objects[isFilter ? 1 : 0]]); }); test('`_.' + methodName + '` should work with a "_where" style `predicate`', 1, function() { - var objects = [{ 'a': 0 }, { 'a': 1 }]; deepEqual(func(objects, objects[1]), [objects[isFilter ? 1 : 0]]); }); test('`_.' + methodName + '` should not modify wrapped values', 2, function() { if (!isNpm) { - var wrapped = _([1, 2, 3, 4]); + var wrapped = _(array); var actual = wrapped[methodName](function(num) { return num < 3; @@ -12032,23 +12147,58 @@ test('`_.' + methodName + '` should work in a lazy chain sequence', 2, function() { if (!isNpm) { - var array = [1, 2, 3], - object = { 'a': 1, 'b': 2, 'c': 3 }, - doubled = function(value) { return value * 2; }, - predicate = function(value) { return isFilter ? (value > 3) : (value < 3); }; + var object = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, + predicate = function(value) { return isFilter ? (value > 6) : (value < 6); }; - var expected = [4, 6], - actual = _(array).map(doubled)[methodName](predicate).value(); + var expected = [9, 16], + actual = _(array).map(square)[methodName](predicate).value(); deepEqual(actual, expected); - actual = _(object).mapValues(doubled)[methodName](predicate).value(); + actual = _(object).mapValues(square)[methodName](predicate).value(); deepEqual(actual, expected); } else { skipTest(2); } }); + + test('`_.' + methodName + '` should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { + if (!isNpm) { + var args, + expected = [1, 0, [1, 4, 9, 16]]; + + _(array).map(square)[methodName](function(value, index, array) { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, expected); + + args = null; + _(array).map(square)[methodName](function(value, index) { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, expected); + + args = null; + _(array).map(square)[methodName](function(value) { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, [1, 0, array]); + + args = null; + _(array).map(square)[methodName](function() { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, expected); + } + else { + skipTest(4); + } + }); }); /*--------------------------------------------------------------------------*/ From 2268376360746511186de324010fcccfe4980ed2 Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 26 Feb 2015 19:41:22 -0800 Subject: [PATCH 08/46] Update tested Firefox 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 0c2978c655..76d8244536 100644 --- a/test/saucelabs.js +++ b/test/saucelabs.js @@ -105,8 +105,8 @@ var platforms = [ ['Linux', 'android', '5.0'], ['Linux', 'android', '4.4'], ['Linux', 'android', '4.0'], + ['Windows 8.1', 'firefox', '36'], ['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'], From e914b83a1b97345fbd8cb68197caf7380bea331d Mon Sep 17 00:00:00 2001 From: jdalton Date: Fri, 27 Feb 2015 08:26:09 -0800 Subject: [PATCH 09/46] Add gitter badge to readme. [ci skip] [closes #983] --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ba13495f66..3d87f86d4c 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli): $ lodash modern -o ./lodash.js ``` +## Community + +[![Join the chat at https://gitter.im/lodash/lodash](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lodash/lodash) + ## Module formats lodash is also available in a variety of other builds & module formats. From 68942f7ec4012132b8fe33e6e83dc0d0f6c16904 Mon Sep 17 00:00:00 2001 From: jdalton Date: Fri, 27 Feb 2015 09:20:57 -0800 Subject: [PATCH 10/46] Move `_.max` & `_.min` to Math category & make `_.sum` work on collections. --- lodash.src.js | 214 ++++++++++++++++++++++++++------------------------ test/test.js | 20 ++++- 2 files changed, 127 insertions(+), 107 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index fda325208c..5dd22deb6d 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -6408,104 +6408,6 @@ return func(collection, iteratee); } - /** - * Gets the maximum value of `collection`. If `collection` is empty or falsey - * `-Infinity` is returned. If an iteratee function is provided it is invoked - * for each value in `collection` to generate the criterion by which the value - * is ranked. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the maximum value. - * @example - * - * _.max([4, 2, 8, 6]); - * // => 8 - * - * _.max([]); - * // => -Infinity - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * _.max(users, function(chr) { - * return chr.age; - * }); - * // => { 'user': 'fred', 'age': 40 }; - * - * // using the `_.property` callback shorthand - * _.max(users, 'age'); - * // => { 'user': 'fred', 'age': 40 }; - */ - var max = createExtremum(arrayMax); - - /** - * Gets the minimum value of `collection`. If `collection` is empty or falsey - * `Infinity` is returned. If an iteratee function is provided it is invoked - * for each value in `collection` to generate the criterion by which the value - * is ranked. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the minimum value. - * @example - * - * _.min([4, 2, 8, 6]); - * // => 2 - * - * _.min([]); - * // => Infinity - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * _.min(users, function(chr) { - * return chr.age; - * }); - * // => { 'user': 'barney', 'age': 36 }; - * - * // using the `_.property` callback shorthand - * _.min(users, 'age'); - * // => { 'user': 'barney', 'age': 36 }; - */ - var min = createExtremum(arrayMin, true); - /** * Creates an array of elements split into two groups, the first of which * contains elements `predicate` returns truthy for, while the second of which @@ -11178,24 +11080,128 @@ } /** - * Calculates the sum of an array of numbers. + * Gets the maximum value of `collection`. If `collection` is empty or falsey + * `-Infinity` is returned. If an iteratee function is provided it is invoked + * for each value in `collection` to generate the criterion by which the value + * is ranked. The `iteratee` is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. * * @static * @memberOf _ * @category Math - * @param {number} array The numbers to add. - * @returns {number} Returns the sum. + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the maximum value. + * @example + * + * _.max([4, 2, 8, 6]); + * // => 8 + * + * _.max([]); + * // => -Infinity + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * _.max(users, function(chr) { + * return chr.age; + * }); + * // => { 'user': 'fred', 'age': 40 }; + * + * // using the `_.property` callback shorthand + * _.max(users, 'age'); + * // => { 'user': 'fred', 'age': 40 }; + */ + var max = createExtremum(arrayMax); + + /** + * Gets the minimum value of `collection`. If `collection` is empty or falsey + * `Infinity` is returned. If an iteratee function is provided it is invoked + * for each value in `collection` to generate the criterion by which the value + * is ranked. The `iteratee` is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Math + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the minimum value. + * @example + * + * _.min([4, 2, 8, 6]); + * // => 2 + * + * _.min([]); + * // => Infinity + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * _.min(users, function(chr) { + * return chr.age; + * }); + * // => { 'user': 'barney', 'age': 36 }; + * + * // using the `_.property` callback shorthand + * _.min(users, 'age'); + * // => { 'user': 'barney', 'age': 36 }; + */ + var min = createExtremum(arrayMin, true); + + /** + * Gets the sum of `collection` values. + * + * @static + * @memberOf _ + * @category Math + * @param {Array|Object|string} collection The collection to iterate over. + * @returns {number} Returns the sum of values. * @example * * _.sum([4, 6, 2]); * // => 12 + * + * _.sum({ 'a': 4, 'b': 6, 'c': 2 }); + * // => 12 */ - function sum(array) { - var length = array ? array.length : 0, + function sum(collection) { + if (!isArray(collection)) { + collection = toIterable(collection); + } + var length = collection.length, result = 0; while (length--) { - result += array[length]; + result += +collection[length] || 0; } return result; } diff --git a/test/test.js b/test/test.js index 294e2a2986..996b9ca95b 100644 --- a/test/test.js +++ b/test/test.js @@ -9648,7 +9648,7 @@ (function() { test('should return the largest value from a collection', 1, function() { - strictEqual(3, _.max([1, 2, 3])); + strictEqual(_.max([1, 2, 3]), 3); }); test('should return `-Infinity` for empty collections', 1, function() { @@ -10067,7 +10067,7 @@ (function() { test('should return the smallest value from a collection', 1, function() { - strictEqual(1, _.min([1, 2, 3])); + strictEqual(_.min([1, 2, 3]), 1); }); test('should return `Infinity` for empty collections', 1, function() { @@ -13340,7 +13340,7 @@ (function() { test('should return the sum of an array of numbers', 1, function() { - equal(_.sum([6, 4, 2]), 12); + strictEqual(_.sum([6, 4, 2]), 12); }); test('should return `0` when passing empty `array` values', 1, function() { @@ -13352,6 +13352,20 @@ deepEqual(actual, expected); }); + + test('should coerce values to numbers and `NaN` to `0`', 1, function() { + strictEqual(_.sum(['1', NaN, '2']), 3); + }); + + test('should iterate an object', 1, function() { + strictEqual(_.sum({ 'a': 1, 'b': 2, 'c': 3 }), 6); + }); + + test('should iterate a string', 2, function() { + _.each(['123', Object('123')], function(value) { + strictEqual(_.sum(value), 6); + }); + }); }()); /*--------------------------------------------------------------------------*/ From 73c48292550f9b6e290e71bb4334f5accb7de002 Mon Sep 17 00:00:00 2001 From: Mohsen Azimi Date: Fri, 27 Feb 2015 10:06:42 -0800 Subject: [PATCH 11/46] Escape the backtick in `_.escape` docs. [ci skip] --- doc/README.md | 2 +- lodash.src.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/README.md b/doc/README.md index 2c1ad3b95c..2cff32f3f6 100644 --- a/doc/README.md +++ b/doc/README.md @@ -5999,7 +5999,7 @@ _.endsWith('abc', 'b', 2); ### `_.escape([string=''])` # [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9925 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escape "See the npm package") -Converts the characters "&", "<", ">", '"', "'", and '`', in `string` to +Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to their corresponding HTML entities.

diff --git a/lodash.src.js b/lodash.src.js index 5dd22deb6d..d964c83368 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -9793,7 +9793,7 @@ } /** - * Converts the characters "&", "<", ">", '"', "'", and '`', in `string` to + * Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to * their corresponding HTML entities. * * **Note:** No other characters are escaped. To escape additional characters From 584da3c39b9e4c3c76419f154171f0674e375881 Mon Sep 17 00:00:00 2001 From: h7lin Date: Fri, 27 Feb 2015 18:04:14 +0800 Subject: [PATCH 12/46] Fix doc example in `_.findLastIndex`. [ci skip] --- lodash.src.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index d964c83368..a32c147ca0 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -4596,7 +4596,7 @@ * * // using the `_.matchesProperty` callback shorthand * _.findLastIndex(users, 'active', false); - * // => 1 + * // => 2 * * // using the `_.property` callback shorthand * _.findLastIndex(users, 'active'); From 973038da6a080263a6347ee75362541e004bdcfe Mon Sep 17 00:00:00 2001 From: jdalton Date: Fri, 27 Feb 2015 20:52:10 -0800 Subject: [PATCH 13/46] Optimize `baseIndexOf`, `indexOfNaN`, and `baseFlatten`. --- lodash.src.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index a32c147ca0..1630d1b669 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -320,7 +320,7 @@ if (value !== value) { return indexOfNaN(array, fromIndex); } - var index = (fromIndex || 0) - 1, + var index = fromIndex == null ? -1 : (fromIndex - 1), length = array.length; while (++index < length) { @@ -514,7 +514,7 @@ */ function indexOfNaN(array, fromIndex, fromRight) { var length = array.length, - index = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1); + index = fromIndex == null ? (fromRight ? length : -1) : (fromIndex + (fromRight ? 0 : -1)); while ((fromRight ? index-- : ++index < length)) { var other = array[index]; @@ -2143,7 +2143,7 @@ * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, isDeep, isStrict, fromIndex) { - var index = (fromIndex || 0) - 1, + var index = fromIndex == null ? -1 : (fromIndex - 1), length = array.length, resIndex = -1, result = []; From 132aacee89bf3087822439ef64c6cbd0c9c94358 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sat, 28 Feb 2015 10:11:26 -0800 Subject: [PATCH 14/46] Optimize lazy evaluation for 1 param. --- lodash.src.js | 46 ++++++++++++++++++++-------------------------- test/test.js | 12 ++++++------ 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 1630d1b669..0cd26add28 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -34,9 +34,10 @@ HOT_SPAN = 16; /** Used to indicate the type of lazy iteratees. */ - var LAZY_FILTER_FLAG = 0, - LAZY_MAP_FLAG = 1, - LAZY_WHILE_FLAG = 2; + var LAZY_DROP_WHILE_FLAG = 0, + LAZY_FILTER_FLAG = 1, + LAZY_MAP_FLAG = 2, + LAZY_TAKE_WHILE_FLAG = 3; /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; @@ -1292,16 +1293,22 @@ while (++iterIndex < iterLength) { var data = iteratees[iterIndex], iteratee = data.iteratee, - computed = iteratee(value, index, array), type = data.type; + if (type != LAZY_DROP_WHILE_FLAG) { + var computed = iteratee(value); + } else { + data.done = data.done && (isRight ? index < data.index : index > data.index); + data.index = index; + computed = data.done || (data.done = !iteratee(value)); + } if (type == LAZY_MAP_FLAG) { value = computed; } else if (!computed) { - if (type == LAZY_FILTER_FLAG) { - continue outer; - } else { + if (type == LAZY_TAKE_WHILE_FLAG) { break outer; + } else { + continue outer; } } } @@ -11482,15 +11489,15 @@ }); // Add `LazyWrapper` methods that accept an `iteratee` value. - arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { - var isFilter = index == LAZY_FILTER_FLAG || index == LAZY_WHILE_FLAG; + arrayEach(['dropWhile', 'filter', 'map', 'takeWhile'], function(methodName, type) { + var isFilter = type != LAZY_MAP_FLAG; LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { var result = this.clone(), iteratees = result.__iteratees__ || (result.__iteratees__ = []); result.__filtered__ = result.__filtered__ || isFilter; - iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 1), 'type': index }); + iteratees.push({ 'done': false, 'index': 0, 'iteratee': getCallback(iteratee, thisArg, 1), 'type': type }); return result; }; }); @@ -11555,23 +11562,10 @@ return this.filter(identity); }; - LazyWrapper.prototype.dropWhile = function(predicate, thisArg) { - var done, - lastIndex, - isRight = this.__dir__ < 0; - - predicate = getCallback(predicate, thisArg, 1); - return this.filter(function(value, index, array) { - done = done && (isRight ? index < lastIndex : index > lastIndex); - lastIndex = index; - return done || (done = !predicate(value, index, array)); - }); - }; - LazyWrapper.prototype.reject = function(predicate, thisArg) { predicate = getCallback(predicate, thisArg, 1); - return this.filter(function(value, index, array) { - return !predicate(value, index, array); + return this.filter(function(value) { + return !predicate(value); }); }; @@ -11593,7 +11587,7 @@ // Add `LazyWrapper` methods to `lodash.prototype`. baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName], - checkIteratee = /(?:filter|map|reject|While)/.test(methodName), + checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), retUnwrapped = /^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { diff --git a/test/test.js b/test/test.js index 996b9ca95b..455b9d4ae8 100644 --- a/test/test.js +++ b/test/test.js @@ -3994,7 +3994,7 @@ args = slice.call(arguments); }).value(); - deepEqual(args, [16, 3, array]); + deepEqual(args, [16]); _(array).map(square).dropRightWhile(function() { args = slice.call(arguments); @@ -4095,7 +4095,7 @@ args = slice.call(arguments); }).value(); - deepEqual(args, [1, 0, array]); + deepEqual(args, [1]); _(array).map(square).dropWhile(function() { args = slice.call(arguments); @@ -4929,7 +4929,7 @@ args = slice.call(arguments); }).value(); - deepEqual(args, [16, 3, array]); + deepEqual(args, [16]); _(array).map(square).takeRightWhile(function() { args = slice.call(arguments); @@ -5029,7 +5029,7 @@ args = slice.call(arguments); }).value(); - deepEqual(args, [1, 0, array]); + deepEqual(args, [1]); _(array).map(square).takeWhile(function() { args = slice.call(arguments); @@ -9199,7 +9199,7 @@ args || (args = slice.call(arguments)); }).value(); - deepEqual(args, [1, 0, array]); + deepEqual(args, [1]); args = null; _(array).map(square).map(function() { @@ -12186,7 +12186,7 @@ args || (args = slice.call(arguments)); }).value(); - deepEqual(args, [1, 0, array]); + deepEqual(args, [1]); args = null; _(array).map(square)[methodName](function() { From 63d5a3acbce20395475846a367d30669428a4f22 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sat, 28 Feb 2015 12:42:14 -0800 Subject: [PATCH 15/46] Optimize `baseIndexOf` more consistently. --- lodash.src.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 0cd26add28..aee2483263 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -314,14 +314,14 @@ * @private * @param {Array} array The array to search. * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. + * @param {number} fromIndex The index to search from. * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { if (value !== value) { return indexOfNaN(array, fromIndex); } - var index = fromIndex == null ? -1 : (fromIndex - 1), + var index = fromIndex - 1, length = array.length; while (++index < length) { @@ -509,13 +509,13 @@ * * @private * @param {Array} array The array to search. - * @param {number} [fromIndex] The index to search from. + * @param {number} fromIndex The index to search from. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {number} Returns the index of the matched `NaN`, else `-1`. */ function indexOfNaN(array, fromIndex, fromRight) { var length = array.length, - index = fromIndex == null ? (fromRight ? length : -1) : (fromIndex + (fromRight ? 0 : -1)); + index = fromIndex + (fromRight ? 0 : -1); while ((fromRight ? index-- : ++index < length)) { var other = array[index]; @@ -1991,7 +1991,7 @@ } result.push(value); } - else if (indexOf(values, value) < 0) { + else if (indexOf(values, value, 0) < 0) { result.push(value); } } @@ -2817,7 +2817,7 @@ } result.push(value); } - else if (indexOf(seen, computed) < 0) { + else if (indexOf(seen, computed, 0) < 0) { if (iteratee || isLarge) { seen.push(computed); } @@ -4725,14 +4725,14 @@ return -1; } if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; } else if (fromIndex) { var index = binaryIndex(array, value), other = array[index]; return (value === value ? value === other : other !== other) ? index : -1; } - return baseIndexOf(array, value, fromIndex); + return baseIndexOf(array, value, fromIndex || 0); } /** @@ -4795,11 +4795,11 @@ outer: while (++index < length) { value = array[index]; - if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value)) < 0) { + if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { argsIndex = argsLength; while (--argsIndex) { var cache = caches[argsIndex]; - if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) { + if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value, 0)) < 0) { continue outer; } } From d860cf834d0c23a37c1bc9f5099b0d3e0f099b1f Mon Sep 17 00:00:00 2001 From: jdalton Date: Sat, 28 Feb 2015 19:18:38 -0800 Subject: [PATCH 16/46] Avoid testing the minified build on PRs in travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index feeb737a0f..f068968fd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,7 +62,7 @@ script: - "[ $ISTANBUL == false ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || (cat ./coverage/lcov.info | coveralls)" - "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || cd ./test" - "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || $BIN $OPTION ./test.js ../lodash.$BUILD.js" - - "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || $BIN $OPTION ./test.js ../lodash.$BUILD.min.js" + - "[ $SAUCE_LABS == true ] || [ $ISTANBUL == true ] || [ $TRAVIS_SECURE_ENV_VARS == false ] || $BIN $OPTION ./test.js ../lodash.$BUILD.min.js" - "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.js&noglobals=true\" tags=\"$BUILD,development\"" - "[ $SAUCE_LABS == false ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.min.js&noglobals=true\" tags=\"$BUILD,production\"" - "[ $SAUCE_LABS == false ] || [ $BUILD != 'compat' ] || $BIN ./test/saucelabs.js name=\"lodash tests\" runner=\"test/index.html?build=../lodash.$BUILD.js\" tags=\"$BUILD,development,ie-compat\" compatMode=7" From 1af8b9d16a196ff24d6c76e9336471ab1b198ab4 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sat, 28 Feb 2015 21:12:10 -0800 Subject: [PATCH 17/46] Cleanup docs of `_.flow`, `_.flowRight`, `_.defaults`, `_.range`, `_.inRange`, & `_.sum`. [ci skip] --- lodash.src.js | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index aee2483263..b7c00fc2b5 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -7500,15 +7500,11 @@ * @returns {Function} Returns the new function. * @example * - * function add(x, y) { - * return x + y; - * } - * * function square(n) { * return n * n; * } * - * var addSquare = _.flow(add, square); + * var addSquare = _.flow(_.add, square); * addSquare(1, 2); * // => 9 */ @@ -7545,15 +7541,11 @@ * @returns {Function} Returns the new function. * @example * - * function add(x, y) { - * return x + y; - * } - * * function square(n) { * return n * n; * } * - * var addSquare = _.flowRight(square, add); + * var addSquare = _.flowRight(square, _.add); * addSquare(1, 2); * // => 9 */ @@ -8783,7 +8775,7 @@ /** * Assigns own enumerable properties of source object(s) to the destination * object for all destination properties that resolve to `undefined`. Once a - * property is set, additional defaults of the same property are ignored. + * property is set, additional values of the same property are ignored. * * @static * @memberOf _ @@ -9602,7 +9594,7 @@ /** * 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`. + * `end` is not specified it is set to `start` with `start` then set to `0`. * * @static * @memberOf _ @@ -10939,9 +10931,9 @@ /** * Creates an array of numbers (positive and/or negative) progressing from - * `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. + * `start` up to, but not including, `end`. If `end` is not specified it is + * set to `start` with `start` then set to `0`. If `start` is less than `end` + * a zero-length range is created unless a negative `step` is specified. * * @static * @memberOf _ @@ -11185,13 +11177,13 @@ var min = createExtremum(arrayMin, true); /** - * Gets the sum of `collection` values. + * Gets the sum of the values in `collection`. * * @static * @memberOf _ * @category Math * @param {Array|Object|string} collection The collection to iterate over. - * @returns {number} Returns the sum of values. + * @returns {number} Returns the sum. * @example * * _.sum([4, 6, 2]); From c15d81545a7a51782ff39c0865b8b7d6642619d7 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sat, 28 Feb 2015 21:51:24 -0800 Subject: [PATCH 18/46] Update chalk in travis. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f068968fd5..c2a8df8fa1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ 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.6.0\" request@\"^2.0.0\" sauce-tunnel@\"2.2.2\"" + - "[ $SAUCE_LABS == false ] || npm i chalk@\"^1.0.0\" 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)" From ec1be41b62a674eee1288c881efe8736ec87149b Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 1 Mar 2015 01:07:33 -0800 Subject: [PATCH 19/46] Correct `_.flatten` benchmark. --- perf/perf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perf/perf.js b/perf/perf.js index 3031301c09..5e606a17c8 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -412,7 +412,7 @@ }\ if (typeof flatten != "undefined") {\ var _flattenDeep = _.flatten([[1]])[0] !== 1,\ - lodashFlattenDeep = lodash.flatten([[1]]) !== 1;\ + lodashFlattenDeep = lodash.flatten([[1]])[0] !== 1;\ }\ if (typeof isEqual != "undefined") {\ var objectOfPrimitives = {\ From 3aa40d4df64c27fb71bf8c0cd2ee4b336ddd9d31 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 1 Mar 2015 01:22:00 -0800 Subject: [PATCH 20/46] Simplify `baseFlatten` and always provide a `fromIndex`. --- lodash.src.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index b7c00fc2b5..cecf663867 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2144,13 +2144,13 @@ * * @private * @param {Array} array The array to flatten. - * @param {boolean} [isDeep] Specify a deep flatten. - * @param {boolean} [isStrict] Restrict flattening to arrays and `arguments` objects. - * @param {number} [fromIndex=0] The index to start from. + * @param {boolean} isDeep Specify a deep flatten. + * @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects. + * @param {number} fromIndex The index to start from. * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, isDeep, isStrict, fromIndex) { - var index = fromIndex == null ? -1 : (fromIndex - 1), + var index = fromIndex - 1, length = array.length, resIndex = -1, result = []; @@ -2161,7 +2161,7 @@ if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) { if (isDeep) { // Recursively flatten arrays (susceptible to call stack limits). - value = baseFlatten(value, isDeep, isStrict); + value = baseFlatten(value, isDeep, isStrict, 0); } var valIndex = -1, valLength = value.length; @@ -4666,7 +4666,7 @@ if (guard && isIterateeCall(array, isDeep, guard)) { isDeep = false; } - return length ? baseFlatten(array, isDeep) : []; + return length ? baseFlatten(array, isDeep, false, 0) : []; } /** @@ -4684,7 +4684,7 @@ */ function flattenDeep(array) { var length = array ? array.length : 0; - return length ? baseFlatten(array, true) : []; + return length ? baseFlatten(array, true, false, 0) : []; } /** @@ -5344,7 +5344,7 @@ * // => [1, 2, 4] */ function union() { - return baseUniq(baseFlatten(arguments, false, true)); + return baseUniq(baseFlatten(arguments, false, true, 0)); } /** From 4ce4f1d758cc735aa01850bbd51db9a0008cdbc4 Mon Sep 17 00:00:00 2001 From: octref Date: Fri, 27 Feb 2015 00:30:09 -0500 Subject: [PATCH 21/46] Add _.sortByOrder. --- lodash.src.js | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/test.js | 72 +++++++++++++++++++++++++++++++- 2 files changed, 182 insertions(+), 2 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index cecf663867..1b91c641c6 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -469,6 +469,46 @@ return object.index - other.index; } + /** + * Used by `_.sortByOrder` to compare multiple properties of each element + * in a collection and stable sort them in the following order: + * + * If orders is unspecified, sort in ascending order for all properties. + * Otherwise, for each property, sort in ascending order if its corresponding value in + * orders is true, and descending order if false. + * + * @private + * @param {Object} object The object to compare to `other`. + * @param {Object} other The object to compare to `object`. + * @param {boolean[]} orders The order to sort by for each property. + * @returns {number} Returns the sort order indicator for `object`. + */ + function compareMultiple(object, other, orders) { + var index = -1, + objCriteria = object.criteria, + othCriteria = other.criteria, + length = objCriteria.length; + + while (++index < length) { + var result = baseCompareAscending(objCriteria[index], othCriteria[index]); + if (result) { + if (typeof orders[index] != 'boolean') { + return result; + } else { + return orders[index] ? result : -1 * result; + } + } + } + // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications + // that causes it, under certain circumstances, to provide the same value for + // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 + // for more details. + // + // This also ensures a stable sort in V8 and other engines. + // See https://code.google.com/p/v8/issues/detail?id=90 for more details. + return object.index - other.index; + } + /** * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters. * @@ -6880,6 +6920,77 @@ return baseSortBy(result, compareMultipleAscending); } + /** + * This method is like `_.sortByAll` except that it takes an optional + * `orders` which can be used to specify sorting orders. + * + * Sort ascendingly for properties that don't have a corresponding order in `orders`. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {string|string[]} props The property names to sort by, + * specified as individual property names or arrays of property names. + * @param {boolean|boolean[]} orders The orders to sort by. + * When not specified, default to true, which sort ascendingly. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'barney', 'age': 26 }, + * { 'user': 'fred', 'age': 30 } + * ]; + * + * // Sort by `user` ascendingly + * _.map(_.sortByOrder(users, 'user'), _.values) + * _.map(_.sortByOrder(users, ['user']), _.values) + * _.map(_.sortByOrder(users, 'user', true), _.values) + * // => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]] + * + * // Sort by 'user' descendingly + * _.map(_.sortByOrder(users, ['user'], [false]), _.values); + * // => [['fred', 40], ['fred', 30], ['barney', 36], ['barney', 26]] + * + * // Same as _.sortByAll(users, ['user', 'age']) + * _.map(_.sortByOrder(users, ['user', 'age']), _.values); + * // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] + * + * // Sort by user ascendingly but age descendingly + * _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values); + * // => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]] + * + * // Default to sort 'age' ascendingly + * _.map(_.sortByOrder(users, ['user', 'age'], [false]), _.values); + * // => [['fred', 30], ['fred', 40], ['barney', 26], ['barney', 36]] + */ + function sortByOrder(collection) { + var args = arguments; + + var index = -1, + length = collection ? collection.length : 0, + props = baseFlatten(args, false, false, 1), + orders = baseFlatten(args, false, false, 2), + result = isLength(length) ? Array(length) : []; + + baseEach(collection, function(value) { + var length = props.length, + criteria = Array(length); + + while (length--) { + criteria[length] = value == null + ? undefined + : value[props[length]] || value[props[length].key]; + } + result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; + }); + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } + /** * Performs a deep comparison between each element in `collection` and the * source object, returning an array of all elements that have equivalent @@ -11305,6 +11416,7 @@ lodash.slice = slice; lodash.sortBy = sortBy; lodash.sortByAll = sortByAll; + lodash.sortByOrder = sortByOrder; lodash.spread = spread; lodash.take = take; lodash.takeRight = takeRight; diff --git a/test/test.js b/test/test.js index 455b9d4ae8..b78597244b 100644 --- a/test/test.js +++ b/test/test.js @@ -13115,6 +13115,73 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.sortByOrder'); + + (function() { + function Pair(a, b, c) { + this.a = a; + this.b = b; + this.c = c; + } + + var objects = [ + { 'a': 'x', 'b': 3 }, + { 'a': 'y', 'b': 4 }, + { 'a': 'x', 'b': 1 }, + { 'a': 'y', 'b': 2 } + ]; + + var complexObjects = [ + { 'a': 'x', 'b': 3, 'c': 'bar' }, + { 'a': 'y', 'b': 4, 'c': 'foo' }, + { 'a': 'x', 'b': 1, 'c': 'foo' }, + { 'a': 'y', 'b': 2, 'c': 'bar' } + ] + + var stableOrder = [ + new Pair(1, 1, 1), new Pair(1, 2, 1), + new Pair(1, 1, 1), new Pair(1, 2, 1), + new Pair(1, 3, 1), new Pair(1, 4, 1), + new Pair(1, 5, 1), new Pair(1, 6, 1), + new Pair(2, 1, 2), new Pair(2, 2, 2), + new Pair(2, 3, 2), new Pair(2, 4, 2), + new Pair(2, 5, 2), new Pair(2, 6, 2), + new Pair(undefined, 1, 1), new Pair(undefined, 2, 1), + new Pair(undefined, 3, 1), new Pair(undefined, 4, 1), + new Pair(undefined, 5, 1), new Pair(undefined, 6, 1) + ]; + + test('should sort mutliple properties in ascending order by default', 1, function() { + var actual = _.sortByOrder(objects, ['a', 'b']); + deepEqual(actual, _.at(objects, [2, 0, 3, 1])); + }); + + test('should sort multiple properties depending on specified orders', 1, function() { + var actual = _.sortByOrder(complexObjects, ['a', 'b'], [false, true]); + deepEqual(actual, _.at(complexObjects, [3, 1, 2, 0])); + }); + + test('should sort ascendingly for property not specified', 1, function() { + var actual = _.sortByOrder(complexObjects, ['a', 'c'], [false]); + deepEqual(actual, _.at(complexObjects, [3, 1, 0, 2])); + }); + + test('should perform a stable sort (test in IE > 8, Opera, and V8)', 1, function() { + var actual = _.sortByOrder(stableOrder, ['a', 'c']); + deepEqual(actual, stableOrder); + }); + + test('should not error on nullish elements', 1, function() { + try { + var actual = _.sortByOrder(objects.concat(undefined), ['a', 'b']); + } catch(e) {} + + deepEqual(actual, [objects[2], objects[0], objects[3], objects[1], undefined]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('sortedIndex methods'); _.each(['sortedIndex', 'sortedLastIndex'], function(methodName) { @@ -16119,6 +16186,7 @@ 'shuffle', 'sortBy', 'sortByAll', + 'sortByOrder', 'take', 'times', 'toArray', @@ -16133,7 +16201,7 @@ var acceptFalsey = _.difference(allMethods, rejectFalsey); - test('should accept falsey arguments', 211, function() { + test('should accept falsey arguments', 213, function() { var emptyArrays = _.map(falsey, _.constant([])), isExposed = '_' in root, oldDash = root._; @@ -16175,7 +16243,7 @@ }); }); - test('should return an array', 70, function() { + test('should return an array', 72, function() { var array = [1, 2, 3]; _.each(returnArrays, function(methodName) { From ec8d919b93c860d73b4e2775e6b8a13754231be9 Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 2 Mar 2015 09:17:16 -0800 Subject: [PATCH 22/46] Cleanup . --- lodash.src.js | 204 ++++++++++++++++++++------------------------------ 1 file changed, 83 insertions(+), 121 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 1b91c641c6..df06738d7a 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -346,26 +346,6 @@ 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 - * corresponding values. - * - * @private - * @param {Array} array The array to sort. - * @param {Function} comparer The function to define sort order. - * @returns {Array} Returns `array`. - */ - function baseSortBy(array, comparer) { - var length = array.length; - - array.sort(comparer); - while (length--) { - array[length] = array[length].value; - } - return array; - } - /** * Converts `value` to a string if it is not one. An empty string is returned * for `null` or `undefined` values. @@ -438,37 +418,6 @@ return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index); } - /** - * Used by `_.sortByAll` to compare multiple properties of each element - * in a collection and stable sort them in ascending order. - * - * @private - * @param {Object} object The object to compare to `other`. - * @param {Object} other The object to compare to `object`. - * @returns {number} Returns the sort order indicator for `object`. - */ - function compareMultipleAscending(object, other) { - var index = -1, - objCriteria = object.criteria, - othCriteria = other.criteria, - length = objCriteria.length; - - while (++index < length) { - var result = baseCompareAscending(objCriteria[index], othCriteria[index]); - if (result) { - return result; - } - } - // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications - // that causes it, under certain circumstances, to provide the same value for - // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 - // for more details. - // - // This also ensures a stable sort in V8 and other engines. - // See https://code.google.com/p/v8/issues/detail?id=90 for more details. - return object.index - other.index; - } - /** * Used by `_.sortByOrder` to compare multiple properties of each element * in a collection and stable sort them in the following order: @@ -476,7 +425,7 @@ * If orders is unspecified, sort in ascending order for all properties. * Otherwise, for each property, sort in ascending order if its corresponding value in * orders is true, and descending order if false. - * + * * @private * @param {Object} object The object to compare to `other`. * @param {Object} other The object to compare to `object`. @@ -487,15 +436,16 @@ var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, - length = objCriteria.length; + length = objCriteria.length, + ordersLength = orders.length; while (++index < length) { var result = baseCompareAscending(objCriteria[index], othCriteria[index]); if (result) { - if (typeof orders[index] != 'boolean') { + if (index >= ordersLength) { return result; } else { - return orders[index] ? result : -1 * result; + return orders[index] ? result : result * -1; } } } @@ -2815,6 +2765,55 @@ return !!result; } + /** + * The base implementation of `_.sortBy` which uses `comparer` to define + * the sort order of `array` and replaces criteria objects with their + * corresponding values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ + function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + + /** + * The base implementation of `_.sortByOrder` without param guards. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {string[]} props The property names to sort by. + * @param {boolean[]} orders The sort orders of `props`. + * @returns {Array} Returns the new sorted array. + */ + function baseSortByOrder(collection, props, orders) { + var index = -1, + length = collection.length, + result = isLength(length) ? Array(length) : []; + + baseEach(collection, function(value) { + var length = props.length, + criteria = Array(length); + + while (length--) { + criteria[length] = value == null ? undefined : value[props[length]]; + } + result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } + /** * The base implementation of `_.uniq` without support for callback shorthands * and `this` binding. @@ -6861,8 +6860,11 @@ * // => ['barney', 'fred', 'pebbles'] */ function sortBy(collection, iteratee, thisArg) { + if (collection == null) { + return []; + } var index = -1, - length = collection ? collection.length : 0, + length = collection.length, result = isLength(length) ? Array(length) : []; if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { @@ -6899,41 +6901,28 @@ * // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ function sortByAll(collection) { + if (collection == null) { + return []; + } var args = arguments; if (args.length > 3 && isIterateeCall(args[1], args[2], args[3])) { args = [collection, args[1]]; } - var index = -1, - length = collection ? collection.length : 0, - props = baseFlatten(args, false, false, 1), - result = isLength(length) ? Array(length) : []; - - baseEach(collection, function(value) { - var length = props.length, - criteria = Array(length); - - while (length--) { - criteria[length] = value == null ? undefined : value[props[length]]; - } - result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; - }); - return baseSortBy(result, compareMultipleAscending); + return baseSortByOrder(collection, baseFlatten(args, false, false, 1), []); } /** - * This method is like `_.sortByAll` except that it takes an optional - * `orders` which can be used to specify sorting orders. + * This method is like `_.sortByAll` except that it allows specifying the + * sort orders of the property names to sort by. A truthy value in `orders` + * will sort the corresponding property name in ascending order while a + * falsey value will sort it in descending order. * - * Sort ascendingly for properties that don't have a corresponding order in `orders`. - * * @static * @memberOf _ * @category Collection * @param {Array|Object|string} collection The collection to iterate over. - * @param {string|string[]} props The property names to sort by, - * specified as individual property names or arrays of property names. - * @param {boolean|boolean[]} orders The orders to sort by. - * When not specified, default to true, which sort ascendingly. + * @param {string[]} props The property names to sort by. + * @param {boolean[]} orders The sort orders of `props`. * @returns {Array} Returns the new sorted array. * @example * @@ -6944,51 +6933,24 @@ * { 'user': 'fred', 'age': 30 } * ]; * - * // Sort by `user` ascendingly - * _.map(_.sortByOrder(users, 'user'), _.values) - * _.map(_.sortByOrder(users, ['user']), _.values) - * _.map(_.sortByOrder(users, 'user', true), _.values) - * // => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]] - * - * // Sort by 'user' descendingly - * _.map(_.sortByOrder(users, ['user'], [false]), _.values); - * // => [['fred', 40], ['fred', 30], ['barney', 36], ['barney', 26]] - * - * // Same as _.sortByAll(users, ['user', 'age']) - * _.map(_.sortByOrder(users, ['user', 'age']), _.values); - * // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] - * - * // Sort by user ascendingly but age descendingly + * // sort by `user` in ascending order and by `age` in descending order * _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values); * // => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]] - * - * // Default to sort 'age' ascendingly - * _.map(_.sortByOrder(users, ['user', 'age'], [false]), _.values); - * // => [['fred', 30], ['fred', 40], ['barney', 26], ['barney', 36]] */ - function sortByOrder(collection) { - var args = arguments; - - var index = -1, - length = collection ? collection.length : 0, - props = baseFlatten(args, false, false, 1), - orders = baseFlatten(args, false, false, 2), - result = isLength(length) ? Array(length) : []; - - baseEach(collection, function(value) { - var length = props.length, - criteria = Array(length); - - while (length--) { - criteria[length] = value == null - ? undefined - : value[props[length]] || value[props[length].key]; - } - result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; - }); - return baseSortBy(result, function(object, other) { - return compareMultiple(object, other, orders); - }); + function sortByOrder(collection, props, orders, guard) { + if (collection == null) { + return []; + } + if (guard && isIterateeCall(props, orders, guard)) { + orders = null; + } + if (!isArray(props)) { + props = props == null ? [] : [props]; + } + if (!isArray(orders)) { + orders = orders == null ? [] : [orders]; + } + return baseSortByOrder(collection, props, orders); } /** From d192e69811b88e97de153a1c971c57b59e99ada5 Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 2 Mar 2015 09:19:05 -0800 Subject: [PATCH 23/46] Break lazy chains before or . [closes #1011] --- lodash.src.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index df06738d7a..39eadce42c 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -11556,10 +11556,11 @@ // Add `LazyWrapper` methods that accept an `iteratee` value. arrayEach(['dropWhile', 'filter', 'map', 'takeWhile'], function(methodName, type) { - var isFilter = type != LAZY_MAP_FLAG; + var isFilter = type != LAZY_MAP_FLAG, + isWhile = type == LAZY_DROP_WHILE_FLAG || type == LAZY_TAKE_WHILE_FLAG; LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { - var result = this.clone(), + var result = isWhile ? new LazyWrapper(this) : this.clone(), iteratees = result.__iteratees__ || (result.__iteratees__ = []); result.__filtered__ = result.__filtered__ || isFilter; @@ -11657,12 +11658,16 @@ retUnwrapped = /^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { - var value = this.__wrapped__, - args = arguments, + var length = arguments.length, + args = Array(length), chainAll = this.__chain__, + value = this.__wrapped__, isHybrid = !!this.__actions__.length, isLazy = value instanceof LazyWrapper; + while (length--) { + args[length] = arguments[length]; + } if (isLazy && checkIteratee) { // avoid lazy use if the iteratee has a `length` other than `1` var iteratee = args[0]; From aad0070b77b82c160ff729728814f120ca8eab43 Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 2 Mar 2015 11:40:01 -0800 Subject: [PATCH 24/46] Narrow `new LodashWrapper` to `dropWhile`. --- lodash.src.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 39eadce42c..0e4e52d183 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -11557,13 +11557,14 @@ // Add `LazyWrapper` methods that accept an `iteratee` value. arrayEach(['dropWhile', 'filter', 'map', 'takeWhile'], function(methodName, type) { var isFilter = type != LAZY_MAP_FLAG, - isWhile = type == LAZY_DROP_WHILE_FLAG || type == LAZY_TAKE_WHILE_FLAG; + isDropWhile = type == LAZY_DROP_WHILE_FLAG; LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { - var result = isWhile ? new LazyWrapper(this) : this.clone(), + var filtered = this.__filtered__, + result = (filtered && isDropWhile) ? new LazyWrapper(this) : this.clone(), iteratees = result.__iteratees__ || (result.__iteratees__ = []); - result.__filtered__ = result.__filtered__ || isFilter; + result.__filtered__ = filtered || isFilter; iteratees.push({ 'done': false, 'index': 0, 'iteratee': getCallback(iteratee, thisArg, 1), 'type': type }); return result; }; From ba9bd3bc764a8cc9ecde4332134aa52ec8c38310 Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 2 Mar 2015 20:21:40 -0800 Subject: [PATCH 25/46] Better match words with one character. [closes #1012] --- lodash.src.js | 2 +- test/test.js | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 0e4e52d183..7e735874d7 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -131,7 +131,7 @@ var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]', lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+'; - return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); + return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); }()); /** Used to detect and test for whitespace. */ diff --git a/test/test.js b/test/test.js index b78597244b..6843ce6e9b 100644 --- a/test/test.js +++ b/test/test.js @@ -1659,7 +1659,7 @@ deepEqual(actual, _.map(burredLetters, _.constant(true))); }); - test('should trim latin-1 mathematical operators', 1, function() { + test('`_.' + methodName + '` should trim latin-1 mathematical operators', 1, function() { var actual = _.map(['\xd7', '\xf7'], func); deepEqual(actual, ['', '']); }); @@ -1689,12 +1689,25 @@ }); }); + (function() { + test('should get the original value after cycling through all case methods', 1, function() { + var funcs = [_.camelCase, _.kebabCase, _.snakeCase, _.startCase, _.camelCase]; + + var actual = _.reduce(funcs, function(result, func) { + return func(result); + }, 'enable 24h format'); + + strictEqual(actual, 'enable24HFormat'); + }); + }()); + /*--------------------------------------------------------------------------*/ QUnit.module('lodash.camelCase'); (function() { - test('should work with numbers', 3, function() { + test('should work with numbers', 4, function() { + strictEqual(_.camelCase('enable 24h format'), 'enable24HFormat'); strictEqual(_.camelCase('too legit 2 quit'), 'tooLegit2Quit'); strictEqual(_.camelCase('walk 500 miles'), 'walk500Miles'); strictEqual(_.camelCase('xhr2 request'), 'xhr2Request'); @@ -15211,10 +15224,15 @@ }); test('should work with compound words', 6, function() { - deepEqual(_.words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']); deepEqual(_.words('aeiouAreVowels'), ['aeiou', 'Are', 'Vowels']); - deepEqual(_.words('aeiou2Consonants'), ['aeiou', '2', 'Consonants']); + deepEqual(_.words('enable 24h format'), ['enable', '24', 'h', 'format']); + deepEqual(_.words('LETTERSAeiouAreVowels'), ['LETTERS', 'Aeiou', 'Are', 'Vowels']); + deepEqual(_.words('tooLegit2Quit'), ['too', 'Legit', '2', 'Quit']); + deepEqual(_.words('walk500Miles'), ['walk', '500', 'Miles']); + deepEqual(_.words('xhr2Request'), ['xhr', '2', 'Request']); + }); + test('should work with compound words containing diacritical marks', 3, function() { deepEqual(_.words('LETTERSÆiouAreVowels'), ['LETTERS', 'Æiou', 'Are', 'Vowels']); deepEqual(_.words('æiouAreVowels'), ['æiou', 'Are', 'Vowels']); deepEqual(_.words('æiou2Consonants'), ['æiou', '2', 'Consonants']); From 9a8345d4f9f73e3fd38f021a5b6fe90d367a71ab Mon Sep 17 00:00:00 2001 From: h7lin Date: Tue, 3 Mar 2015 11:59:00 +0800 Subject: [PATCH 26/46] Fix doc example in `_.partition`. [ci skip] --- lodash.src.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index 7e735874d7..1d0edab40f 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -6489,7 +6489,7 @@ * _.partition([1.2, 2.3, 3.4], function(n) { * return this.floor(n) % 2; * }, Math); - * // => [[1, 3], [2]] + * // => [[1.2, 3.4], [2.3]] * * var users = [ * { 'user': 'barney', 'age': 36, 'active': false }, From 913778d5ab25039f5838cf6359516fdb61d9f09f Mon Sep 17 00:00:00 2001 From: octref Date: Tue, 3 Mar 2015 00:00:09 -0500 Subject: [PATCH 27/46] Let `createAssigner` get correct customizer When `_.defaults` is invoked using `_.reduce` / `_.reduceRight` `createAssigner` discards the customizer, so the effect is `_.assign` but not `_.defaults` ``` _.reduce([{ 'user': 'barney' }, { 'user': 'fred' }], _.defaults) // -> {user: "fred"} _.reduceRight([{ 'user': 'barney' }, { 'user': 'fred' }], _.defaults) // -> {user: "barney"} // Fixed _.reduce([{ 'user': 'barney' }, { 'user': 'fred' }], _.defaults) // -> {user: "barney"} _.reduceRight([{ 'user': 'barney' }, { 'user': 'fred' }], _.defaults) // -> {user: "fred"} ``` --- lodash.src.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lodash.src.js b/lodash.src.js index 1d0edab40f..1c9cd2c1e0 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -3167,6 +3167,9 @@ return object; } if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) { + if (typeof arguments[length - 1] == 'function') { + customizer = arguments[--length]; + } length = 2; } // Juggle arguments. From 5991068fdfe8f2e884f16d546ccbfbe69f17a5f3 Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 2 Mar 2015 21:22:13 -0800 Subject: [PATCH 28/46] Add more lazy chaining tests. --- test/test.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test.js b/test/test.js index 6843ce6e9b..1edefc2717 100644 --- a/test/test.js +++ b/test/test.js @@ -4087,6 +4087,16 @@ } }); + test('should work in a lazy chain sequence with `drop`', 1, function() { + var actual = _(array) + .dropWhile(function(num) { return num == 1; }) + .drop() + .dropWhile(function(num) { return num == 3; }) + .value(); + + deepEqual(actual, [4]); + }); + test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { if (!isNpm) { var args, @@ -5021,6 +5031,16 @@ } }); + test('should work in a lazy chain sequence with `take`', 1, function() { + var actual = _(array) + .takeWhile(function(num) { return num < 4; }) + .take(2) + .takeWhile(function(num) { return num == 1; }) + .value(); + + deepEqual(actual, [1]); + }); + test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { if (!isNpm) { var args, From cc77a36dd9c2165dc5a7742e276cb2902ed43dd3 Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 3 Mar 2015 09:16:33 -0800 Subject: [PATCH 29/46] Cleanup `createAssigner`. --- lodash.src.js | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 1c9cd2c1e0..00f5bebbc2 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -3160,27 +3160,26 @@ */ function createAssigner(assigner) { return function() { - var length = arguments.length, - object = arguments[0]; + var args = arguments, + length = args.length, + object = args[0]; if (length < 2 || object == null) { return object; } - if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) { - if (typeof arguments[length - 1] == 'function') { - customizer = arguments[--length]; - } - length = 2; + if (length > 3 && typeof args[length - 2] == 'function') { + var index = (length -= 2); + } else if (length > 2 && typeof args[length - 1] == 'function') { + index = --length; } - // Juggle arguments. - if (length > 3 && typeof arguments[length - 2] == 'function') { - var customizer = bindCallback(arguments[--length - 1], arguments[length--], 5); - } else if (length > 2 && typeof arguments[length - 1] == 'function') { - customizer = arguments[--length]; + var customizer = index && bindCallback(args[index], args[index + 1], 5); + if (length > 3 && isIterateeCall(args[1], args[2], args[3])) { + length = 2; + customizer = index === 3 ? null : customizer; } - var index = 0; + index = 0; while (++index < length) { - var source = arguments[index]; + var source = args[index]; if (source) { assigner(object, source, customizer); } From 534aeb40654eaa15f358c113484859c33d38789a Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 3 Mar 2015 09:17:45 -0800 Subject: [PATCH 30/46] Use `args` alias of `arguments` in `_.difference`, `_.pull`, & `_.memoize`. --- lodash.src.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 00f5bebbc2..71d0d622a9 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -4312,16 +4312,17 @@ * // => [1, 3] */ function difference() { - var index = -1, - length = arguments.length; + var args = arguments, + index = -1, + length = args.length; while (++index < length) { - var value = arguments[index]; + var value = args[index]; if (isArray(value) || isArguments(value)) { break; } } - return baseDifference(value, baseFlatten(arguments, false, true, ++index)); + return baseDifference(value, baseFlatten(args, false, true, ++index)); } /** @@ -4945,17 +4946,19 @@ * // => [1, 1] */ function pull() { - var array = arguments[0]; + var args = arguments, + array = args[0]; + if (!(array && array.length)) { return array; } var index = 0, indexOf = getIndexOf(), - length = arguments.length; + length = args.length; while (++index < length) { var fromIndex = 0, - value = arguments[index]; + value = args[index]; while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { splice.call(array, fromIndex, 1); @@ -7703,13 +7706,14 @@ throw new TypeError(FUNC_ERROR_TEXT); } var memoized = function() { - var cache = memoized.cache, - key = resolver ? resolver.apply(this, arguments) : arguments[0]; + var args = arguments, + cache = memoized.cache, + key = resolver ? resolver.apply(this, args) : args[0]; if (cache.has(key)) { return cache.get(key); } - var result = func.apply(this, arguments); + var result = func.apply(this, args); cache.set(key, result); return result; }; From b1366696c41acba7c9e6e458fcdc3471a7057480 Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 3 Mar 2015 09:18:17 -0800 Subject: [PATCH 31/46] Simplify guard check in `_.sortByAll`. --- lodash.src.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 71d0d622a9..20f0fd6cfb 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -6909,8 +6909,10 @@ if (collection == null) { return []; } - var args = arguments; - if (args.length > 3 && isIterateeCall(args[1], args[2], args[3])) { + var args = arguments, + guard = args[3]; + + if (guard && isIterateeCall(args[1], args[2], guard)) { args = [collection, args[1]]; } return baseSortByOrder(collection, baseFlatten(args, false, false, 1), []); From 3c99ecda60d6f8b4f4b6fc801e3c2f2aa39bd165 Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 3 Mar 2015 09:18:48 -0800 Subject: [PATCH 32/46] Move more code out of the try-block in `_.attempt`. --- lodash.src.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 20f0fd6cfb..ee05ffa873 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -10676,14 +10676,14 @@ * } */ function attempt() { - var length = arguments.length, - func = arguments[0]; + var func = arguments[0], + length = arguments.length, + args = Array(length ? length - 1 : 0); + while (--length > 0) { + args[length - 1] = arguments[length]; + } try { - 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 68f3c43805f9bd2ff8d9a26f16cee895cfee921c Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 3 Mar 2015 09:19:27 -0800 Subject: [PATCH 33/46] Add `createComposer` to reduce the definition of `_.flow` and `_.flowRight`. --- lodash.src.js | 77 +++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index ee05ffa873..fc208e5e87 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -3217,6 +3217,41 @@ return new SetCache(values); }; + /** + * Creates a function to compose other functions into a single function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new composer function. + */ + function createComposer(fromRight) { + return function() { + var length = arguments.length, + index = length, + fromIndex = fromRight ? length - 1 : 0; + + if (!length) { + return function() { return arguments[0]; }; + } + var funcs = Array(length); + while (index--) { + funcs[index] = arguments[index]; + if (typeof funcs[index] != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + } + return function() { + var index = fromIndex, + result = funcs[index].apply(this, arguments); + + while ((fromRight ? index-- : ++index < length)) { + result = funcs[index].call(this, result); + } + return result; + }; + }; + } + /** * Creates a function that produces compound words out of the words in a * given string. @@ -7588,26 +7623,7 @@ * addSquare(1, 2); * // => 9 */ - function flow() { - var funcs = arguments, - length = funcs.length; - - if (!length) { - return function() { return arguments[0]; }; - } - if (!arrayEvery(funcs, baseIsFunction)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function() { - var index = 0, - result = funcs[index].apply(this, arguments); - - while (++index < length) { - result = funcs[index].call(this, result); - } - return result; - }; - } + var flow = createComposer(); /** * This method is like `_.flow` except that it creates a function that @@ -7629,26 +7645,7 @@ * addSquare(1, 2); * // => 9 */ - function flowRight() { - var funcs = arguments, - fromIndex = funcs.length - 1; - - if (fromIndex < 0) { - return function() { return arguments[0]; }; - } - if (!arrayEvery(funcs, baseIsFunction)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function() { - var index = fromIndex, - result = funcs[index].apply(this, arguments); - - while (index--) { - result = funcs[index].call(this, result); - } - return result; - }; - } + var flowRight = createComposer(true); /** * Creates a function that memoizes the result of `func`. If `resolver` is From bbe30db1b7502e21b06daeaeeea8731542905964 Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 3 Mar 2015 12:13:31 -0800 Subject: [PATCH 34/46] Avoid test fails for npm builds. --- test/test.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/test/test.js b/test/test.js index 1edefc2717..aa44ffa5e8 100644 --- a/test/test.js +++ b/test/test.js @@ -4088,13 +4088,18 @@ }); test('should work in a lazy chain sequence with `drop`', 1, function() { - var actual = _(array) - .dropWhile(function(num) { return num == 1; }) - .drop() - .dropWhile(function(num) { return num == 3; }) - .value(); + if (!isNpm) { + var actual = _(array) + .dropWhile(function(num) { return num == 1; }) + .drop() + .dropWhile(function(num) { return num == 3; }) + .value(); - deepEqual(actual, [4]); + deepEqual(actual, [4]); + } + else { + skipTest(); + } }); test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { @@ -5032,13 +5037,18 @@ }); test('should work in a lazy chain sequence with `take`', 1, function() { - var actual = _(array) - .takeWhile(function(num) { return num < 4; }) - .take(2) - .takeWhile(function(num) { return num == 1; }) - .value(); + if (!isNpm) { + var actual = _(array) + .takeWhile(function(num) { return num < 4; }) + .take(2) + .takeWhile(function(num) { return num == 1; }) + .value(); - deepEqual(actual, [1]); + deepEqual(actual, [1]); + } + else { + skipTest(); + } }); test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { From 3a94a65f1227a7adb977b13d9c2576fdd14293c7 Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 3 Mar 2015 22:24:55 -0800 Subject: [PATCH 35/46] Tweak `root` assignment to work with webpack in a web worker. [closes ##313] --- lodash.src.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lodash.src.js b/lodash.src.js index fc208e5e87..8201fba8b9 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -275,7 +275,8 @@ /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ var freeGlobal = freeExports && freeModule && typeof global == 'object' && global; - if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { + if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || + (typeof freeGlobal.WorkerGlobalScope == 'function' && freeGlobal instanceof freeGlobal.WorkerGlobalScope))) { root = freeGlobal; } From adce718d63035232bbe82f9932fa19ecf1bcf753 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 4 Mar 2015 00:45:42 -0800 Subject: [PATCH 36/46] Another cleanup pass on `createAssigner`. --- lodash.src.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 8201fba8b9..aaae2864ab 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -3168,17 +3168,22 @@ if (length < 2 || object == null) { return object; } - if (length > 3 && typeof args[length - 2] == 'function') { - var index = (length -= 2); - } else if (length > 2 && typeof args[length - 1] == 'function') { - index = --length; + var customizer = args[length - 2], + thisArg = args[length - 1], + guard = args[3]; + + if (length > 3 && typeof customizer == 'function') { + customizer = bindCallback(customizer, thisArg, 5); + length -= 2; + } else { + customizer = (length > 2 && typeof thisArg == 'function') ? thisArg : null; + length -= (customizer ? 1 : 0); } - var customizer = index && bindCallback(args[index], args[index + 1], 5); - if (length > 3 && isIterateeCall(args[1], args[2], args[3])) { + if (guard && isIterateeCall(args[1], args[2], guard)) { + customizer = length == 3 ? null : customizer; length = 2; - customizer = index === 3 ? null : customizer; } - index = 0; + var index = 0; while (++index < length) { var source = args[index]; if (source) { From 69e9c7d0bed4b9f3ade1a2b293dc8385601c4842 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 4 Mar 2015 08:04:39 -0800 Subject: [PATCH 37/46] Expand `_.defaults` test for working with `_.reduce`. --- test/test.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index aa44ffa5e8..9a798cc2eb 100644 --- a/test/test.js +++ b/test/test.js @@ -5712,7 +5712,8 @@ QUnit.module('object assignments'); _.each(['assign', 'defaults', 'merge'], function(methodName) { - var func = _[methodName]; + var func = _[methodName], + isDefaults = methodName == 'defaults'; test('`_.' + methodName + '` should pass thru falsey `object` values', 1, function() { var actual = _.map(falsey, function(value, index) { @@ -5787,8 +5788,11 @@ }); test('`_.' + methodName + '` should work as an iteratee for `_.reduce`', 1, function() { - var array = [{ 'b': 2 }, { 'c': 3 }]; - deepEqual(_.reduce(array, func, { 'a': 1}), { 'a': 1, 'b': 2, 'c': 3 }); + var array = [{ 'a': 1 }, { 'b': 2 }, { 'c': 3 }], + expected = { 'a': 1, 'b': 2, 'c': 3 }; + + expected.a = isDefaults ? 0 : 1; + deepEqual(_.reduce(array, func, { 'a': 0 }), expected); }); test('`_.' + methodName + '` should not return the existing wrapped value when chaining', 1, function() { From ee456493c4478aab600152f66a621bf34d78368e Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 4 Mar 2015 00:46:10 -0800 Subject: [PATCH 38/46] Remove argument unrolling in `LazyWrapper` assignments. --- lodash.src.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index aaae2864ab..748fdaf7ca 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -11670,16 +11670,13 @@ retUnwrapped = /^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { - var length = arguments.length, - args = Array(length), + var args = arguments, + length = args.length, chainAll = this.__chain__, value = this.__wrapped__, isHybrid = !!this.__actions__.length, isLazy = value instanceof LazyWrapper; - while (length--) { - args[length] = arguments[length]; - } if (isLazy && checkIteratee) { // avoid lazy use if the iteratee has a `length` other than `1` var iteratee = args[0]; From 10e379d8627b387360217efd4aacd06c4e0a7700 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 4 Mar 2015 08:35:42 -0800 Subject: [PATCH 39/46] Add `_.sortByOrder` tests. --- test/test.js | 112 ++++++++++++++++----------------------------------- 1 file changed, 35 insertions(+), 77 deletions(-) diff --git a/test/test.js b/test/test.js index 9a798cc2eb..5a9fc6c140 100644 --- a/test/test.js +++ b/test/test.js @@ -13094,9 +13094,34 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.sortByAll'); + QUnit.module('lodash.sortByOrder'); (function() { + var objects = [ + { 'a': 'x', 'b': 3 }, + { 'a': 'y', 'b': 4 }, + { 'a': 'x', 'b': 1 }, + { 'a': 'y', 'b': 2 } + ]; + + test('should sort multiple properties by specified orders', 1, function() { + var actual = _.sortByOrder(objects, ['a', 'b'], [false, true]); + deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]); + }); + + test('should sort a property in ascending order when its order is not specified', 1, function() { + var actual = _.sortByOrder(objects, ['a', 'b'], [false]); + deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('sortBy methods'); + + _.each(['sortByAll', 'sortByOrder'], function(methodName) { + var func = _[methodName]; + function Pair(a, b, c) { this.a = a; this.b = b; @@ -13123,25 +13148,25 @@ new Pair(undefined, 5, 1), new Pair(undefined, 6, 1) ]; - test('should sort mutliple properties in ascending order', 1, function() { - var actual = _.sortByAll(objects, ['a', 'b']); + test('`_.' + methodName + '` should sort mutliple properties in ascending order', 1, function() { + var actual = func(objects, ['a', 'b']); deepEqual(actual, [objects[2], objects[0], objects[3], objects[1]]); }); - test('should perform a stable sort (test in IE > 8, Opera, and V8)', 1, function() { - var actual = _.sortByAll(stableOrder, ['a', 'c']); + test('`_.' + methodName + '` should perform a stable sort (test in IE > 8, Opera, and V8)', 1, function() { + var actual = func(stableOrder, ['a', 'c']); deepEqual(actual, stableOrder); }); - test('should not error on nullish elements', 1, function() { + test('`_.' + methodName + '` should not error on nullish elements', 1, function() { try { - var actual = _.sortByAll(objects.concat(undefined), ['a', 'b']); + var actual = func(objects.concat(undefined), ['a', 'b']); } catch(e) {} deepEqual(actual, [objects[2], objects[0], objects[3], objects[1], undefined]); }); - test('should work as an iteratee for `_.reduce`', 1, function() { + test('`_.' + methodName + '` should work as an iteratee for `_.reduce`', 1, function() { var objects = [ { 'a': 'x', '0': 3 }, { 'a': 'y', '0': 4 }, @@ -13149,7 +13174,7 @@ { 'a': 'y', '0': 2 } ]; - var funcs = [_.sortByAll, _.partialRight(_.sortByAll, 'bogus')], + var funcs = [func, _.partialRight(func, 'bogus')], expected = _.map(funcs, _.constant([objects[0], objects[2], objects[1], objects[3]])); var actual = _.map(funcs, function(func) { @@ -13158,74 +13183,7 @@ deepEqual(actual, expected); }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('lodash.sortByOrder'); - - (function() { - function Pair(a, b, c) { - this.a = a; - this.b = b; - this.c = c; - } - - var objects = [ - { 'a': 'x', 'b': 3 }, - { 'a': 'y', 'b': 4 }, - { 'a': 'x', 'b': 1 }, - { 'a': 'y', 'b': 2 } - ]; - - var complexObjects = [ - { 'a': 'x', 'b': 3, 'c': 'bar' }, - { 'a': 'y', 'b': 4, 'c': 'foo' }, - { 'a': 'x', 'b': 1, 'c': 'foo' }, - { 'a': 'y', 'b': 2, 'c': 'bar' } - ] - - var stableOrder = [ - new Pair(1, 1, 1), new Pair(1, 2, 1), - new Pair(1, 1, 1), new Pair(1, 2, 1), - new Pair(1, 3, 1), new Pair(1, 4, 1), - new Pair(1, 5, 1), new Pair(1, 6, 1), - new Pair(2, 1, 2), new Pair(2, 2, 2), - new Pair(2, 3, 2), new Pair(2, 4, 2), - new Pair(2, 5, 2), new Pair(2, 6, 2), - new Pair(undefined, 1, 1), new Pair(undefined, 2, 1), - new Pair(undefined, 3, 1), new Pair(undefined, 4, 1), - new Pair(undefined, 5, 1), new Pair(undefined, 6, 1) - ]; - - test('should sort mutliple properties in ascending order by default', 1, function() { - var actual = _.sortByOrder(objects, ['a', 'b']); - deepEqual(actual, _.at(objects, [2, 0, 3, 1])); - }); - - test('should sort multiple properties depending on specified orders', 1, function() { - var actual = _.sortByOrder(complexObjects, ['a', 'b'], [false, true]); - deepEqual(actual, _.at(complexObjects, [3, 1, 2, 0])); - }); - - test('should sort ascendingly for property not specified', 1, function() { - var actual = _.sortByOrder(complexObjects, ['a', 'c'], [false]); - deepEqual(actual, _.at(complexObjects, [3, 1, 0, 2])); - }); - - test('should perform a stable sort (test in IE > 8, Opera, and V8)', 1, function() { - var actual = _.sortByOrder(stableOrder, ['a', 'c']); - deepEqual(actual, stableOrder); - }); - - test('should not error on nullish elements', 1, function() { - try { - var actual = _.sortByOrder(objects.concat(undefined), ['a', 'b']); - } catch(e) {} - - deepEqual(actual, [objects[2], objects[0], objects[3], objects[1], undefined]); - }); - }()); + }); /*--------------------------------------------------------------------------*/ From 1e647a205809035e9a97673228c9b76b6f704bf9 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 4 Mar 2015 08:36:11 -0800 Subject: [PATCH 40/46] Rename test module for consistency. --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index 5a9fc6c140..786d29e2db 100644 --- a/test/test.js +++ b/test/test.js @@ -10145,7 +10145,7 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.max and lodash.min'); + QUnit.module('extremum methods'); _.each(['max', 'min'], function(methodName) { var array = [1, 2, 3], From d898fcee75d38c3ffb00fd4dbaa41afa2e0305a0 Mon Sep 17 00:00:00 2001 From: jdalton Date: Wed, 4 Mar 2015 21:45:24 -0800 Subject: [PATCH 41/46] Simplify the `root` assignment. --- lodash.src.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 748fdaf7ca..97981784d3 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -259,30 +259,29 @@ '\u2029': 'u2029' }; - /** - * Used as a reference to the global object. - * - * The `this` value is used if it is the global object to avoid Greasemonkey's - * restricted `window` object, otherwise the `window` object is used. - */ - var root = (objectTypes[typeof window] && window !== (this && this.window)) ? window : this; - /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; - /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ + /** Detect free variable `global` from Node.js. */ var freeGlobal = freeExports && freeModule && typeof global == 'object' && global; - if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || - (typeof freeGlobal.WorkerGlobalScope == 'function' && freeGlobal instanceof freeGlobal.WorkerGlobalScope))) { - root = freeGlobal; - } + + /** Detect free variable `window`. */ + var freeWindow = objectTypes[typeof window] && window; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; + /** + * Used as a reference to the global object. + * + * The `this` value is used if it is the global object to avoid Greasemonkey's + * restricted `window` object, otherwise the `window` object is used. + */ + var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || this; + /*--------------------------------------------------------------------------*/ /** From 1dfaa30520f5d1a7590549c6f44977a2b429dbaa Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 5 Mar 2015 08:20:32 -0800 Subject: [PATCH 42/46] Add `inRange` and `sortByOrder` to `lodash` doc notes. [ci skip] --- lodash.src.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 97981784d3..4c3c7284f6 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -876,19 +876,19 @@ * `mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`, * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`, - * `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `splice`, `spread`, - * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, - * `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`, - * `unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`, - * `zip`, and `zipObject` + * `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, + * `spread`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, + * `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, `transform`, + * `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`, + * `without`, `wrap`, `xor`, `zip`, and `zipObject` * * The wrapper methods that are **not** chainable by default are: * `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, - * `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, - * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, - * `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, + * `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`, + * `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, + * `isFinite`,`isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`, * `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, From 9cdf013933ee18c519e5ab3a21a4cd1615adbece Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 5 Mar 2015 22:47:32 -0800 Subject: [PATCH 43/46] Ensure `length` hit of for lazy eval is checked on initial lazy call. [closes #997] --- lodash.src.js | 11 ++++----- test/test.js | 62 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 4c3c7284f6..dc5f3f403f 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -11674,12 +11674,13 @@ chainAll = this.__chain__, value = this.__wrapped__, isHybrid = !!this.__actions__.length, - isLazy = value instanceof LazyWrapper; + isLazy = value instanceof LazyWrapper, + iteratee = args[0], + useLazy = isLazy || isArray(value); - if (isLazy && checkIteratee) { + if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { // avoid lazy use if the iteratee has a `length` other than `1` - var iteratee = args[0]; - isLazy = !(typeof iteratee == 'function' && iteratee.length != 1); + isLazy = useLazy = false; } var onlyLazy = isLazy && !isHybrid; if (retUnwrapped && !chainAll) { @@ -11692,7 +11693,7 @@ push.apply(otherArgs, args); return lodashFunc.apply(lodash, otherArgs); }; - if (isLazy || isArray(value)) { + if (useLazy) { var wrapper = onlyLazy ? value : new LazyWrapper(this), result = func.apply(wrapper, args); diff --git a/test/test.js b/test/test.js index 786d29e2db..a6b875fa80 100644 --- a/test/test.js +++ b/test/test.js @@ -3986,11 +3986,17 @@ } }); - test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { + test('should provide the correct `predicate` arguments in a lazy chain sequence', 5, function() { if (!isNpm) { var args, expected = [16, 3, [1, 4, 9 ,16]]; + _(array).dropRightWhile(function(value, index, array) { + args = slice.call(arguments); + }).value(); + + deepEqual(args, [4, 3, array]); + _(array).map(square).dropRightWhile(function(value, index, array) { args = slice.call(arguments); }).value(); @@ -4016,7 +4022,7 @@ deepEqual(args, expected); } else { - skipTest(4); + skipTest(5); } }); }()); @@ -4102,11 +4108,17 @@ } }); - test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { + test('should provide the correct `predicate` arguments in a lazy chain sequence', 5, function() { if (!isNpm) { var args, expected = [1, 0, [1, 4, 9, 16]]; + _(array).dropWhile(function(value, index, array) { + args = slice.call(arguments); + }).value(); + + deepEqual(args, [1, 0, array]); + _(array).map(square).dropWhile(function(value, index, array) { args = slice.call(arguments); }).value(); @@ -4132,7 +4144,7 @@ deepEqual(args, expected); } else { - skipTest(4); + skipTest(5); } }); }()); @@ -4936,11 +4948,17 @@ } }); - test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { + test('should provide the correct `predicate` arguments in a lazy chain sequence', 5, function() { if (!isNpm) { var args, expected = [16, 3, [1, 4, 9 , 16]]; + _(array).takeRightWhile(function(value, index, array) { + args = slice.call(arguments) + }).value(); + + deepEqual(args, [4, 3, array]); + _(array).map(square).takeRightWhile(function(value, index, array) { args = slice.call(arguments) }).value(); @@ -4966,7 +4984,7 @@ deepEqual(args, expected); } else { - skipTest(4); + skipTest(5); } }); }()); @@ -5051,11 +5069,17 @@ } }); - test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { + test('should provide the correct `predicate` arguments in a lazy chain sequence', 5, function() { if (!isNpm) { var args, expected = [1, 0, [1, 4, 9, 16]]; + _(array).takeWhile(function(value, index, array) { + args = slice.call(arguments); + }).value(); + + deepEqual(args, [1, 0, array]); + _(array).map(square).takeWhile(function(value, index, array) { args = slice.call(arguments); }).value(); @@ -5081,7 +5105,7 @@ deepEqual(args, expected); } else { - skipTest(4); + skipTest(5); } }); }()); @@ -9223,11 +9247,18 @@ } }); - test('should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { + test('should provide the correct `predicate` arguments in a lazy chain sequence', 5, function() { if (!isNpm) { var args, expected = [1, 0, [1, 4, 9]]; + _(array).map(function(value, index, array) { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, [1, 0, array]); + + args = null; _(array).map(square).map(function(value, index, array) { args || (args = slice.call(arguments)); }).value(); @@ -9256,7 +9287,7 @@ deepEqual(args, expected); } else { - skipTest(4); + skipTest(5); } }); @@ -12210,11 +12241,18 @@ } }); - test('`_.' + methodName + '` should provide the correct `predicate` arguments in a lazy chain sequence', 4, function() { + test('`_.' + methodName + '` should provide the correct `predicate` arguments in a lazy chain sequence', 5, function() { if (!isNpm) { var args, expected = [1, 0, [1, 4, 9, 16]]; + _(array)[methodName](function(value, index, array) { + args || (args = slice.call(arguments)); + }).value(); + + deepEqual(args, [1, 0, array]); + + args = null; _(array).map(square)[methodName](function(value, index, array) { args || (args = slice.call(arguments)); }).value(); @@ -12243,7 +12281,7 @@ deepEqual(args, expected); } else { - skipTest(4); + skipTest(5); } }); }); From 6693416d0a1d7ff2d0b33711c40d6da906e4a966 Mon Sep 17 00:00:00 2001 From: jdalton Date: Thu, 5 Mar 2015 22:49:41 -0800 Subject: [PATCH 44/46] Tweak `_.isEmpty` and `_.size` docs. [ci skip] --- lodash.src.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index dc5f3f403f..4bfd9ec4f7 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -6774,8 +6774,8 @@ } /** - * Gets the size of `collection` by returning `collection.length` for - * array-like values or the number of own enumerable properties for objects. + * Gets the size of `collection` by returning its length for array-like + * values or the number of own enumerable properties for objects. * * @static * @memberOf _ @@ -8240,7 +8240,7 @@ } /** - * Checks if a value is empty. A value is considered empty unless it is an + * Checks if `value` is empty. A value is considered empty unless it is an * `arguments` object, array, string, or jQuery-like collection with a length * greater than `0` or an object with own enumerable properties. * From b5a42cfa7539fde33b7057a695af0005c0eeb354 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sat, 28 Feb 2015 21:39:33 -0800 Subject: [PATCH 45/46] Rebuild lodash and docs. --- doc/README.md | 798 ++++++++++++++++++++++++++++---------------------- lodash.js | 738 +++++++++++++++++++++++++++------------------- lodash.min.js | 170 +++++------ lodash.src.js | 4 +- 4 files changed, 965 insertions(+), 745 deletions(-) diff --git a/doc/README.md b/doc/README.md index 2cff32f3f6..67a5334ce7 100644 --- a/doc/README.md +++ b/doc/README.md @@ -1,4 +1,4 @@ -# lodash v3.3.1 +# lodash v3.4.0 @@ -95,8 +95,6 @@ * `_.inject` -> `reduce` * `_.invoke` * `_.map` -* `_.max` -* `_.min` * `_.partition` * `_.pluck` * `_.reduce` @@ -109,6 +107,7 @@ * `_.some` * `_.sortBy` * `_.sortByAll` +* `_.sortByOrder` * `_.where` @@ -183,6 +182,16 @@ +## `Math` +* `_.add` +* `_.max` +* `_.min` +* `_.sum` + + + + + ## `Number` * `_.inRange` * `_.random` @@ -313,7 +322,7 @@ ### `_.chunk(array, [size=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4200 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.chunk "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4288 "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 @@ -341,7 +350,7 @@ _.chunk(['a', 'b', 'c', 'd'], 3); ### `_.compact(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4231 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.compact "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4319 "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. @@ -364,7 +373,7 @@ _.compact([0, 1, false, 2, '', 3]); ### `_.difference(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4266 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.difference "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4354 "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. @@ -394,7 +403,7 @@ _.difference([1, 2, 3], [4, 2]); ### `_.drop(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4303 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.drop "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4392 "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. @@ -426,7 +435,7 @@ _.drop([1, 2, 3], 0); ### `_.dropRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4338 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4427 "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. @@ -458,7 +467,7 @@ _.dropRight([1, 2, 3], 0); ### `_.dropRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4399 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.droprightwhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4488 "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 @@ -518,7 +527,7 @@ _.pluck(_.dropRightWhile(users, 'active'), 'user'); ### `_.dropWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4458 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.dropwhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4547 "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 @@ -578,7 +587,7 @@ _.pluck(_.dropWhile(users, 'active'), 'user'); ### `_.fill(array, value, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4484 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.fill "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4573 "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`. @@ -602,7 +611,7 @@ including, `end`. ### `_.findIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4544 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4633 "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. @@ -661,7 +670,7 @@ _.findIndex(users, 'active'); ### `_.findLastIndex(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4605 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4694 "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. @@ -707,7 +716,7 @@ _.findLastIndex(users, { 'user': 'barney', 'active': true }); // using the `_.matchesProperty` callback shorthand _.findLastIndex(users, 'active', false); -// => 1 +// => 2 // using the `_.property` callback shorthand _.findLastIndex(users, 'active'); @@ -720,7 +729,7 @@ _.findLastIndex(users, 'active'); ### `_.first(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4633 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.first "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4722 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.first "See the npm package") Gets the first element of `array`. @@ -745,7 +754,7 @@ _.first([]); ### `_.flatten(array, [isDeep])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4657 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flatten "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4746 "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. @@ -773,7 +782,7 @@ _.flatten([1, [2, 3, [4]]], true); ### `_.flattenDeep(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4678 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4767 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flattendeep "See the npm package") Recursively flattens a nested array. @@ -795,7 +804,7 @@ _.flattenDeep([1, [2, 3, [4]]]); ### `_.indexOf(array, value, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4715 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4804 "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, @@ -836,7 +845,7 @@ _.indexOf([1, 1, 2, 2], 2, true); ### `_.initial(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4744 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4833 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.initial "See the npm package") Gets all but the last element of `array`. @@ -858,7 +867,7 @@ _.initial([1, 2, 3]); ### `_.intersection([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4766 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.intersection "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4855 "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. @@ -887,7 +896,7 @@ _.intersection([1, 2], [4, 2], [2, 1]); ### `_.last(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4821 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4910 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.last "See the npm package") Gets the last element of `array`. @@ -909,7 +918,7 @@ _.last([1, 2, 3]); ### `_.lastIndexOf(array, value, [fromIndex=array.length-1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4851 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.lastindexof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4940 "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. @@ -942,7 +951,7 @@ _.lastIndexOf([1, 1, 2, 2], 2, true); ### `_.pull(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4899 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pull "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L4988 "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. @@ -978,7 +987,7 @@ console.log(array); ### `_.pullAt(array, [indexes])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4944 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pullat "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5035 "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 @@ -1012,7 +1021,7 @@ console.log(evens); ### `_.remove(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L4987 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.remove "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5078 "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 @@ -1063,7 +1072,7 @@ console.log(evens); ### `_.rest(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5018 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rest "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5109 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rest "See the npm package") Gets all but the first element of `array`. @@ -1085,7 +1094,7 @@ _.rest([1, 2, 3]); ### `_.slice(array, [start=0], [end=array.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5036 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.slice "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5127 "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`.
@@ -1108,7 +1117,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.3.1/lodash.src.js#L5096 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5187 "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 @@ -1167,7 +1176,7 @@ _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); ### `_.sortedLastIndex(array, value, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5123 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortedlastindex "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5214 "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 @@ -1195,7 +1204,7 @@ _.sortedLastIndex([4, 4, 5, 5], 5); ### `_.take(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5154 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.take "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5245 "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. @@ -1227,7 +1236,7 @@ _.take([1, 2, 3], 0); ### `_.takeRight(array, [n=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5189 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takeright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5280 "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. @@ -1259,7 +1268,7 @@ _.takeRight([1, 2, 3], 0); ### `_.takeRightWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5250 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takerightwhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5341 "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` @@ -1319,7 +1328,7 @@ _.pluck(_.takeRightWhile(users, 'active'), 'user'); ### `_.takeWhile(array, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5309 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.takewhile "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5400 "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 @@ -1379,7 +1388,7 @@ _.pluck(_.takeWhile(users, 'active'), 'user'); ### `_.union([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5339 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.union "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5430 "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. @@ -1408,7 +1417,7 @@ _.union([1, 2], [4, 2], [2, 1]); ### `_.uniq(array, [isSorted], [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5395 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniq "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5486 "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 @@ -1472,7 +1481,7 @@ _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); ### `_.unzip(array)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5432 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unzip "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5523 "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` @@ -1499,7 +1508,7 @@ _.unzip(zipped); ### `_.without(array, [values])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5463 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.without "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5554 "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. @@ -1529,7 +1538,7 @@ _.without([1, 2, 1, 3], 1, 2); ### `_.xor([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5482 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.xor "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5573 "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 @@ -1553,7 +1562,7 @@ _.xor([1, 2], [4, 2]); ### `_.zip([arrays])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5512 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zip "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5603 "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 @@ -1577,7 +1586,7 @@ _.zip(['fred', 'barney'], [30, 40], [true, false]); ### `_.zipObject(props, [values=[]])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5539 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.zipobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5630 "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]]` @@ -1608,7 +1617,7 @@ _.zipObject(['fred', 'barney'], [30, 40]); ### `_(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L938 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L929 "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 @@ -1652,27 +1661,27 @@ The chainable wrapper methods are:
`mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`, `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`, -`shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `splice`, `spread`, -`take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, -`thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`, -`unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`, -`zip`, and `zipObject` +`shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, +`spread`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, +`throttle`, `thru`, `times`, `toArray`, `toPlainObject`, `transform`, +`union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`, +`without`, `wrap`, `xor`, `zip`, and `zipObject`

The wrapper methods that are **not** chainable by default are:
-`attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, +`add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, -`identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, -`isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, -`isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, +`identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`, +`isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, +`isFinite`,`isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`, `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, -`startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, -`trunc`, `unescape`, `uniqueId`, `value`, and `words` +`startCase`, `startsWith`, `sum`, `template`, `trim`, `trimLeft`, +`trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words`

The wrapper method `sample` will return a wrapped value when `n` is provided, @@ -1712,7 +1721,7 @@ _.isArray(squares.value()); ### `_.chain(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5586 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5677 "View in source") [Ⓣ][1] Creates a `lodash` object that wraps `value` with explicit method chaining enabled. @@ -1747,7 +1756,7 @@ var youngest = _.chain(users) ### `_.tap(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5615 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5706 "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 @@ -1779,7 +1788,7 @@ _([1, 2, 3]) ### `_.thru(value, interceptor, [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5640 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5731 "View in source") [Ⓣ][1] This method is like `_.tap` except that it returns the result of `interceptor`. @@ -1808,7 +1817,7 @@ _([1, 2, 3]) ### `_.prototype.chain()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5669 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5760 "View in source") [Ⓣ][1] Enables explicit method chaining on the wrapper object. @@ -1840,7 +1849,7 @@ _(users).chain() ### `_.prototype.commit()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5698 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5789 "View in source") [Ⓣ][1] Executes the chained sequence and returns the wrapped result. @@ -1872,7 +1881,7 @@ console.log(array); ### `_.prototype.plant()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5725 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5816 "View in source") [Ⓣ][1] Creates a clone of the chained sequence planting `value` as the wrapped value. @@ -1902,7 +1911,7 @@ wrapper.value(); ### `_.prototype.reverse()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5763 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5854 "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. @@ -1930,7 +1939,7 @@ console.log(array); ### `_.prototype.toString()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5788 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5879 "View in source") [Ⓣ][1] Produces the result of coercing the unwrapped value to a string. @@ -1949,7 +1958,7 @@ _([1, 2, 3]).toString(); ### `_.prototype.value()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5805 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5896 "View in source") [Ⓣ][1] Executes the chained sequence to extract the unwrapped value. @@ -1974,7 +1983,7 @@ _([1, 2, 3]).value(); ### `_.at(collection, [props])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5831 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.at "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5922 "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 @@ -2002,7 +2011,7 @@ _.at(['fred', 'barney', 'pebbles'], 0, 2); ### `_.countBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5880 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.countby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L5971 "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 @@ -2054,7 +2063,7 @@ _.countBy(['one', 'two', 'three'], 'length'); ### `_.every(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5932 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.every "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6023 "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; @@ -2112,7 +2121,7 @@ _.every(users, 'active'); ### `_.filter(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L5989 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.filter "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6080 "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 @@ -2171,7 +2180,7 @@ _.pluck(_.filter(users, 'active'), 'user'); ### `_.find(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6045 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.find "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6136 "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 @@ -2231,7 +2240,7 @@ _.result(_.find(users, 'active'), 'user'); ### `_.findLast(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6073 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlast "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6164 "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. @@ -2258,7 +2267,7 @@ _.findLast([1, 2, 3, 4], function(n) { ### `_.findWhere(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6107 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findwhere "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6198 "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 @@ -2297,7 +2306,7 @@ _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user'); ### `_.forEach(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6141 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreach "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6232 "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; @@ -2336,7 +2345,7 @@ _.forEach({ 'a': 1, 'b': 2 }, function(n, key) { ### `_.forEachRight(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6166 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.foreachright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6257 "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. @@ -2363,7 +2372,7 @@ _([1, 2]).forEachRight(function(n) { ### `_.groupBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6214 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.groupby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6305 "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 @@ -2416,7 +2425,7 @@ _.groupBy(['one', 'two', 'three'], 'length'); ### `_.includes(collection, target, [fromIndex=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6254 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.includes "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6345 "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 @@ -2457,7 +2466,7 @@ _.includes('pebbles', 'eb'); ### `_.indexBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6319 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.indexby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6410 "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 @@ -2514,7 +2523,7 @@ _.indexBy(keyData, function(object) { ### `_.invoke(collection, methodName, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6345 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invoke "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6436 "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 @@ -2544,7 +2553,7 @@ _.invoke([123, 456], String.prototype.split, ''); ### `_.map(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6405 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.map "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6496 "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 @@ -2610,126 +2619,8 @@ _.map(users, 'user'); -### `_.max(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6458 "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 -for each value in `collection` to generate the criterion by which the value -is ranked. The `iteratee` is bound to `thisArg` and invoked with three -arguments; (value, index, collection). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. - -#### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. - -#### Returns -*(*)*: Returns the maximum value. - -#### Example -```js -_.max([4, 2, 8, 6]); -// => 8 - -_.max([]); -// => -Infinity - -var users = [ - { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 40 } -]; - -_.max(users, function(chr) { - return chr.age; -}); -// => { 'user': 'fred', 'age': 40 }; - -// using the `_.property` callback shorthand -_.max(users, 'age'); -// => { 'user': 'fred', 'age': 40 }; -``` -* * * - - - - - -### `_.min(collection, [iteratee], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6507 "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 -for each value in `collection` to generate the criterion by which the value -is ranked. The `iteratee` is bound to `thisArg` and invoked with three -arguments; (value, index, collection). -
-
-If a property name is provided for `predicate` the created `_.property` -style callback returns the property value of the given element. -
-
-If a value is also provided for `thisArg` the created `_.matchesProperty` -style callback returns `true` for elements that have a matching property -value, else `false`. -
-
-If an object is provided for `predicate` the created `_.matches` style -callback returns `true` for elements that have the properties of the given -object, else `false`. - -#### Arguments -1. `collection` *(Array|Object|string)*: The collection to iterate over. -2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. -3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. - -#### Returns -*(*)*: Returns the minimum value. - -#### Example -```js -_.min([4, 2, 8, 6]); -// => 2 - -_.min([]); -// => Infinity - -var users = [ - { 'user': 'barney', 'age': 36 }, - { 'user': 'fred', 'age': 40 } -]; - -_.min(users, function(chr) { - return chr.age; -}); -// => { 'user': 'barney', 'age': 36 }; - -// using the `_.property` callback shorthand -_.min(users, 'age'); -// => { 'user': 'barney', 'age': 36 }; -``` -* * * - - - - - ### `_.partition(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6568 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partition "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6561 "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 @@ -2768,7 +2659,7 @@ _.partition([1, 2, 3], function(n) { _.partition([1.2, 2.3, 3.4], function(n) { return this.floor(n) % 2; }, Math); -// => [[1, 3], [2]] +// => [[1.2, 3.4], [2.3]] var users = [ { 'user': 'barney', 'age': 36, 'active': false }, @@ -2799,7 +2690,7 @@ _.map(_.partition(users, 'active'), mapper); ### `_.pluck(collection, key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6595 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pluck "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6588 "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`. @@ -2831,7 +2722,7 @@ _.pluck(userIndex, 'age'); ### `_.reduce(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6635 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduce "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6628 "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 @@ -2877,7 +2768,7 @@ _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) { ### `_.reduceRight(collection, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6662 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reduceright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6655 "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. @@ -2907,7 +2798,7 @@ _.reduceRight(array, function(flattened, other) { ### `_.reject(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6714 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.reject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6707 "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. @@ -2965,7 +2856,7 @@ _.pluck(_.reject(users, 'active'), 'user'); ### `_.sample(collection, [n])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6740 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sample "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6733 "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. @@ -2991,7 +2882,7 @@ _.sample([1, 2, 3, 4], 2); ### `_.shuffle(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6766 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.shuffle "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6759 "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) @@ -3015,10 +2906,10 @@ _.shuffle([1, 2, 3, 4]); ### `_.size(collection)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6803 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.size "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6796 "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. +Gets the size of `collection` by returning its length for array-like +values or the number of own enumerable properties for objects. #### Arguments 1. `collection` *(Array|Object|string)*: The collection to inspect. @@ -3044,7 +2935,7 @@ _.size('pebbles'); ### `_.some(collection, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6857 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.some "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6850 "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 @@ -3103,7 +2994,7 @@ _.some(users, 'active'); ### `_.sortBy(collection, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6914 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortby "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6907 "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 @@ -3162,7 +3053,7 @@ _.pluck(_.sortBy(users, 'user'), 'user'); ### `_.sortByAll(collection, props)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L6952 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortbyall "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6948 "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. @@ -3192,8 +3083,43 @@ _.map(_.sortByAll(users, ['user', 'age']), _.values); +### `_.sortByOrder(collection, props, orders)` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L6987 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sortbyorder "See the npm package") + +This method is like `_.sortByAll` except that it allows specifying the +sort orders of the property names to sort by. A truthy value in `orders` +will sort the corresponding property name in ascending order while a +falsey value will sort it in descending order. + +#### Arguments +1. `collection` *(Array|Object|string)*: The collection to iterate over. +2. `props` *(string[])*: The property names to sort by. +3. `orders` *(boolean[])*: The sort orders of `props`. + +#### Returns +*(Array)*: Returns the new sorted array. + +#### Example +```js +var users = [ + { 'user': 'barney', 'age': 36 }, + { 'user': 'fred', 'age': 40 }, + { 'user': 'barney', 'age': 26 }, + { 'user': 'fred', 'age': 30 } +]; + +// sort by `user` in ascending order and by `age` in descending order +_.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values); +// => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]] +``` +* * * + + + + + ### `_.where(collection, source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7003 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.where "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7032 "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 @@ -3238,7 +3164,7 @@ _.pluck(_.where(users, { 'pets': ['dino'] }), 'user'); ### `_.now` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7023 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.now "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7052 "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). @@ -3263,7 +3189,7 @@ _.defer(function(stamp) { ### `_.after(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7052 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.after "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7081 "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. @@ -3295,7 +3221,7 @@ _.forEach(saves, function(type) { ### `_.ary(func, [n=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7086 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ary "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7115 "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. @@ -3319,7 +3245,7 @@ _.map(['6', '8', '10'], _.ary(parseInt, 1)); ### `_.before(n, func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7110 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.before "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7139 "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 @@ -3344,7 +3270,7 @@ jQuery('#add').on('click', _.before(5, addContactToList)); ### `_.bind(func, thisArg, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7166 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bind "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7195 "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 @@ -3390,7 +3316,7 @@ bound('hi'); ### `_.bindAll(object, [methodNames])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7205 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindall "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7234 "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 @@ -3427,7 +3353,7 @@ jQuery('#docs').on('click', view.onClick); ### `_.bindKey(object, key, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7257 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.bindkey "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7286 "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. @@ -3482,7 +3408,7 @@ bound('hi'); ### `_.curry(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7308 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curry "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7337 "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 @@ -3532,7 +3458,7 @@ curried(1)(_, 3)(2); ### `_.curryRight(func, [arity=func.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7354 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.curryright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7383 "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`. @@ -3579,7 +3505,7 @@ curried(3)(1, _)(2); ### `_.debounce(func, [wait=0], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7425 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.debounce "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7454 "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 @@ -3649,7 +3575,7 @@ delete models.todo; ### `_.defer(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7556 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defer "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7585 "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. @@ -3675,7 +3601,7 @@ _.defer(function(text) { ### `_.delay(func, wait, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7578 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.delay "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7607 "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. @@ -3702,7 +3628,7 @@ _.delay(function(text) { ### `_.flow([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7606 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flow "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7631 "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 @@ -3716,15 +3642,11 @@ successive invocation is supplied the return value of the previous. #### Example ```js -function add(x, y) { - return x + y; -} - function square(n) { return n * n; } -var addSquare = _.flow(add, square); +var addSquare = _.flow(_.add, square); addSquare(1, 2); // => 9 ``` @@ -3735,7 +3657,7 @@ addSquare(1, 2); ### `_.flowRight([funcs])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7651 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.flowright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7653 "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. @@ -3748,15 +3670,11 @@ invokes the provided functions from right to left. #### Example ```js -function add(x, y) { - return x + y; -} - function square(n) { return n * n; } -var addSquare = _.flowRight(square, add); +var addSquare = _.flowRight(square, _.add); addSquare(1, 2); // => 9 ``` @@ -3767,7 +3685,7 @@ addSquare(1, 2); ### `_.memoize(func, [resolver])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7725 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.memoize "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7708 "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 @@ -3830,7 +3748,7 @@ identity(other); ### `_.negate(predicate)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7763 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.negate "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7747 "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 @@ -3858,7 +3776,7 @@ _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); ### `_.once(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7789 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.once "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7773 "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 @@ -3884,7 +3802,7 @@ initialize(); ### `_.partial(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7825 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partial "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7809 "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 @@ -3927,7 +3845,7 @@ greetFred('hi'); ### `_.partialRight(func, [args])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7863 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.partialright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7847 "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. @@ -3969,7 +3887,7 @@ sayHelloTo('fred'); ### `_.rearg(func, indexes)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7898 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.rearg "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7882 "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 @@ -4005,7 +3923,7 @@ map(function(n) { ### `_.spread(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7933 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.spread "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7917 "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 @@ -4044,7 +3962,7 @@ numbers.then(_.spread(function(x, y) { ### `_.throttle(func, [wait=0], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L7981 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.throttle "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L7965 "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 @@ -4092,7 +4010,7 @@ jQuery(window).on('popstate', throttled.cancel); ### `_.wrap(value, wrapper)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8021 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.wrap "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8005 "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 @@ -4128,7 +4046,7 @@ p('fred, barney, & pebbles'); ### `_.clone(value, [isDeep], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8079 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clone "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8063 "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 @@ -4189,7 +4107,7 @@ el.childNodes.length; ### `_.cloneDeep(value, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8137 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.clonedeep "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8121 "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 @@ -4244,7 +4162,7 @@ el.childNodes.length; ### `_.isArguments(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8158 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8142 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarguments "See the npm package") Checks if `value` is classified as an `arguments` object. @@ -4269,7 +4187,7 @@ _.isArguments([1, 2, 3]); ### `_.isArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8187 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8171 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isarray "See the npm package") Checks if `value` is classified as an `Array` object. @@ -4294,7 +4212,7 @@ _.isArray(function() { return arguments; }()); ### `_.isBoolean(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8207 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isboolean "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8191 "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. @@ -4319,7 +4237,7 @@ _.isBoolean(null); ### `_.isDate(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8227 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8211 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isdate "See the npm package") Checks if `value` is classified as a `Date` object. @@ -4344,7 +4262,7 @@ _.isDate('Mon April 23 2012'); ### `_.isElement(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8247 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8231 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iselement "See the npm package") Checks if `value` is a DOM element. @@ -4369,9 +4287,9 @@ _.isElement(''); ### `_.isEmpty(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8285 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isempty "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8269 "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 +Checks if `value` is empty. A value is considered empty unless it is an `arguments` object, array, string, or jQuery-like collection with a length greater than `0` or an object with own enumerable properties. @@ -4405,7 +4323,7 @@ _.isEmpty({ 'a': 1 }); ### `_.isEqual(value, other, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8340 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isequal "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8324 "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. @@ -4458,7 +4376,7 @@ _.isEqual(array, other, function(value, other) { ### `_.isError(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8366 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.iserror "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8350 "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. @@ -4484,7 +4402,7 @@ _.isError(Error); ### `_.isFinite(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8399 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfinite "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8383 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfinite "See the npm package") Checks if `value` is a finite primitive number.
@@ -4523,7 +4441,7 @@ _.isFinite(Infinity); ### `_.isFunction(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8419 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8403 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isfunction "See the npm package") Checks if `value` is classified as a `Function` object. @@ -4548,7 +4466,7 @@ _.isFunction(/abc/); ### `_.isMatch(object, source, [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8494 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.ismatch "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8478 "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 @@ -4597,7 +4515,7 @@ _.isMatch(object, source, function(value, other) { ### `_.isNaN(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8543 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8527 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnan "See the npm package") Checks if `value` is `NaN`.
@@ -4633,7 +4551,7 @@ _.isNaN(undefined); ### `_.isNative(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8565 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8549 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnative "See the npm package") Checks if `value` is a native function. @@ -4658,7 +4576,7 @@ _.isNative(_); ### `_.isNull(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8592 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8576 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnull "See the npm package") Checks if `value` is `null`. @@ -4683,7 +4601,7 @@ _.isNull(void 0); ### `_.isNumber(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8618 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isnumber "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8602 "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.
@@ -4715,7 +4633,7 @@ _.isNumber('8.4'); ### `_.isObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8448 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8432 "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('')`) @@ -4747,7 +4665,7 @@ _.isObject(1); ### `_.isPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8652 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isplainobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8636 "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`. @@ -4787,7 +4705,7 @@ _.isPlainObject(Object.create(null)); ### `_.isRegExp(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8680 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8664 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isregexp "See the npm package") Checks if `value` is classified as a `RegExp` object. @@ -4812,7 +4730,7 @@ _.isRegExp('/abc/'); ### `_.isString(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8700 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isstring "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8684 "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. @@ -4837,7 +4755,7 @@ _.isString(1); ### `_.isTypedArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8720 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8704 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.istypedarray "See the npm package") Checks if `value` is classified as a typed array. @@ -4862,7 +4780,7 @@ _.isTypedArray([]); ### `_.isUndefined(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8740 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8724 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.isundefined "See the npm package") Checks if `value` is `undefined`. @@ -4887,7 +4805,7 @@ _.isUndefined(null); ### `_.toArray(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8759 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8743 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toarray "See the npm package") Converts `value` to an array. @@ -4911,7 +4829,7 @@ Converts `value` to an array. ### `_.toPlainObject(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8795 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.toplainobject "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8779 "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. @@ -4944,15 +4862,187 @@ _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); +## `“Math” Methods` + + + +### `_.add(augend, addend)` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L11160 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.add "See the npm package") + +Adds two numbers. + +#### Arguments +1. `augend` *(number)*: The first number to add. +2. `addend` *(number)*: The second number to add. + +#### Returns +*(number)*: Returns the sum. + +#### Example +```js +_.add(6, 4); +// => 10 +``` +* * * + + + + + +### `_.max(collection, [iteratee], [thisArg])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L11211 "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 +for each value in `collection` to generate the criterion by which the value +is ranked. The `iteratee` is bound to `thisArg` and invoked with three +arguments; (value, index, collection). +
+
+If a property name is provided for `predicate` the created `_.property` +style callback returns the property value of the given element. +
+
+If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style +callback returns `true` for elements that have the properties of the given +object, else `false`. + +#### Arguments +1. `collection` *(Array|Object|string)*: The collection to iterate over. +2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. +3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. + +#### Returns +*(*)*: Returns the maximum value. + +#### Example +```js +_.max([4, 2, 8, 6]); +// => 8 + +_.max([]); +// => -Infinity + +var users = [ + { 'user': 'barney', 'age': 36 }, + { 'user': 'fred', 'age': 40 } +]; + +_.max(users, function(chr) { + return chr.age; +}); +// => { 'user': 'fred', 'age': 40 }; + +// using the `_.property` callback shorthand +_.max(users, 'age'); +// => { 'user': 'fred', 'age': 40 }; +``` +* * * + + + + + +### `_.min(collection, [iteratee], [thisArg])` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L11260 "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 +for each value in `collection` to generate the criterion by which the value +is ranked. The `iteratee` is bound to `thisArg` and invoked with three +arguments; (value, index, collection). +
+
+If a property name is provided for `predicate` the created `_.property` +style callback returns the property value of the given element. +
+
+If a value is also provided for `thisArg` the created `_.matchesProperty` +style callback returns `true` for elements that have a matching property +value, else `false`. +
+
+If an object is provided for `predicate` the created `_.matches` style +callback returns `true` for elements that have the properties of the given +object, else `false`. + +#### Arguments +1. `collection` *(Array|Object|string)*: The collection to iterate over. +2. `[iteratee]` *(Function|Object|string)*: The function invoked per iteration. +3. `[thisArg]` *(*)*: The `this` binding of `iteratee`. + +#### Returns +*(*)*: Returns the minimum value. + +#### Example +```js +_.min([4, 2, 8, 6]); +// => 2 + +_.min([]); +// => Infinity + +var users = [ + { 'user': 'barney', 'age': 36 }, + { 'user': 'fred', 'age': 40 } +]; + +_.min(users, function(chr) { + return chr.age; +}); +// => { 'user': 'barney', 'age': 36 }; + +// using the `_.property` callback shorthand +_.min(users, 'age'); +// => { 'user': 'barney', 'age': 36 }; +``` +* * * + + + + + +### `_.sum(collection)` +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L11278 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.sum "See the npm package") + +Gets the sum of the values in `collection`. + +#### Arguments +1. `collection` *(Array|Object|string)*: The collection to iterate over. + +#### Returns +*(number)*: Returns the sum. + +#### Example +```js +_.sum([4, 6, 2]); +// => 12 + +_.sum({ 'a': 4, 'b': 6, 'c': 2 }); +// => 12 +``` +* * * + + + + + + + ## `“Number” Methods` ### `_.inRange(n, [start=0], end)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9725 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.inrange "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9709 "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`. +`end` is not specified it is set to `start` with `start` then set to `0`. #### Arguments 1. `n` *(number)*: The number to check. @@ -4989,7 +5079,7 @@ _.inRange(5.2, 4); ### `_.random([min=0], [max=1], [floating])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9763 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.random "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9747 "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. @@ -5031,7 +5121,7 @@ _.random(1.2, 5.2); ### `_.assign(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8830 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.assign "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8814 "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. @@ -5068,7 +5158,7 @@ defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.create(prototype, [properties])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8866 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.create "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8850 "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 @@ -5110,11 +5200,11 @@ circle instanceof Shape; ### `_.defaults(object, [sources])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8890 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.defaults "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8874 "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 -property is set, additional defaults of the same property are ignored. +property is set, additional values of the same property are ignored. #### Arguments 1. `object` *(Object)*: The destination object. @@ -5135,7 +5225,7 @@ _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' }); ### `_.findKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L8947 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findkey "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8931 "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. @@ -5194,7 +5284,7 @@ _.findKey(users, 'active'); ### `_.findLastKey(object, [predicate=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9000 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.findlastkey "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L8984 "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. @@ -5253,7 +5343,7 @@ _.findLastKey(users, 'active'); ### `_.forIn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9032 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9016 "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 @@ -5289,7 +5379,7 @@ _.forIn(new Foo, function(value, key) { ### `_.forInRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9064 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forinright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9048 "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. @@ -5323,7 +5413,7 @@ _.forInRight(new Foo, function(value, key) { ### `_.forOwn(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9096 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forown "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9080 "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 @@ -5359,7 +5449,7 @@ _.forOwn(new Foo, function(value, key) { ### `_.forOwnRight(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9128 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.forownright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9112 "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. @@ -5393,7 +5483,7 @@ _.forOwnRight(new Foo, function(value, key) { ### `_.functions(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9148 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.functions "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9132 "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`. @@ -5416,7 +5506,7 @@ _.functions(_); ### `_.has(object, key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9169 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.has "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9153 "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. @@ -5442,7 +5532,7 @@ _.has(object, 'b'); ### `_.invert(object, [multiValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9196 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.invert "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9180 "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 @@ -5473,7 +5563,7 @@ _.invert(object, true); ### `_.keys(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9250 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keys "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9234 "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`.
@@ -5510,7 +5600,7 @@ _.keys('hi'); ### `_.keysIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9284 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.keysin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9268 "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`.
@@ -5542,7 +5632,7 @@ _.keysIn(new Foo); ### `_.mapValues(object, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9383 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mapvalues "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9367 "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 @@ -5594,7 +5684,7 @@ _.mapValues(users, 'age'); ### `_.merge(object, [sources], [customizer], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9441 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.merge "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9425 "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 @@ -5651,7 +5741,7 @@ _.merge(object, other, function(a, b) { ### `_.omit(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9471 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.omit "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9455 "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. @@ -5686,7 +5776,7 @@ _.omit(object, _.isNumber); ### `_.pairs(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9499 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pairs "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9483 "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]]`. @@ -5709,7 +5799,7 @@ _.pairs({ 'barney': 36, 'fred': 40 }); ### `_.pick(object, [predicate], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9538 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pick "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9522 "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 @@ -5742,7 +5832,7 @@ _.pick(object, _.isString); ### `_.result(object, key, [defaultValue])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9577 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.result "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9561 "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 @@ -5780,7 +5870,7 @@ _.result(object, 'status', _.constant('busy')); ### `_.transform(object, [iteratee=_.identity], [accumulator], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9614 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.transform "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9598 "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 @@ -5818,7 +5908,7 @@ _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) { ### `_.values(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9661 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.values "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9645 "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`.
@@ -5853,7 +5943,7 @@ _.values('hi'); ### `_.valuesIn(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9688 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.valuesin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9672 "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`. @@ -5892,7 +5982,7 @@ _.valuesIn(new Foo); ### `_.camelCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9820 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.camelcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9804 "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. @@ -5921,7 +6011,7 @@ _.camelCase('__foo_bar__'); ### `_.capitalize([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9838 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.capitalize "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9822 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.capitalize "See the npm package") Capitalizes the first character of `string`. @@ -5943,7 +6033,7 @@ _.capitalize('fred'); ### `_.deburr([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9858 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.deburr "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9842 "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) @@ -5967,7 +6057,7 @@ _.deburr('déjà vu'); ### `_.endsWith([string=''], [target], [position=string.length])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9884 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.endswith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9868 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.endswith "See the npm package") Checks if `string` ends with the given target string. @@ -5997,7 +6087,7 @@ _.endsWith('abc', 'b', 2); ### `_.escape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9925 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escape "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9909 "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. @@ -6042,7 +6132,7 @@ _.escape('fred, barney, & pebbles'); ### `_.escapeRegExp([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9947 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escaperegexp "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9931 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.escaperegexp "See the npm package") Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", "+", "(", ")", "[", "]", "{" and "}" in `string`. @@ -6065,7 +6155,7 @@ _.escapeRegExp('[lodash](https://lodash.com/)'); ### `_.kebabCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L9975 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.kebabcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9959 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.kebabcase "See the npm package") Converts `string` to kebab case. See [Wikipedia](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles) for @@ -6095,7 +6185,7 @@ _.kebabCase('__foo_bar__'); ### `_.pad([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10002 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.pad "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L9986 "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 @@ -6127,7 +6217,7 @@ _.pad('abc', 3); ### `_.padLeft([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10041 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padleft "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10025 "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 @@ -6159,7 +6249,7 @@ _.padLeft('abc', 3); ### `_.padRight([string=''], [length=0], [chars=' '])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10069 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.padright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10053 "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 @@ -6191,7 +6281,7 @@ _.padRight('abc', 3); ### `_.parseInt(string, [radix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10097 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.parseint "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10081 "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, @@ -6223,7 +6313,7 @@ _.map(['6', '08', '10'], _.parseInt); ### `_.repeat([string=''], [n=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10139 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.repeat "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10123 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.repeat "See the npm package") Repeats the given string `n` times. @@ -6252,7 +6342,7 @@ _.repeat('abc', 0); ### `_.snakeCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10179 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.snakecase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10163 "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. @@ -6281,7 +6371,7 @@ _.snakeCase('--foo-bar'); ### `_.startCase([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10204 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startcase "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10188 "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) @@ -6311,7 +6401,7 @@ _.startCase('__foo_bar__'); ### `_.startsWith([string=''], [target], [position=0])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10229 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startswith "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10213 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.startswith "See the npm package") Checks if `string` starts with the given target string. @@ -6341,7 +6431,7 @@ _.startsWith('abc', 'b', 1); ### `_.template([string=''], [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10331 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.template "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10315 "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 @@ -6448,7 +6538,7 @@ fs.writeFileSync(path.join(cwd, 'jst.js'), '\ ### `_.trim([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10458 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trim "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10442 "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`. @@ -6477,7 +6567,7 @@ _.map([' foo ', ' bar '], _.trim); ### `_.trimLeft([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10489 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimleft "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10473 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimleft "See the npm package") Removes leading whitespace or specified characters from `string`. @@ -6503,7 +6593,7 @@ _.trimLeft('-_-abc-_-', '_-'); ### `_.trimRight([string=''], [chars=whitespace])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10519 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimright "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10503 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trimright "See the npm package") Removes trailing whitespace or specified characters from `string`. @@ -6529,7 +6619,7 @@ _.trimRight('-_-abc-_-', '_-'); ### `_.trunc([string=''], [options], [options.length=30], [options.omission='...'], [options.separator])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10571 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.trunc "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10555 "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 @@ -6577,7 +6667,7 @@ _.trunc('hi-diddly-ho there, neighborino', { ### `_.unescape([string=''])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10641 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.unescape "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10625 "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 @@ -6605,7 +6695,7 @@ _.unescape('fred, barney, & pebbles'); ### `_.words([string=''], [pattern])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10666 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.words "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10650 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.words "See the npm package") Splits `string` into an array of its words. @@ -6637,7 +6727,7 @@ _.words('fred, barney, & pebbles', /[^, ]+/g); ### `_.attempt(func)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10696 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.attempt "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10680 "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. @@ -6666,7 +6756,7 @@ if (_.isError(elements)) { ### `_.callback([func=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10749 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.callback "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10733 "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 @@ -6711,7 +6801,7 @@ _.filter(users, 'age__gt36'); ### `_.constant(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10774 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.constant "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10758 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.constant "See the npm package") Creates a function that returns `value`. @@ -6736,7 +6826,7 @@ getter() === object; ### `_.identity(value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10795 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.identity "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10779 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.identity "See the npm package") This method returns the first argument provided to it. @@ -6760,7 +6850,7 @@ _.identity(object) === object; ### `_.matches(source)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10824 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matches "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10808 "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 @@ -6795,7 +6885,7 @@ _.filter(users, _.matches({ 'age': 40, 'active': false })); ### `_.matchesProperty(key, value)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10853 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.matchesproperty "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10837 "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`. @@ -6830,7 +6920,7 @@ _.find(users, _.matchesProperty('user', 'fred')); ### `_.mixin([object=this], source, [options])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10893 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.mixin "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10877 "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 @@ -6874,7 +6964,7 @@ _('fred').vowels(); ### `_.noConflict()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10956 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noconflict "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10940 "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. @@ -6893,7 +6983,7 @@ var lodash = _.noConflict(); ### `_.noop()` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L10975 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noop "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10959 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.noop "See the npm package") A no-operation function which returns `undefined` regardless of the arguments it receives. @@ -6912,7 +7002,7 @@ _.noop(object) === undefined; ### `_.property(key)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L11002 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.property "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L10986 "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. @@ -6944,7 +7034,7 @@ _.pluck(_.sortBy(users, getName), 'user'); ### `_.propertyOf(object)` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L11025 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.propertyof "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L11009 "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`. @@ -6972,12 +7062,12 @@ _.sortBy(['a', 'b', 'c'], _.propertyOf(object)); ### `_.range([start=0], end, [step=1])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L11064 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.range "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L11048 "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 `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. +`start` up to, but not including, `end`. If `end` is not specified it is +set to `start` with `start` then set to `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. @@ -7014,7 +7104,7 @@ _.range(0); ### `_.runInContext([context=root])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L703 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.runincontext "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L694 "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. @@ -7058,7 +7148,7 @@ var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; ### `_.times(n, [iteratee=_.identity], [thisArg])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L11117 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.times "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L11101 "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 @@ -7094,7 +7184,7 @@ _.times(3, function(n) { ### `_.uniqueId([prefix])` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L11155 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.uniqueid "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L11139 "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. @@ -7125,7 +7215,7 @@ _.uniqueId(); ### `_.templateSettings.imports._` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1191 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1182 "View in source") [Ⓣ][1] A reference to the `lodash` function. @@ -7142,7 +7232,7 @@ A reference to the `lodash` function. ### `_.VERSION` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L11426 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L11560 "View in source") [Ⓣ][1] (string): The semantic version number. @@ -7153,7 +7243,7 @@ A reference to the `lodash` function. ### `_.support` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L980 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.support "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L971 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.support "See the npm package") (Object): An object environment feature flags. @@ -7164,7 +7254,7 @@ A reference to the `lodash` function. ### `_.support.argsTag` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L997 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L988 "View in source") [Ⓣ][1] (boolean): Detect if the `toStringTag` of `arguments` objects is resolvable (all but Firefox < 4, IE < 9). @@ -7176,7 +7266,7 @@ A reference to the `lodash` function. ### `_.support.enumErrorProps` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1006 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L997 "View in source") [Ⓣ][1] (boolean): Detect if `name` or `message` properties of `Error.prototype` are enumerable by default (IE < 9, Safari < 5.1). @@ -7188,7 +7278,7 @@ enumerable by default (IE < 9, Safari < 5.1). ### `_.support.enumPrototypes` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1020 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1011 "View in source") [Ⓣ][1] (boolean): Detect if `prototype` properties are enumerable by default.
@@ -7205,7 +7295,7 @@ property to `true`. ### `_.support.funcDecomp` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1030 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1021 "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 @@ -7218,7 +7308,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.funcNames` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1038 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1029 "View in source") [Ⓣ][1] (boolean): Detect if `Function#name` is supported (all but IE). @@ -7229,7 +7319,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.nodeTag` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1046 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1037 "View in source") [Ⓣ][1] (boolean): Detect if the `toStringTag` of DOM nodes is resolvable (all but IE < 9). @@ -7240,7 +7330,7 @@ the PlayStation 3; forced `false` for Windows 8 apps). ### `_.support.nonEnumShadows` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1067 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1058 "View in source") [Ⓣ][1] (boolean): Detect if properties shadowing those on `Object.prototype` are non-enumerable. @@ -7256,7 +7346,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.nonEnumStrings` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1055 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1046 "View in source") [Ⓣ][1] (boolean): Detect if string indexes are non-enumerable (IE < 9, RingoJS, Rhino, Narwhal). @@ -7268,7 +7358,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.ownLast` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1075 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1066 "View in source") [Ⓣ][1] (boolean): Detect if own properties are iterated after inherited properties (IE < 9). @@ -7279,7 +7369,7 @@ are made non-enumerable as well (a.k.a the JScript `[[DontEnum]]` bug). ### `_.support.spliceObjects` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1090 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1081 "View in source") [Ⓣ][1] (boolean): Detect if `Array#shift` and `Array#splice` augment array-like objects correctly. @@ -7298,7 +7388,7 @@ is buggy regardless of mode in IE < 9. ### `_.support.unindexedChars` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1101 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1092 "View in source") [Ⓣ][1] (boolean): Detect lack of support for accessing string characters by index.
@@ -7313,7 +7403,7 @@ by index on string literals, not string objects. ### `_.templateSettings` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1143 "View in source") [Ⓣ][1] [Ⓝ](https://www.npmjs.com/package/lodash.templatesettings "See the npm package") +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1134 "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 @@ -7326,7 +7416,7 @@ alternative delimiters. ### `_.templateSettings.escape` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1151 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1142 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to be HTML-escaped. @@ -7337,7 +7427,7 @@ alternative delimiters. ### `_.templateSettings.evaluate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1159 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1150 "View in source") [Ⓣ][1] (RegExp): Used to detect code to be evaluated. @@ -7348,7 +7438,7 @@ alternative delimiters. ### `_.templateSettings.imports` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1183 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1174 "View in source") [Ⓣ][1] (Object): Used to import variables into the compiled template. @@ -7359,7 +7449,7 @@ alternative delimiters. ### `_.templateSettings.interpolate` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1167 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1158 "View in source") [Ⓣ][1] (RegExp): Used to detect `data` property values to inject. @@ -7370,7 +7460,7 @@ alternative delimiters. ### `_.templateSettings.variable` -# [Ⓢ](https://github.com/lodash/lodash/blob/3.3.1/lodash.src.js#L1175 "View in source") [Ⓣ][1] +# [Ⓢ](https://github.com/lodash/lodash/blob/3.4.0/lodash.src.js#L1166 "View in source") [Ⓣ][1] (string): Used to reference the data object in the template text. diff --git a/lodash.js b/lodash.js index 369ad15f64..665cb0f02d 100644 --- a/lodash.js +++ b/lodash.js @@ -1,6 +1,6 @@ /** * @license - * lodash 3.3.1 (Custom Build) + * lodash 3.4.0 (Custom Build) * Build: `lodash modern -o ./lodash.js` * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.8.2 @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '3.3.1'; + var VERSION = '3.4.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -35,9 +35,9 @@ HOT_SPAN = 16; /** Used to indicate the type of lazy iteratees. */ - var LAZY_FILTER_FLAG = 0, - LAZY_MAP_FLAG = 1, - LAZY_WHILE_FLAG = 2; + var LAZY_DROP_WHILE_FLAG = 0, + LAZY_MAP_FLAG = 2, + LAZY_TAKE_WHILE_FLAG = 3; /** Used as the `TypeError` message for "Functions" methods. */ var FUNC_ERROR_TEXT = 'Expected a function'; @@ -131,7 +131,7 @@ var upper = '[A-Z\\xc0-\\xd6\\xd8-\\xde]', lower = '[a-z\\xdf-\\xf6\\xf8-\\xff]+'; - return RegExp(upper + '{2,}(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); + return RegExp(upper + '+(?=' + upper + lower + ')|' + upper + '?' + lower + '|' + upper + '+|[0-9]+', 'g'); }()); /** Used to detect and test for whitespace. */ @@ -253,29 +253,29 @@ '\u2029': 'u2029' }; - /** - * Used as a reference to the global object. - * - * The `this` value is used if it is the global object to avoid Greasemonkey's - * restricted `window` object, otherwise the `window` object is used. - */ - var root = (objectTypes[typeof window] && window !== (this && this.window)) ? window : this; - /** Detect free variable `exports`. */ var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = objectTypes[typeof module] && module && !module.nodeType && module; - /** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */ + /** Detect free variable `global` from Node.js. */ var freeGlobal = freeExports && freeModule && typeof global == 'object' && global; - if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal)) { - root = freeGlobal; - } + + /** Detect free variable `window`. */ + var freeWindow = objectTypes[typeof window] && window; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports && freeExports; + /** + * Used as a reference to the global object. + * + * The `this` value is used if it is the global object to avoid Greasemonkey's + * restricted `window` object, otherwise the `window` object is used. + */ + var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || this; + /*--------------------------------------------------------------------------*/ /** @@ -308,14 +308,14 @@ * @private * @param {Array} array The array to search. * @param {*} value The value to search for. - * @param {number} [fromIndex=0] The index to search from. + * @param {number} fromIndex The index to search from. * @returns {number} Returns the index of the matched value, else `-1`. */ function baseIndexOf(array, value, fromIndex) { if (value !== value) { return indexOfNaN(array, fromIndex); } - var index = (fromIndex || 0) - 1, + var index = fromIndex - 1, length = array.length; while (++index < length) { @@ -340,26 +340,6 @@ 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 - * corresponding values. - * - * @private - * @param {Array} array The array to sort. - * @param {Function} comparer The function to define sort order. - * @returns {Array} Returns `array`. - */ - function baseSortBy(array, comparer) { - var length = array.length; - - array.sort(comparer); - while (length--) { - array[length] = array[length].value; - } - return array; - } - /** * Converts `value` to a string if it is not one. An empty string is returned * for `null` or `undefined` values. @@ -433,24 +413,34 @@ } /** - * Used by `_.sortByAll` to compare multiple properties of each element - * in a collection and stable sort them in ascending order. + * Used by `_.sortByOrder` to compare multiple properties of each element + * in a collection and stable sort them in the following order: + * + * If orders is unspecified, sort in ascending order for all properties. + * Otherwise, for each property, sort in ascending order if its corresponding value in + * orders is true, and descending order if false. * * @private * @param {Object} object The object to compare to `other`. * @param {Object} other The object to compare to `object`. + * @param {boolean[]} orders The order to sort by for each property. * @returns {number} Returns the sort order indicator for `object`. */ - function compareMultipleAscending(object, other) { + function compareMultiple(object, other, orders) { var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, - length = objCriteria.length; + length = objCriteria.length, + ordersLength = orders.length; while (++index < length) { var result = baseCompareAscending(objCriteria[index], othCriteria[index]); if (result) { - return result; + if (index >= ordersLength) { + return result; + } else { + return orders[index] ? result : result * -1; + } } } // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications @@ -503,13 +493,13 @@ * * @private * @param {Array} array The array to search. - * @param {number} [fromIndex] The index to search from. + * @param {number} fromIndex The index to search from. * @param {boolean} [fromRight] Specify iterating from right to left. * @returns {number} Returns the index of the matched `NaN`, else `-1`. */ function indexOfNaN(array, fromIndex, fromRight) { var length = array.length, - index = fromRight ? (fromIndex || length) : ((fromIndex || 0) - 1); + index = fromIndex + (fromRight ? 0 : -1); while ((fromRight ? index-- : ++index < length)) { var other = array[index]; @@ -830,26 +820,26 @@ * `mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`, * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`, - * `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `splice`, `spread`, - * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, - * `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`, - * `unshift`, `unzip`, `values`, `valuesIn`, `where`, `without`, `wrap`, `xor`, - * `zip`, and `zipObject` + * `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, + * `spread`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, + * `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, `transform`, + * `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`, + * `without`, `wrap`, `xor`, `zip`, and `zipObject` * * The wrapper methods that are **not** chainable by default are: - * `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, + * `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, - * `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, - * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`, - * `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, + * `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`, + * `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, + * `isFinite`,`isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`, * `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, * `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`, * `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, - * `startCase`, `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, - * `trunc`, `unescape`, `uniqueId`, `value`, and `words` + * `startCase`, `startsWith`, `sum`, `template`, `trim`, `trimLeft`, + * `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words` * * The wrapper method `sample` will return a wrapped value when `n` is provided, * otherwise an unwrapped value is returned. @@ -1136,16 +1126,22 @@ while (++iterIndex < iterLength) { var data = iteratees[iterIndex], iteratee = data.iteratee, - computed = iteratee(value, index, array), type = data.type; + if (type != LAZY_DROP_WHILE_FLAG) { + var computed = iteratee(value); + } else { + data.done = data.done && (isRight ? index < data.index : index > data.index); + data.index = index; + computed = data.done || (data.done = !iteratee(value)); + } if (type == LAZY_MAP_FLAG) { value = computed; } else if (!computed) { - if (type == LAZY_FILTER_FLAG) { - continue outer; - } else { + if (type == LAZY_TAKE_WHILE_FLAG) { break outer; + } else { + continue outer; } } } @@ -1825,7 +1821,7 @@ } result.push(value); } - else if (indexOf(values, value) < 0) { + else if (indexOf(values, value, 0) < 0) { result.push(value); } } @@ -1978,13 +1974,13 @@ * * @private * @param {Array} array The array to flatten. - * @param {boolean} [isDeep] Specify a deep flatten. - * @param {boolean} [isStrict] Restrict flattening to arrays and `arguments` objects. - * @param {number} [fromIndex=0] The index to start from. + * @param {boolean} isDeep Specify a deep flatten. + * @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects. + * @param {number} fromIndex The index to start from. * @returns {Array} Returns the new flattened array. */ function baseFlatten(array, isDeep, isStrict, fromIndex) { - var index = (fromIndex || 0) - 1, + var index = fromIndex - 1, length = array.length, resIndex = -1, result = []; @@ -1995,7 +1991,7 @@ if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) { if (isDeep) { // Recursively flatten arrays (susceptible to call stack limits). - value = baseFlatten(value, isDeep, isStrict); + value = baseFlatten(value, isDeep, isStrict, 0); } var valIndex = -1, valLength = value.length; @@ -2609,6 +2605,55 @@ return !!result; } + /** + * The base implementation of `_.sortBy` which uses `comparer` to define + * the sort order of `array` and replaces criteria objects with their + * corresponding values. + * + * @private + * @param {Array} array The array to sort. + * @param {Function} comparer The function to define sort order. + * @returns {Array} Returns `array`. + */ + function baseSortBy(array, comparer) { + var length = array.length; + + array.sort(comparer); + while (length--) { + array[length] = array[length].value; + } + return array; + } + + /** + * The base implementation of `_.sortByOrder` without param guards. + * + * @private + * @param {Array|Object|string} collection The collection to iterate over. + * @param {string[]} props The property names to sort by. + * @param {boolean[]} orders The sort orders of `props`. + * @returns {Array} Returns the new sorted array. + */ + function baseSortByOrder(collection, props, orders) { + var index = -1, + length = collection.length, + result = isLength(length) ? Array(length) : []; + + baseEach(collection, function(value) { + var length = props.length, + criteria = Array(length); + + while (length--) { + criteria[length] = value == null ? undefined : value[props[length]]; + } + result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; + }); + + return baseSortBy(result, function(object, other) { + return compareMultiple(object, other, orders); + }); + } + /** * The base implementation of `_.uniq` without support for callback shorthands * and `this` binding. @@ -2651,7 +2696,7 @@ } result.push(value); } - else if (indexOf(seen, computed) < 0) { + else if (indexOf(seen, computed, 0) < 0) { if (iteratee || isLarge) { seen.push(computed); } @@ -2955,24 +3000,31 @@ */ function createAssigner(assigner) { return function() { - var length = arguments.length, - object = arguments[0]; + var args = arguments, + length = args.length, + object = args[0]; if (length < 2 || object == null) { return object; } - if (length > 3 && isIterateeCall(arguments[1], arguments[2], arguments[3])) { - length = 2; + var customizer = args[length - 2], + thisArg = args[length - 1], + guard = args[3]; + + if (length > 3 && typeof customizer == 'function') { + customizer = bindCallback(customizer, thisArg, 5); + length -= 2; + } else { + customizer = (length > 2 && typeof thisArg == 'function') ? thisArg : null; + length -= (customizer ? 1 : 0); } - // Juggle arguments. - if (length > 3 && typeof arguments[length - 2] == 'function') { - var customizer = bindCallback(arguments[--length - 1], arguments[length--], 5); - } else if (length > 2 && typeof arguments[length - 1] == 'function') { - customizer = arguments[--length]; + if (guard && isIterateeCall(args[1], args[2], guard)) { + customizer = length == 3 ? null : customizer; + length = 2; } var index = 0; while (++index < length) { - var source = arguments[index]; + var source = args[index]; if (source) { assigner(object, source, customizer); } @@ -3010,6 +3062,41 @@ return new SetCache(values); }; + /** + * Creates a function to compose other functions into a single function. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new composer function. + */ + function createComposer(fromRight) { + return function() { + var length = arguments.length, + index = length, + fromIndex = fromRight ? length - 1 : 0; + + if (!length) { + return function() { return arguments[0]; }; + } + var funcs = Array(length); + while (index--) { + funcs[index] = arguments[index]; + if (typeof funcs[index] != 'function') { + throw new TypeError(FUNC_ERROR_TEXT); + } + } + return function() { + var index = fromIndex, + result = funcs[index].apply(this, arguments); + + while ((fromRight ? index-- : ++index < length)) { + result = funcs[index].call(this, result); + } + return result; + }; + }; + } + /** * Creates a function that produces compound words out of the words in a * given string. @@ -4079,16 +4166,17 @@ * // => [1, 3] */ function difference() { - var index = -1, - length = arguments.length; + var args = arguments, + index = -1, + length = args.length; while (++index < length) { - var value = arguments[index]; + var value = args[index]; if (isArray(value) || isArguments(value)) { break; } } - return baseDifference(value, baseFlatten(arguments, false, true, ++index)); + return baseDifference(value, baseFlatten(args, false, true, ++index)); } /** @@ -4200,7 +4288,7 @@ * ]; * * // using the `_.matches` callback shorthand - * _.pluck(_.dropRightWhile(users, { 'user': pebbles, 'active': false }), 'user'); + * _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user'); * // => ['barney', 'fred'] * * // using the `_.matchesProperty` callback shorthand @@ -4411,7 +4499,7 @@ * * // using the `_.matchesProperty` callback shorthand * _.findLastIndex(users, 'active', false); - * // => 1 + * // => 2 * * // using the `_.property` callback shorthand * _.findLastIndex(users, 'active'); @@ -4474,7 +4562,7 @@ if (guard && isIterateeCall(array, isDeep, guard)) { isDeep = false; } - return length ? baseFlatten(array, isDeep) : []; + return length ? baseFlatten(array, isDeep, false, 0) : []; } /** @@ -4492,7 +4580,7 @@ */ function flattenDeep(array) { var length = array ? array.length : 0; - return length ? baseFlatten(array, true) : []; + return length ? baseFlatten(array, true, false, 0) : []; } /** @@ -4533,14 +4621,14 @@ return -1; } if (typeof fromIndex == 'number') { - fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0); + fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; } else if (fromIndex) { var index = binaryIndex(array, value), other = array[index]; return (value === value ? value === other : other !== other) ? index : -1; } - return baseIndexOf(array, value, fromIndex); + return baseIndexOf(array, value, fromIndex || 0); } /** @@ -4603,11 +4691,11 @@ outer: while (++index < length) { value = array[index]; - if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value)) < 0) { + if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { argsIndex = argsLength; while (--argsIndex) { var cache = caches[argsIndex]; - if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) { + if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value, 0)) < 0) { continue outer; } } @@ -4712,17 +4800,19 @@ * // => [1, 1] */ function pull() { - var array = arguments[0]; + var args = arguments, + array = args[0]; + if (!(array && array.length)) { return array; } var index = 0, indexOf = getIndexOf(), - length = arguments.length; + length = args.length; while (++index < length) { var fromIndex = 0, - value = arguments[index]; + value = args[index]; while ((fromIndex = indexOf(array, value, fromIndex)) > -1) { splice.call(array, fromIndex, 1); @@ -5152,7 +5242,7 @@ * // => [1, 2, 4] */ function union() { - return baseUniq(baseFlatten(arguments, false, true)); + return baseUniq(baseFlatten(arguments, false, true, 0)); } /** @@ -6223,104 +6313,6 @@ return func(collection, iteratee); } - /** - * Gets the maximum value of `collection`. If `collection` is empty or falsey - * `-Infinity` is returned. If an iteratee function is provided it is invoked - * for each value in `collection` to generate the criterion by which the value - * is ranked. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the maximum value. - * @example - * - * _.max([4, 2, 8, 6]); - * // => 8 - * - * _.max([]); - * // => -Infinity - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * _.max(users, function(chr) { - * return chr.age; - * }); - * // => { 'user': 'fred', 'age': 40 }; - * - * // using the `_.property` callback shorthand - * _.max(users, 'age'); - * // => { 'user': 'fred', 'age': 40 }; - */ - var max = createExtremum(arrayMax); - - /** - * Gets the minimum value of `collection`. If `collection` is empty or falsey - * `Infinity` is returned. If an iteratee function is provided it is invoked - * for each value in `collection` to generate the criterion by which the value - * is ranked. The `iteratee` is bound to `thisArg` and invoked with three - * arguments; (value, index, collection). - * - * If a property name is provided for `predicate` the created `_.property` - * style callback returns the property value of the given element. - * - * If a value is also provided for `thisArg` the created `_.matchesProperty` - * style callback returns `true` for elements that have a matching property - * value, else `false`. - * - * If an object is provided for `predicate` the created `_.matches` style - * callback returns `true` for elements that have the properties of the given - * object, else `false`. - * - * @static - * @memberOf _ - * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee] The function invoked per iteration. - * @param {*} [thisArg] The `this` binding of `iteratee`. - * @returns {*} Returns the minimum value. - * @example - * - * _.min([4, 2, 8, 6]); - * // => 2 - * - * _.min([]); - * // => Infinity - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * _.min(users, function(chr) { - * return chr.age; - * }); - * // => { 'user': 'barney', 'age': 36 }; - * - * // using the `_.property` callback shorthand - * _.min(users, 'age'); - * // => { 'user': 'barney', 'age': 36 }; - */ - var min = createExtremum(arrayMin, true); - /** * Creates an array of elements split into two groups, the first of which * contains elements `predicate` returns truthy for, while the second of which @@ -6356,7 +6348,7 @@ * _.partition([1.2, 2.3, 3.4], function(n) { * return this.floor(n) % 2; * }, Math); - * // => [[1, 3], [2]] + * // => [[1.2, 3.4], [2.3]] * * var users = [ * { 'user': 'barney', 'age': 36, 'active': false }, @@ -6596,8 +6588,8 @@ } /** - * Gets the size of `collection` by returning `collection.length` for - * array-like values or the number of own enumerable properties for objects. + * Gets the size of `collection` by returning its length for array-like + * values or the number of own enumerable properties for objects. * * @static * @memberOf _ @@ -6727,8 +6719,11 @@ * // => ['barney', 'fred', 'pebbles'] */ function sortBy(collection, iteratee, thisArg) { + if (collection == null) { + return []; + } var index = -1, - length = collection ? collection.length : 0, + length = collection.length, result = isLength(length) ? Array(length) : []; if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { @@ -6765,25 +6760,58 @@ * // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]] */ function sortByAll(collection) { - var args = arguments; - if (args.length > 3 && isIterateeCall(args[1], args[2], args[3])) { - args = [collection, args[1]]; + if (collection == null) { + return []; } - var index = -1, - length = collection ? collection.length : 0, - props = baseFlatten(args, false, false, 1), - result = isLength(length) ? Array(length) : []; + var args = arguments, + guard = args[3]; - baseEach(collection, function(value) { - var length = props.length, - criteria = Array(length); + if (guard && isIterateeCall(args[1], args[2], guard)) { + args = [collection, args[1]]; + } + return baseSortByOrder(collection, baseFlatten(args, false, false, 1), []); + } - while (length--) { - criteria[length] = value == null ? undefined : value[props[length]]; - } - result[++index] = { 'criteria': criteria, 'index': index, 'value': value }; - }); - return baseSortBy(result, compareMultipleAscending); + /** + * This method is like `_.sortByAll` except that it allows specifying the + * sort orders of the property names to sort by. A truthy value in `orders` + * will sort the corresponding property name in ascending order while a + * falsey value will sort it in descending order. + * + * @static + * @memberOf _ + * @category Collection + * @param {Array|Object|string} collection The collection to iterate over. + * @param {string[]} props The property names to sort by. + * @param {boolean[]} orders The sort orders of `props`. + * @returns {Array} Returns the new sorted array. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 }, + * { 'user': 'barney', 'age': 26 }, + * { 'user': 'fred', 'age': 30 } + * ]; + * + * // sort by `user` in ascending order and by `age` in descending order + * _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values); + * // => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]] + */ + function sortByOrder(collection, props, orders, guard) { + if (collection == null) { + return []; + } + if (guard && isIterateeCall(props, orders, guard)) { + orders = null; + } + if (!isArray(props)) { + props = props == null ? [] : [props]; + } + if (!isArray(orders)) { + orders = orders == null ? [] : [orders]; + } + return baseSortByOrder(collection, props, orders); } /** @@ -7406,38 +7434,15 @@ * @returns {Function} Returns the new function. * @example * - * function add(x, y) { - * return x + y; - * } - * * function square(n) { * return n * n; * } * - * var addSquare = _.flow(add, square); + * var addSquare = _.flow(_.add, square); * addSquare(1, 2); * // => 9 */ - function flow() { - var funcs = arguments, - length = funcs.length; - - if (!length) { - return function() { return arguments[0]; }; - } - if (!arrayEvery(funcs, baseIsFunction)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function() { - var index = 0, - result = funcs[index].apply(this, arguments); - - while (++index < length) { - result = funcs[index].call(this, result); - } - return result; - }; - } + var flow = createComposer(); /** * This method is like `_.flow` except that it creates a function that @@ -7451,38 +7456,15 @@ * @returns {Function} Returns the new function. * @example * - * function add(x, y) { - * return x + y; - * } - * * function square(n) { * return n * n; * } * - * var addSquare = _.flowRight(square, add); + * var addSquare = _.flowRight(square, _.add); * addSquare(1, 2); * // => 9 */ - function flowRight() { - var funcs = arguments, - fromIndex = funcs.length - 1; - - if (fromIndex < 0) { - return function() { return arguments[0]; }; - } - if (!arrayEvery(funcs, baseIsFunction)) { - throw new TypeError(FUNC_ERROR_TEXT); - } - return function() { - var index = fromIndex, - result = funcs[index].apply(this, arguments); - - while (index--) { - result = funcs[index].call(this, result); - } - return result; - }; - } + var flowRight = createComposer(true); /** * Creates a function that memoizes the result of `func`. If `resolver` is @@ -7542,13 +7524,14 @@ throw new TypeError(FUNC_ERROR_TEXT); } var memoized = function() { - var cache = memoized.cache, - key = resolver ? resolver.apply(this, arguments) : arguments[0]; + var args = arguments, + cache = memoized.cache, + key = resolver ? resolver.apply(this, args) : args[0]; if (cache.has(key)) { return cache.get(key); } - var result = func.apply(this, arguments); + var result = func.apply(this, args); cache.set(key, result); return result; }; @@ -8063,7 +8046,7 @@ } /** - * Checks if a value is empty. A value is considered empty unless it is an + * Checks if `value` is empty. A value is considered empty unless it is an * `arguments` object, array, string, or jQuery-like collection with a length * greater than `0` or an object with own enumerable properties. * @@ -8678,7 +8661,7 @@ /** * Assigns own enumerable properties of source object(s) to the destination * object for all destination properties that resolve to `undefined`. Once a - * property is set, additional defaults of the same property are ignored. + * property is set, additional values of the same property are ignored. * * @static * @memberOf _ @@ -9468,7 +9451,7 @@ /** * 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`. + * `end` is not specified it is set to `start` with `start` then set to `0`. * * @static * @memberOf _ @@ -9666,7 +9649,7 @@ } /** - * Converts the characters "&", "<", ">", '"', "'", and '`', in `string` to + * Converts the characters "&", "<", ">", '"', "'", and "\`", in `string` to * their corresponding HTML entities. * * **Note:** No other characters are escaped. To escape additional characters @@ -10469,14 +10452,14 @@ * } */ function attempt() { - var length = arguments.length, - func = arguments[0]; + var func = arguments[0], + length = arguments.length, + args = Array(length ? length - 1 : 0); + while (--length > 0) { + args[length - 1] = arguments[length]; + } try { - 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); @@ -10805,9 +10788,9 @@ /** * Creates an array of numbers (positive and/or negative) progressing from - * `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. + * `start` up to, but not including, `end`. If `end` is not specified it is + * set to `start` with `start` then set to `0`. If `start` is less than `end` + * a zero-length range is created unless a negative `step` is specified. * * @static * @memberOf _ @@ -10934,6 +10917,153 @@ /*------------------------------------------------------------------------*/ + /** + * Adds two numbers. + * + * @static + * @memberOf _ + * @category Math + * @param {number} augend The first number to add. + * @param {number} addend The second number to add. + * @returns {number} Returns the sum. + * @example + * + * _.add(6, 4); + * // => 10 + */ + function add(augend, addend) { + return augend + addend; + } + + /** + * Gets the maximum value of `collection`. If `collection` is empty or falsey + * `-Infinity` is returned. If an iteratee function is provided it is invoked + * for each value in `collection` to generate the criterion by which the value + * is ranked. The `iteratee` is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Math + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the maximum value. + * @example + * + * _.max([4, 2, 8, 6]); + * // => 8 + * + * _.max([]); + * // => -Infinity + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * _.max(users, function(chr) { + * return chr.age; + * }); + * // => { 'user': 'fred', 'age': 40 }; + * + * // using the `_.property` callback shorthand + * _.max(users, 'age'); + * // => { 'user': 'fred', 'age': 40 }; + */ + var max = createExtremum(arrayMax); + + /** + * Gets the minimum value of `collection`. If `collection` is empty or falsey + * `Infinity` is returned. If an iteratee function is provided it is invoked + * for each value in `collection` to generate the criterion by which the value + * is ranked. The `iteratee` is bound to `thisArg` and invoked with three + * arguments; (value, index, collection). + * + * If a property name is provided for `predicate` the created `_.property` + * style callback returns the property value of the given element. + * + * If a value is also provided for `thisArg` the created `_.matchesProperty` + * style callback returns `true` for elements that have a matching property + * value, else `false`. + * + * If an object is provided for `predicate` the created `_.matches` style + * callback returns `true` for elements that have the properties of the given + * object, else `false`. + * + * @static + * @memberOf _ + * @category Math + * @param {Array|Object|string} collection The collection to iterate over. + * @param {Function|Object|string} [iteratee] The function invoked per iteration. + * @param {*} [thisArg] The `this` binding of `iteratee`. + * @returns {*} Returns the minimum value. + * @example + * + * _.min([4, 2, 8, 6]); + * // => 2 + * + * _.min([]); + * // => Infinity + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * _.min(users, function(chr) { + * return chr.age; + * }); + * // => { 'user': 'barney', 'age': 36 }; + * + * // using the `_.property` callback shorthand + * _.min(users, 'age'); + * // => { 'user': 'barney', 'age': 36 }; + */ + var min = createExtremum(arrayMin, true); + + /** + * Gets the sum of the values in `collection`. + * + * @static + * @memberOf _ + * @category Math + * @param {Array|Object|string} collection The collection to iterate over. + * @returns {number} Returns the sum. + * @example + * + * _.sum([4, 6, 2]); + * // => 12 + * + * _.sum({ 'a': 4, 'b': 6, 'c': 2 }); + * // => 12 + */ + function sum(collection) { + if (!isArray(collection)) { + collection = toIterable(collection); + } + var length = collection.length, + result = 0; + + while (length--) { + result += +collection[length] || 0; + } + return result; + } + + /*------------------------------------------------------------------------*/ + // Ensure wrappers are instances of `baseLodash`. lodash.prototype = baseLodash.prototype; @@ -11032,6 +11162,7 @@ lodash.slice = slice; lodash.sortBy = sortBy; lodash.sortByAll = sortByAll; + lodash.sortByOrder = sortByOrder; lodash.spread = spread; lodash.take = take; lodash.takeRight = takeRight; @@ -11076,6 +11207,7 @@ /*------------------------------------------------------------------------*/ // Add functions that return unwrapped values when chaining. + lodash.add = add; lodash.attempt = attempt; lodash.camelCase = camelCase; lodash.capitalize = capitalize; @@ -11145,6 +11277,7 @@ lodash.sortedLastIndex = sortedLastIndex; lodash.startCase = startCase; lodash.startsWith = startsWith; + lodash.sum = sum; lodash.template = template; lodash.trim = trim; lodash.trimLeft = trimLeft; @@ -11206,15 +11339,17 @@ }); // Add `LazyWrapper` methods that accept an `iteratee` value. - arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { - var isFilter = index == LAZY_FILTER_FLAG || index == LAZY_WHILE_FLAG; + arrayEach(['dropWhile', 'filter', 'map', 'takeWhile'], function(methodName, type) { + var isFilter = type != LAZY_MAP_FLAG, + isDropWhile = type == LAZY_DROP_WHILE_FLAG; LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { - var result = this.clone(), + var filtered = this.__filtered__, + result = (filtered && isDropWhile) ? new LazyWrapper(this) : this.clone(), iteratees = result.__iteratees__ || (result.__iteratees__ = []); - result.__filtered__ = result.__filtered__ || isFilter; - iteratees.push({ 'iteratee': getCallback(iteratee, thisArg, 3), 'type': index }); + result.__filtered__ = filtered || isFilter; + iteratees.push({ 'done': false, 'index': 0, 'iteratee': getCallback(iteratee, thisArg, 1), 'type': type }); return result; }; }); @@ -11279,23 +11414,10 @@ return this.filter(identity); }; - LazyWrapper.prototype.dropWhile = function(predicate, thisArg) { - var done, - lastIndex, - isRight = this.__dir__ < 0; - - predicate = getCallback(predicate, thisArg, 3); - return this.filter(function(value, index, array) { - done = done && (isRight ? index < lastIndex : index > lastIndex); - lastIndex = index; - return done || (done = !predicate(value, index, array)); - }); - }; - LazyWrapper.prototype.reject = function(predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); - return this.filter(function(value, index, array) { - return !predicate(value, index, array); + predicate = getCallback(predicate, thisArg, 1); + return this.filter(function(value) { + return !predicate(value); }); }; @@ -11317,16 +11439,24 @@ // Add `LazyWrapper` methods to `lodash.prototype`. baseForOwn(LazyWrapper.prototype, function(func, methodName) { var lodashFunc = lodash[methodName], + checkIteratee = /^(?:filter|map|reject)|While$/.test(methodName), retUnwrapped = /^(?:first|last)$/.test(methodName); lodash.prototype[methodName] = function() { - var value = this.__wrapped__, - args = arguments, + var args = arguments, + length = args.length, chainAll = this.__chain__, + value = this.__wrapped__, isHybrid = !!this.__actions__.length, isLazy = value instanceof LazyWrapper, - onlyLazy = isLazy && !isHybrid; + iteratee = args[0], + useLazy = isLazy || isArray(value); + if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { + // avoid lazy use if the iteratee has a `length` other than `1` + isLazy = useLazy = false; + } + var onlyLazy = isLazy && !isHybrid; if (retUnwrapped && !chainAll) { return onlyLazy ? func.call(value) @@ -11337,7 +11467,7 @@ push.apply(otherArgs, args); return lodashFunc.apply(lodash, otherArgs); }; - if (isLazy || isArray(value)) { + if (useLazy) { var wrapper = onlyLazy ? value : new LazyWrapper(this), result = func.apply(wrapper, args); diff --git a/lodash.min.js b/lodash.min.js index e5abf6319b..a691b0d255 100644 --- a/lodash.min.js +++ b/lodash.min.js @@ -1,89 +1,89 @@ /** * @license - * lodash 3.3.1 (Custom Build) lodash.com/license | Underscore.js 1.8.2 underscorejs.org/LICENSE + * lodash 3.4.0 (Custom Build) lodash.com/license | Underscore.js 1.8.2 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 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||0,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),-1u.__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,e,u=0>this.__dir__;return n=ne(n,t,3),this.filter(function(t,o,i){return r=r&&(u?oe),e=o,r||(r=!n(t,o,i))}) -},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 +;(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 _(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,0)&&u.push(a);return u}function or(n,t){var r=n?n.length:0;if(!ae(r))return _r(n,t);for(var e=-1,u=ge(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,0)&&((r||f)&&a.push(s),c.push(l))}return c}function Wr(n,t){for(var r=-1,e=t.length,u=wu(e);++r>>1,i=n[o]; +(r?i<=t:ir||null==e)return e;var u=t[r-2],o=t[r-1],i=t[3];for(3=o&&f<=i&&(e=I&&t>u||e>u&&t>=I)||o)&&(t&w&&(r[2]=p[2],f|=e&w?0:A),(e=p[3])&&(u=r[3],r[3]=u?Lr(u,e,p[4]):Bt(e),r[4]=u?_(r[3],L):Bt(p[4])),(e=p[5])&&(u=r[5],r[5]=u?Br(u,e,p[6]):Bt(e),r[6]=u?_(r[5],L):Bt(p[6])),(e=p[7])&&(r[7]=Bt(e)),t&O&&(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==w?Mr(r[0],r[2]):t!=E&&t!=(w|E)||r[4].length?Yr.apply(m,r):Gr.apply(m,r),r)}function Xr(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 te(n,t,r){var e=Wt.callback||gu,e=e===gu?tr:e;return r?e(n,t,r):e}function re(n,r,e){var u=Wt.indexOf||we,u=u===we?t:u;return n?u(n,r,e):u}function ee(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 ue(n){return n=n.constructor,typeof n=="function"&&n instanceof n||(n=Ru),new n +}function oe(n,t,r){var e=n.constructor;switch(t){case G:return $r(n);case D:case M:return new e(+n);case J:case X:case H:case Q:case nt:case tt:case rt:case et:case ut:return t=n.buffer,new e(r?$r(t):t,n.byteOffset,n.length);case K:case Z:return new e(n);case Y:var u=new e(n.source,vt.exec(n));u.lastIndex=n.lastIndex}return u}function ie(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?fe(n,t,r):null==t)&&(t=1),t=e-(+t||0),Rr(n,0,0>t?0:t)):[]}function me(n,t,r){var e=-1,u=n?n.length:0;for(t=te(t,r,3);++ee?oo(u+e,0):e;else if(e)return e=Nr(n,r),n=n[e],(r===r?r===n:n!==n)?e:-1;return t(n,r,e||0)}function xe(n){return de(n,1)}function Ae(n,r,e,u){if(!n||!n.length)return[];null!=r&&typeof r!="boolean"&&(u=e,e=fe(n,r,u)?null:r,r=false); +var o=te();if((o!==tr||null!=e)&&(e=o(e,u,3)),r&&re()==t){r=e;var i;e=-1,u=n.length;for(var o=-1,f=[];++e>>0,e=wu(r);++tr?oo(e+r,0):r||0:0,typeof n=="string"||!So(n)&&ru(n)?rarguments.length,or)}function Fe(n,t,r,e){return(So(n)?Zt:Er)(n,te(t,e,4),r,3>arguments.length,ir)}function $e(n,t,r){return(r?fe(n,t,r):null==t)?(n=_e(n),t=n.length,0t?0:+t||0,n.length),n) +}function Le(n){n=_e(n);for(var t=-1,r=n.length,e=wu(r);++t=r||r>t?(f&&Pu(f),r=p,f=s=p=m,r&&(h=Co(),a=n.apply(l,i),s||f||(i=l=null))):s=Ju(e,r)}function u(){s&&Pu(s),f=s=p=m,(g||_!==t)&&(h=Co(),a=n.apply(l,i),s||f||(i=l=null)) +}function o(){if(i=arguments,c=Co(),l=this,p=g&&(s||!v),false===_)var r=v&&!s;else{f||v||(h=c);var o=_-(c-h),d=0>=o||o>_;d?(f&&(f=Pu(f)),h=c,a=n.apply(l,i)):f||(f=Ju(u,o))}return d&&s?s=Pu(s):s||t===_||(s=Ju(e,t)),r&&(d=true,a=n.apply(l,i)),!d||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($);if(t=0>t?0:+t||0,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=m +},o}function Ve(n,t){function r(){var e=arguments,u=r.cache,o=t?t.apply(this,e):e[0];return u.has(o)?u.get(o):(e=n.apply(this,e),u.set(o,e),e)}if(typeof n!="function"||t&&typeof t!="function")throw new Cu($);return r.cache=new Ve.Cache,r}function Ye(n){var t=Rr(arguments,1),r=_(t,Ye.placeholder);return Jr(n,E,null,t,r)}function Ze(n){var t=Rr(arguments,1),r=_(t,Ze.placeholder);return Jr(n,R,null,t,r)}function Ge(n){return ae(p(n)?n.length:m)&&Lu.call(n)==B||false}function Je(n){return n&&1===n.nodeType&&p(n)&&-1t||!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 u=n;return(n=e(n))?(r?fe(u,t,r):null==t)?n.slice(g(n),v(n)+1):(t+="",n.slice(o(n,t),i(n,t)+1)):n}function hu(n,t,r){return r&&fe(n,t,r)&&(t=null),n=e(n),n.match(t||Et)||[]}function _u(){for(var n=arguments[0],t=arguments.length,r=wu(t?t-1:0);0<--t;)r[t-1]=arguments[t];try{return n.apply(m,r)}catch(e){return Xe(e)?e:new Au(e)}}function gu(n,t,r){return r&&fe(n,t,r)&&(t=null),p(n)?yu(n):tr(n,t) +}function vu(n){return function(){return n}}function du(n){return n}function yu(n){return wr(rr(n,true))}function mu(n,t,r){if(null==r){var e=He(t),u=e&&Lo(t);((u=u&&u.length&&vr(t,u))?u.length:e)||(u=false,r=t,t=n,n=this)}u||(u=vr(t,Lo(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,bo=Wt.support={};!function(n){bo.funcDecomp=!Qe(h.WinRTError)&&jt.test(y),bo.funcNames=typeof ju.name=="string";try{bo.dom=11===Su.createDocumentFragment().nodeType +}catch(t){bo.dom=false}try{bo.nonEnumArgs=!Zu.call(arguments,1)}catch(r){bo.nonEnumArgs=true}}(0,0),Wt.templateSettings={escape:pt,evaluate:ht,interpolate:_t,variable:"",imports:{_:Wt}};var wo=function(){function n(){}return function(t){if(He(t)){n.prototype=t;var r=new n;n.prototype=null}return r||h.Object()}}(),xo=mo?function(n,t){return mo.set(n,t),n}:du;Mu||($r=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 $t(n)}:vu(null),jo=mo?function(n){return mo.get(n)}:bu,ko=function(){var n=0,t=0;return function(r,e){var u=Co(),o=S-(u-t);if(t=u,0=W)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=zr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Co=fo||function(){return(new xu).getTime()},To=qr(),Wo=qr(true),So=to||function(n){return p(n)&&ae(n.length)&&Lu.call(n)==z||false +};bo.dom||(Je=function(n){return n&&1===n.nodeType&&p(n)&&!Fo(n)||false});var No=ao||function(n){return typeof n=="number"&&eo(n)},Uo=r(/x/)||Hu&&!r(Hu)?function(n){return Lu.call(n)==P}:r,Fo=Vu?function(n){if(!n||Lu.call(n)!=V)return false;var t=n.valueOf,r=Qe(t)&&(r=Vu(t))&&Vu(r);return r?n==r||Vu(n)==r:pe(n)}:pe,$o=Dr(Ht),Lo=uo?function(n){if(n)var t=n.constructor,r=n.length;return typeof t=="function"&&t.prototype===n||typeof n!="function"&&r&&ae(r)?he(n):He(n)?uo(n):[]}:he,Bo=Dr(Ar),zo=Pr(function(n,t,r){return t=t.toLowerCase(),n+(r?t.charAt(0).toUpperCase()+t.slice(1):t) +}),Do=Pr(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()});8!=co(Rt+"08")&&(lu=function(n,t,r){return(r?fe(n,t,r):null==t)?t=0:t&&(t=+t),n=pu(n),co(n,t||(yt.test(n)?16:10))});var Mo=Pr(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),qo=Pr(function(n,t,r){return n+(r?" ":"")+(t.charAt(0).toUpperCase()+t.slice(1))}),Po=Vr(Vt),Ko=Vr(function(n){for(var t=-1,r=n.length,e=po;++t--n?t.apply(this,arguments):void 0 +}},Wt.ary=function(n,t,r){return r&&fe(n,t,r)&&(t=null),t=n&&null==t?n.length:oo(+t||0,0),Jr(n,O,null,null,null,null,t)},Wt.assign=$o,Wt.at=function(n){return ae(n?n.length:0)&&(n=_e(n)),Qt(n,lr(arguments,false,false,1))},Wt.before=ze,Wt.bind=De,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?Lt(s,f):o(l,f,0))){for(r=e;--r;){var p=u[r];if(0>(p?Lt(p,f):o(n[r],f,0)))continue n}s&&s.push(f),l.push(f) +}return l},Wt.invert=function(n,t,r){r&&fe(n,t,r)&&(t=null),r=-1;for(var e=Lo(n),u=e.length,o={};++rt?0:t)):[]},Wt.takeRight=function(n,t,r){var e=n?n.length:0;return e?((r?fe(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=te(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=te(t,r,3);++un||!eo(n))return[];var e=-1,u=wu(io(n,ho));for(t=Fr(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))&&st.test(n)?n.replace(ct,c):n},Wt.escapeRegExp=cu,Wt.every=Ie,Wt.find=Ce,Wt.findIndex=me,Wt.findKey=function(n,t,r){return t=te(t,r,3),cr(n,t,_r,true)},Wt.findLast=function(n,t,r){return t=te(t,r,3),cr(n,t,ir)},Wt.findLastIndex=function(n,t,r){var e=n?n.length:0; +for(t=te(t,r,3);e--;)if(t(n[e],e,n))return e;return-1},Wt.findLastKey=function(n,t,r){return t=te(t,r,3),cr(n,t,gr,true)},Wt.findWhere=function(n,t){return Ce(n,wr(t))},Wt.first=be,Wt.has=function(n,t){return n?Fu.call(n,t):false},Wt.identity=du,Wt.includes=Se,Wt.indexOf=we,Wt.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 s(n,u,true);for(;u--;)if(n[u]===t)return u;return-1},Wt.max=Po,Wt.min=Ko,Wt.noConflict=function(){return h._=Bu,this},Wt.noop=bu,Wt.now=Co,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.sum=function(n){So(n)||(n=_e(n));for(var t=n.length,r=0;t--;)r+=+n[t]||0;return r},Wt.template=function(n,t,r){var u=Wt.templateSettings;r&&fe(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=Lo(r),a=Wr(r,f),c=0;r=t.interpolate||wt;var s="__p+='";r=Iu((t.escape||wt).source+"|"+r.source+"|"+(r===_t?gt:wt).source+"|"+(t.evaluate||wt).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),s+=n.slice(c,a).replace(kt,l),r&&(o=true,s+="'+__e("+r+")+'"),f&&(i=true,s+="';"+f+";\n__p+='"),e&&(s+="'+((__t=("+e+"))==null?'':__t)+'"),c=a+t.length,t}),s+="';",(t=t.variable)||(s="with(obj){"+s+"}"),s=(i?s.replace(ot,""):s).replace(it,"$1").replace(ft,"$1;"),s="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(o?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+s+"return __p}",t=_u(function(){return ju(f,p+"return "+s).apply(m,a) +}),t.source=s,Xe(t))throw t;return t},Wt.trim=pu,Wt.trimLeft=function(n,t,r){var u=n;return(n=e(n))?n.slice((r?fe(u,t,r):null==t)?g(n):o(n,t+"")):n},Wt.trimRight=function(n,t,r){var u=n;return(n=e(n))?(r?fe(u,t,r):null==t)?n.slice(0,v(n)+1):n.slice(0,i(n,t+"")+1):n},Wt.trunc=function(n,t,r){r&&fe(n,t,r)&&(t=null);var u=C;if(r=T,null!=t)if(He(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(tu(o)){if(n.slice(u).search(o)){var i,f=n.slice(0,u);for(o.global||(o=Iu(o.source,(vt.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),-1u.__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?wr:jr;Ut.prototype[n]=function(n){return this[r](e(n))}}),Ut.prototype.compact=function(){return this.filter(du)},Ut.prototype.reject=function(n,t){return n=te(n,t,1),this.filter(function(t){return!n(t) +})},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=/^(?:filter|map|reject)|While$/.test(t),u=/^(?:first|last)$/.test(t);Wt.prototype[t]=function(){function t(n){return n=[n],Yu.apply(n,o),r.apply(Wt,n)}var o=arguments,i=this.__chain__,f=this.__wrapped__,a=!!this.__actions__.length,c=f instanceof Ut,l=o[0],s=c||So(f); +return s&&e&&typeof l=="function"&&1!=l.length&&(c=s=false),c=c&&!a,u&&!i?c?n.call(f):r.call(Wt,this.value()):s?(f=n.apply(c?f:new Ut(this),o),u||!a&&!f.__actions__||(f.__actions__||(f.__actions__=[])).push({func:Re,args:[t],thisArg:Wt}),new Nt(f,i)):this.thru(t)}}),Mt("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);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?Bt(n):null,e.__dir__=this.__dir__,e.__dropCount__=this.__dropCount__,e.__filtered__=this.__filtered__,e.__iteratees__=t?Bt(t):null,e.__takeCount__=this.__takeCount__,e.__views__=r?Bt(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 Sr(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;++ih.index),h.index=i,h=h.done||(h.done=!_(p))),g==U)p=h;else if(!h){if(g==F)break n;continue n}}u?u--:l[c++]=p}return l},Wt.prototype.chain=function(){return Ee(this)},Wt.prototype.commit=function(){return new Nt(this.value(),this.__chain__)},Wt.prototype.plant=function(n){for(var t,r=this;r instanceof St;){var e=ve(r);t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},Wt.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof Ut?(this.__actions__.length&&(n=new Ut(this)),new Nt(n.reverse(),this.__chain__)):this.thru(function(n){return n.reverse() +})},Wt.prototype.toString=function(){return this.value()+""},Wt.prototype.run=Wt.prototype.toJSON=Wt.prototype.valueOf=Wt.prototype.value=function(){return Sr(this.__wrapped__,this.__actions__)},Wt.prototype.collect=Wt.prototype.map,Wt.prototype.head=Wt.prototype.first,Wt.prototype.select=Wt.prototype.filter,Wt.prototype.tail=Wt.prototype.rest,Wt}var m,b="3.4.0",w=1,x=2,A=4,j=8,k=16,E=32,R=64,I=128,O=256,C=30,T="...",W=150,S=16,N=0,U=2,F=3,$="Expected a function",L="__lodash_placeholder__",B="[object Arguments]",z="[object Array]",D="[object Boolean]",M="[object Date]",q="[object Error]",P="[object Function]",K="[object Number]",V="[object Object]",Y="[object RegExp]",Z="[object String]",G="[object ArrayBuffer]",J="[object Float32Array]",X="[object Float64Array]",H="[object Int8Array]",Q="[object Int16Array]",nt="[object Int32Array]",tt="[object Uint8Array]",rt="[object Uint8ClampedArray]",et="[object Uint16Array]",ut="[object Uint32Array]",ot=/\b__p\+='';/g,it=/\b(__p\+=)''\+/g,ft=/(__e\(.*?\)|\b__t\))\+'';/g,at=/&(?:amp|lt|gt|quot|#39|#96);/g,ct=/[&<>"'`]/g,lt=RegExp(at.source),st=RegExp(ct.source),pt=/<%-([\s\S]+?)%>/g,ht=/<%([\s\S]+?)%>/g,_t=/<%=([\s\S]+?)%>/g,gt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vt=/\w*$/,dt=/^\s*function[ \n\r\t]+\w/,yt=/^0[xX]/,mt=/^\[object .+?Constructor\]$/,bt=/[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g,wt=/($^)/,xt=/[.*+?^${}()|[\]\/\\]/g,At=RegExp(xt.source),jt=/\bthis\b/,kt=/['\n\r\u2028\u2029\\]/g,Et=RegExp("[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?=[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"),Rt=" \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",It="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(" "),Ot={}; +Ot[J]=Ot[X]=Ot[H]=Ot[Q]=Ot[nt]=Ot[tt]=Ot[rt]=Ot[et]=Ot[ut]=true,Ot[B]=Ot[z]=Ot[G]=Ot[D]=Ot[M]=Ot[q]=Ot[P]=Ot["[object Map]"]=Ot[K]=Ot[V]=Ot[Y]=Ot["[object Set]"]=Ot[Z]=Ot["[object WeakMap]"]=false;var Ct={};Ct[B]=Ct[z]=Ct[G]=Ct[D]=Ct[M]=Ct[J]=Ct[X]=Ct[H]=Ct[Q]=Ct[nt]=Ct[K]=Ct[V]=Ct[Y]=Ct[Z]=Ct[tt]=Ct[rt]=Ct[et]=Ct[ut]=true,Ct[q]=Ct[P]=Ct["[object Map]"]=Ct["[object Set]"]=Ct["[object WeakMap]"]=false;var Tt={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"},St={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},Nt={"&":"&","<":"<",">":">",""":'"',"'":"'","`":"`"},Ut={"function":true,object:true},Ft={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},$t=Ut[typeof exports]&&exports&&!exports.nodeType&&exports,Lt=Ut[typeof module]&&module&&!module.nodeType&&module,Ut=Ut[typeof window]&&window,Bt=Lt&&Lt.exports===$t&&$t,zt=$t&&Lt&&typeof global=="object"&&global||Ut!==(this&&this.window)&&Ut||this,Dt=y(); +typeof define=="function"&&typeof define.amd=="object"&&define.amd?(zt._=Dt, define(function(){return Dt})):$t&&Lt?Bt?(Lt.exports=Dt)._=Dt:$t._=Dt:zt._=Dt}).call(this); \ No newline at end of file diff --git a/lodash.src.js b/lodash.src.js index 4bfd9ec4f7..549b11e1a3 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -1,6 +1,6 @@ /** * @license - * lodash 3.3.1 + * lodash 3.4.0 * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.8.2 * 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.3.1'; + var VERSION = '3.4.0'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, From ab2269717dcb05feb791f5131a133f0f34f7e92d Mon Sep 17 00:00:00 2001 From: jdalton Date: Sat, 28 Feb 2015 21:53:11 -0800 Subject: [PATCH 46/46] Bump to v3.4.0. --- LICENSE.txt | 2 +- README.md | 6 +++--- bower.json | 2 +- component.json | 2 +- package.json | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 17764328c8..9cd87e5dce 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ Copyright 2012-2015 The Dojo Foundation -Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas, +Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors Permission is hereby granted, free of charge, to any person obtaining diff --git a/README.md b/README.md index 3d87f86d4c..bfd1518d17 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash v3.3.1 +# lodash v3.4.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/). @@ -16,8 +16,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.3.1-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.3.1-amd) builds - * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.3.1-es) build + * AMD modules for [modern](https://github.com/lodash/lodash/tree/3.4.0-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.4.0-amd) builds + * ES modules for the [modern](https://github.com/lodash/lodash/tree/3.4.0-es) build ## Further Reading diff --git a/bower.json b/bower.json index 6e519dd669..bed2376d0b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "3.3.1", + "version": "3.4.0", "main": "lodash.js", "ignore": [ ".*", diff --git a/component.json b/component.json index 09c584e2d4..a2f4d892c5 100644 --- a/component.json +++ b/component.json @@ -1,7 +1,7 @@ { "name": "lodash", "repo": "lodash/lodash", - "version": "3.3.1", + "version": "3.4.0", "description": "The modern build of lodash.", "license": "MIT", "main": "lodash.js", diff --git a/package.json b/package.json index 14d4ee3248..27413bd7fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash", - "version": "3.3.1", + "version": "3.4.0", "main": "lodash.src.js", "private": true, "devDependencies": {