diff --git a/lodash.js b/lodash.js index e4b3fbf29..9493acef0 100644 --- a/lodash.js +++ b/lodash.js @@ -1709,9 +1709,9 @@ * The base implementation of `_.forEach` without support for callback shorthands. * * @private - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object|string} Returns `collection`. + * @returns {Array|Object} Returns `collection`. */ var baseEach = createBaseEach(baseForOwn); @@ -1719,9 +1719,9 @@ * The base implementation of `_.forEachRight` without support for callback shorthands. * * @private - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. - * @returns {Array|Object|string} Returns `collection`. + * @returns {Array|Object} Returns `collection`. */ var baseEachRight = createBaseEach(baseForOwnRight, true); @@ -1729,7 +1729,7 @@ * The base implementation of `_.every` without support for callback shorthands. * * @private - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false` */ @@ -1776,7 +1776,7 @@ * The base implementation of `_.filter` without support for callback shorthands. * * @private - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {Array} Returns the new filtered array. */ @@ -1796,7 +1796,7 @@ * using the provided `eachFunc`. * * @private - * @param {Array|Object|string} collection The collection to search. + * @param {Array|Object} collection The collection to search. * @param {Function} predicate The function invoked per iteration. * @param {Function} eachFunc The function to iterate over `collection`. * @param {boolean} [retKey] Specify returning the key of the found element instead of the element itself. @@ -2162,7 +2162,7 @@ * The base implementation of `_.map` without support for callback shorthands. * * @private - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the new mapped array. */ @@ -2446,7 +2446,7 @@ * `eachFunc`. * * @private - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} accumulator The initial value. * @param {boolean} initFromCollection Specify using the first or last element of `collection` as the initial value. @@ -2510,7 +2510,7 @@ * The base implementation of `_.some` without support for callback shorthands. * * @private - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. */ @@ -2548,7 +2548,7 @@ * The base implementation of `_.sortByOrder` without param guards. * * @private - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. * @param {string[]} orders The sort orders of `iteratees`. * @returns {Array} Returns the new sorted array. @@ -5714,7 +5714,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. * @returns {Object} Returns the composed aggregate object. * @example @@ -5738,7 +5738,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. * @returns {boolean} Returns `true` if all elements pass the predicate check, else `false`. @@ -5780,7 +5780,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. * @returns {Array} Returns the new filtered array. * @example @@ -5820,7 +5820,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to search. + * @param {Array|Object} collection The collection to search. * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. * @returns {*} Returns the matched element, else `undefined`. * @example @@ -5864,7 +5864,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to search. + * @param {Array|Object} collection The collection to search. * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. * @returns {*} Returns the matched element, else `undefined`. * @example @@ -5896,9 +5896,9 @@ * @memberOf _ * @alias each * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array|Object|string} Returns `collection`. + * @returns {Array|Object} Returns `collection`. * @example * * _([1, 2]).forEach(function(value) { @@ -5925,9 +5925,9 @@ * @memberOf _ * @alias eachRight * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @returns {Array|Object|string} Returns `collection`. + * @returns {Array|Object} Returns `collection`. * @example * * _.forEachRight([1, 2], function(value) { @@ -5950,7 +5950,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. * @returns {Object} Returns the composed aggregate object. * @example @@ -5981,7 +5981,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to search. + * @param {Array|Object} collection The collection to search. * @param {*} target The value to search for. * @param {number} [fromIndex=0] The index to search from. * @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`. @@ -6022,7 +6022,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. * @returns {Object} Returns the composed aggregate object. * @example @@ -6053,7 +6053,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Array|Function|string} path The path of the method to invoke or * the function invoked per iteration. * @param {...*} [args] The arguments to invoke the method with. @@ -6096,7 +6096,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. * @returns {Array} Returns the new mapped array. * @example @@ -6134,7 +6134,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. * @returns {Array} Returns the array of grouped elements. * @example @@ -6186,7 +6186,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @param {*} [accumulator] The initial value. * @returns {*} Returns the accumulated value. @@ -6217,7 +6217,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function} [iteratee=_.identity] The function invoked per iteration. * @param {*} [accumulator] The initial value. * @returns {*} Returns the accumulated value. @@ -6244,7 +6244,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. * @returns {Array} Returns the new filtered array. * @example @@ -6285,7 +6285,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to sample. + * @param {Array|Object} collection The collection to sample. * @param {number} [n] The number of elements to sample. * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. * @returns {*} Returns the random sample(s). @@ -6327,7 +6327,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to shuffle. + * @param {Array|Object} collection The collection to shuffle. * @returns {Array} Returns the new shuffled array. * @example * @@ -6345,7 +6345,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to inspect. + * @param {Array|Object} collection The collection to inspect. * @returns {number} Returns the size of `collection`. * @example * @@ -6374,7 +6374,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function|Object|string} [predicate=_.identity] The function invoked per iteration. * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`. * @returns {boolean} Returns `true` if any element passes the predicate check, else `false`. @@ -6418,7 +6418,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {...(Function|Function[]|Object|Object[]|string|string[])} [iteratees=[_.identity]] * The iteratees to sort by, specified individually or in arrays. * @returns {Array} Returns the new sorted array. @@ -6466,7 +6466,7 @@ * @static * @memberOf _ * @category Collection - * @param {Array|Object|string} collection The collection to iterate over. + * @param {Array|Object} collection The collection to iterate over. * @param {Function[]|Object[]|string[]} [iteratees=[_.identity]] The iteratees to sort by. * @param {string[]} [orders] The sort orders of `iteratees`. * @param- {Object} [guard] Enables use as an iteratee for functions like `_.reduce`. diff --git a/test/test.js b/test/test.js index e02c0b27f..8843069c0 100644 --- a/test/test.js +++ b/test/test.js @@ -1100,16 +1100,6 @@ var actual = _.at(new Foo, 'b'); deepEqual(actual, [2]); }); - - _.each({ - 'literal': 'abc', - 'object': Object('abc') - }, - function(object, key) { - test('should work with a string ' + key + ' for `object`', 1, function() { - deepEqual(_.at(object, [2, 0]), ['c', 'a']); - }); - }); }(1, 2, 3)); /*--------------------------------------------------------------------------*/ @@ -4057,25 +4047,6 @@ }); } }()); - - (function() { - var expected = ({ - 'find': 'a', - 'findLast': 'b', - 'findIndex': 0, - 'findLastIndex': 1 - })[methodName]; - - if (expected != null) { - test('should work with a string for `collection`', 1, function() { - var actual = func('abc', function(chr, index) { - return index < 2; - }); - - strictEqual(actual, expected); - }); - } - }()); }); /*--------------------------------------------------------------------------*/ @@ -4982,43 +4953,6 @@ skipTest(); } }); - - _.each({ - 'literal': 'abc', - 'object': Object('abc') - }, - function(collection, key) { - test('`_.' + methodName + '` should work with a string ' + key + ' for `collection` (test in IE < 9)', 6, function() { - if (func) { - var args, - values = [], - expectedChars = ['a', 'b', 'c']; - - var expectedArgs = isObject - ? (isRight ? ['c', '2', collection] : ['a', '0', collection]) - : (isRight ? ['c', 2, collection] : ['a', 0, collection]); - - var actual = func(collection, function(value) { - args || (args = slice.call(arguments)); - values.push(value); - }); - - var stringObject = args[2]; - - ok(_.isString(stringObject)); - ok(_.isObject(stringObject)); - - deepEqual([stringObject[0], stringObject[1], stringObject[2]], expectedChars); - deepEqual(args, expectedArgs); - deepEqual(values, isRight ? ['c', 'b', 'a'] : expectedChars); - - strictEqual(actual, collection); - } - else { - skipTest(6); - } - }); - }); }); _.each(collectionMethods, function(methodName) { @@ -5591,12 +5525,6 @@ }); }); - test('should return `true` for string indexes (test in IE < 9)', 2, function() { - _.each([1, [1]], function(path) { - strictEqual(_.has('xo', path), true); - }); - }); - test('should treat sparse arrays as dense', 1, function() { strictEqual(_.has(Array(1), 0), true); }); @@ -7550,15 +7478,6 @@ deepEqual(actual, [false, true]); }); - test('should work with strings', 4, function() { - var pairs = [['xo', Object('x')], [Object('xo'), 'x']]; - - _.each(pairs, function(pair) { - strictEqual(_.isMatch(pair[0], pair[1]), true); - strictEqual(_.isMatch(pair[1], pair[0]), false); - }); - }); - test('should return `true` when comparing a `source` of empty arrays and objects', 1, function() { var objects = [{ 'a': [1], 'b': { 'c': 1 } }, { 'a': [2, 3], 'b': { 'd': 2 } }], source = { 'a': [], 'b': {} }; @@ -8935,7 +8854,7 @@ } }); - test('`_.' + methodName + '` should work with string objects (test in IE < 9)', 1, function() { + test('`_.' + methodName + '` should work with string objects', 1, function() { deepEqual(func(Object('abc')).sort(), ['0', '1', '2']); }); @@ -9781,18 +9700,6 @@ deepEqual(actual, [false, true]); }); - test('should work with strings', 4, function() { - var pairs = [['xo', Object('x')], [Object('xo'), 'x']]; - - _.each(pairs, function(pair) { - var matches = _.matches(pair[1]); - strictEqual(matches(pair[0]), true); - - matches = _.matches(pair[0]); - strictEqual(matches(pair[1]), false); - }); - }); - test('should match problem JScript properties (test in IE < 9)', 1, function() { var matches = _.matches(shadowObject), objects = [{}, shadowObject], @@ -9860,13 +9767,6 @@ deepEqual(actual, expected); }); - test('should match characters of string indexes (test in IE < 9)', 2, function() { - var matches = _.matchesProperty(1, 'o'); - _.each(['xo', Object('xo')], function(string) { - strictEqual(matches(string), true); - }); - }); - test('should match a key over a path', 2, function() { var object = { 'a.b.c': 3, 'a': { 'b': { 'c': 4 } } }; @@ -10091,18 +9991,6 @@ deepEqual(actual, [false, true]); }); - test('should work with strings', 4, function() { - var pairs = [['xo', Object('x')], [Object('xo'), 'x']]; - - _.each(pairs, function(pair) { - var matches = _.matchesProperty('0', pair[1]); - strictEqual(matches(pair[0]), true); - - matches = _.matchesProperty('0', pair[0]); - strictEqual(matches(pair[1]), false); - }); - }); - test('should match properties when `value` is not a plain object', 1, function() { function Foo(object) { _.assign(this, object); } @@ -12220,13 +12108,6 @@ }); }); - test('should pluck string indexes (test in IE < 9)', 2, function() { - _.each([1, [1]], function(path) { - var prop = _.property(path); - strictEqual(prop('xo'), 'o'); - }); - }); - test('should pluck a key over a path', 2, function() { var object = { 'a.b.c': 3, 'a': { 'b': { 'c': 4 } } }; @@ -12339,14 +12220,6 @@ }); }); - test('should pluck string indexes (test in IE < 9)', 2, function() { - var propOf = _.propertyOf('xo'); - - _.each([1, [1]], function(path) { - strictEqual(propOf(path), 'o'); - }); - }); - test('should pluck a key over a path', 2, function() { var object = { 'a.b.c': 3, 'a': { 'b': { 'c': 4 } } }, propOf = _.propertyOf(object); @@ -12779,24 +12652,6 @@ deepEqual(args, expected); }); - - _.each({ - 'literal': 'abc', - 'object': Object('abc') - }, - function(collection, key) { - test('should work with a string ' + key + ' for `collection` (test in IE < 9)', 2, function() { - var args; - - var actual = _.reduce(collection, function(accumulator, value) { - args || (args = slice.call(arguments)); - return accumulator + value; - }); - - deepEqual(args, ['a', 'b', 1, collection]); - strictEqual(actual, 'abc'); - }); - }); }()); /*--------------------------------------------------------------------------*/ @@ -12853,24 +12708,6 @@ deepEqual(args, expected); }); - - _.each({ - 'literal': 'abc', - 'object': Object('abc') - }, - function(collection, key) { - test('should work with a string ' + key + ' for `collection` (test in IE < 9)', 2, function() { - var args; - - var actual = _.reduceRight(collection, function(accumulator, value) { - args || (args = slice.call(arguments)); - return accumulator + value; - }); - - deepEqual(args, ['c', 'b', 1, collection]); - strictEqual(actual, 'cba'); - }); - }); }()); /*--------------------------------------------------------------------------*/ @@ -13235,20 +13072,6 @@ }); }); - test('`_.' + methodName + '` should get characters of string indexes (test in IE < 9)', 8, function() { - _.each([1, [1]], function(path) { - _.each(['xo', Object('xo')], function(string) { - strictEqual(func(string, path), 'o'); - }); - }); - - _.each([{ 'a': 'xo' }, { 'a': Object('xo') }], function(object) { - _.each(['a[1]', ['a', '1']], function(path) { - strictEqual(func(object, path), 'o'); - }); - }); - }); - test('`_.' + methodName + '` should get a key over a path', 2, function() { var object = { 'a.b.c': 3, 'a': { 'b': { 'c': 4 } } }; @@ -13719,20 +13542,6 @@ skipTest(2); } }); - - _.each({ - 'literal': 'abc', - 'object': Object('abc') - }, - function(collection, key) { - test('should work with a string ' + key + ' for `collection`', 2, function() { - var actual = _.sample(collection); - ok(_.includes(collection, actual)); - - actual = _.sample(collection, 2); - ok(actual.length == 2 && actual[0] !== actual[1] && _.includes(collection, actual[0]) && _.includes(collection, actual[1])); - }); - }); }()); /*--------------------------------------------------------------------------*/ @@ -13908,17 +13717,6 @@ test('should treat number values for `collection` as empty', 1, function() { deepEqual(_.shuffle(1), []); }); - - _.each({ - 'literal': 'abc', - 'object': Object('abc') - }, - function(collection, key) { - test('should work with a string ' + key + ' for `collection`', 1, function() { - var actual = _.shuffle(collection); - deepEqual(actual.sort(), ['a','b', 'c']); - }); - }); }()); /*--------------------------------------------------------------------------*/ @@ -13975,16 +13773,6 @@ test('should fix the JScript `[[DontEnum]]` bug (test in IE < 9)', 1, function() { strictEqual(_.size(shadowObject), 7); }); - - _.each({ - 'literal': 'abc', - 'object': Object('abc') - }, - function(collection, key) { - test('should work with a string ' + key + ' for `collection`', 1, function() { - deepEqual(_.size(collection), 3); - }); - }); }(1, 2, 3)); /*--------------------------------------------------------------------------*/ @@ -15701,7 +15489,7 @@ deepEqual(_.toArray(object), array); }); - test('should work with a string for `collection` (test in Opera < 10.52)', 2, function() { + test('should work with a string for `collection`', 2, function() { deepEqual(_.toArray('ab'), ['a', 'b']); deepEqual(_.toArray(Object('ab')), ['a', 'b']); });