From 1bfe25f1a5e1441995922d24d7b290fd6243c8dd Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 6 Jul 2015 10:05:56 -0700 Subject: [PATCH] Remove aliases and rename `_.callback` to `_.iteratee`. --- lodash.src.js | 265 +++++------ test/test.js | 1258 +++++++++++++++++++++++-------------------------- 2 files changed, 711 insertions(+), 812 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 37c52b206..3662e75c8 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -1786,34 +1786,6 @@ return object; } - /** - * The base implementation of `_.callback` which supports specifying the - * number of arguments to provide to `func`. - * - * @private - * @param {*} [func=_.identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of `func`. - * @param {number} [argCount] The number of arguments to provide to `func`. - * @returns {Function} Returns the callback. - */ - function baseCallback(func, thisArg, argCount) { - var type = typeof func; - if (type == 'function') { - return thisArg === undefined - ? func - : bindCallback(func, thisArg, argCount); - } - if (func == null) { - return identity; - } - if (type == 'object') { - return baseMatches(func); - } - return thisArg === undefined - ? property(func) - : baseMatchesProperty(func, thisArg); - } - /** * The base implementation of `_.clone` without support for argument juggling * and `this` binding `customizer` functions. @@ -2142,6 +2114,34 @@ return result; } + /** + * The base implementation of `_.iteratee` which supports specifying the + * number of arguments to provide to `func`. + * + * @private + * @param {*} [func=_.identity] The value to convert to an iteratee. + * @param {*} [thisArg] The `this` binding of `func`. + * @param {number} [argCount] The number of arguments to provide to `func`. + * @returns {Function} Returns the iteratee. + */ + function baseIteratee(func, thisArg, argCount) { + var type = typeof func; + if (type == 'function') { + return thisArg === undefined + ? func + : bindCallback(func, thisArg, argCount); + } + if (func == null) { + return identity; + } + if (type == 'object') { + return baseMatches(func); + } + return thisArg === undefined + ? property(func) + : baseMatchesProperty(func, thisArg); + } + /** * The base implementation of `baseForIn` and `baseForOwn` which iterates * over `object` properties returned by `keysFunc` invoking `iteratee` for @@ -2769,7 +2769,7 @@ * @returns {Array} Returns the new sorted array. */ function baseSortByOrder(collection, iteratees, orders) { - var callback = getCallback(), + var callback = getIteratee(), index = -1; iteratees = arrayMap(iteratees, function(iteratee) { return callback(iteratee); }); @@ -3000,7 +3000,7 @@ } /** - * A specialized version of `baseCallback` which only supports `this` binding + * A specialized version of `baseIteratee` which only supports `this` binding * and specifying the number of arguments to provide to `func`. * * @private @@ -3123,7 +3123,7 @@ function createAggregator(setter, initializer) { return function(collection, iteratee, thisArg) { var result = initializer ? initializer() : {}; - iteratee = getCallback(iteratee, thisArg, 3); + iteratee = getIteratee(iteratee, thisArg, 3); if (isArray(collection)) { var index = -1, @@ -3364,7 +3364,7 @@ if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { iteratee = undefined; } - iteratee = getCallback(iteratee, thisArg, 3); + iteratee = getIteratee(iteratee, thisArg, 3); if (iteratee.length == 1) { collection = isArray(collection) ? collection : toIterable(collection); var result = arrayExtremum(collection, iteratee, comparator, exValue); @@ -3386,7 +3386,7 @@ */ function createFind(eachFunc, fromRight) { return function(collection, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); + predicate = getIteratee(predicate, thisArg, 3); if (isArray(collection)) { var index = baseFindIndex(collection, predicate, fromRight); return index > -1 ? collection[index] : undefined; @@ -3407,7 +3407,7 @@ if (!(array && array.length)) { return -1; } - predicate = getCallback(predicate, thisArg, 3); + predicate = getIteratee(predicate, thisArg, 3); return baseFindIndex(array, predicate, fromRight); }; } @@ -3421,7 +3421,7 @@ */ function createFindKey(objectFunc) { return function(object, predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 3); + predicate = getIteratee(predicate, thisArg, 3); return baseFind(object, predicate, objectFunc, true); }; } @@ -3539,7 +3539,7 @@ function createObjectMapper(isMapKeys) { return function(object, iteratee, thisArg) { var result = {}; - iteratee = getCallback(iteratee, thisArg, 3); + iteratee = getIteratee(iteratee, thisArg, 3); baseForOwn(object, function(value, key, object) { var mapped = iteratee(value, key, object); @@ -3593,7 +3593,7 @@ var initFromArray = arguments.length < 3; return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection)) ? arrayFunc(collection, iteratee, accumulator, initFromArray) - : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc); + : baseReduce(collection, getIteratee(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc); }; } @@ -3772,8 +3772,8 @@ */ function createSortedIndex(retHighest) { return function(array, value, iteratee, thisArg) { - var callback = getCallback(iteratee); - return (iteratee == null && callback === baseCallback) + var callback = getIteratee(iteratee); + return (iteratee == null && callback === baseIteratee) ? binaryIndex(array, value, retHighest) : binaryIndexBy(array, value, callback(iteratee, thisArg, 1), retHighest); }; @@ -3989,21 +3989,6 @@ return true; } - /** - * Gets the appropriate "callback" function. If the `_.callback` method is - * customized this function returns the custom method, otherwise it returns - * the `baseCallback` function. If arguments are provided the chosen function - * is invoked with them and its result is returned. - * - * @private - * @returns {Function} Returns the chosen function or its result. - */ - function getCallback(func, thisArg, argCount) { - var result = lodash.callback || callback; - result = result === callback ? baseCallback : result; - return argCount ? result(func, thisArg, argCount) : result; - } - /** * Gets metadata for `func`. * @@ -4052,6 +4037,21 @@ return collection ? result(collection, target, fromIndex) : result; } + /** + * Gets the appropriate "iteratee" function. If the `_.iteratee` method is + * customized this function returns the custom method, otherwise it returns + * the `baseIteratee` function. If arguments are provided the chosen function + * is invoked with them and its result is returned. + * + * @private + * @returns {Function} Returns the chosen function or its result. + */ + function getIteratee(func, thisArg, argCount) { + var result = lodash.iteratee || iteratee; + result = result === iteratee ? baseIteratee : result; + return argCount ? result(func, thisArg, argCount) : result; + } + /** * Gets the "length" property value of `object`. * @@ -4825,7 +4825,7 @@ */ function dropRightWhile(array, predicate, thisArg) { return (array && array.length) - ? baseWhile(array, getCallback(predicate, thisArg, 3), true, true) + ? baseWhile(array, getIteratee(predicate, thisArg, 3), true, true) : []; } @@ -4880,7 +4880,7 @@ */ function dropWhile(array, predicate, thisArg) { return (array && array.length) - ? baseWhile(array, getCallback(predicate, thisArg, 3), true) + ? baseWhile(array, getIteratee(predicate, thisArg, 3), true) : []; } @@ -5399,7 +5399,7 @@ indexes = [], length = array.length; - predicate = getCallback(predicate, thisArg, 3); + predicate = getIteratee(predicate, thisArg, 3); while (++index < length) { var value = array[index]; if (predicate(value, index, array)) { @@ -5649,7 +5649,7 @@ */ function takeRightWhile(array, predicate, thisArg) { return (array && array.length) - ? baseWhile(array, getCallback(predicate, thisArg, 3), false, true) + ? baseWhile(array, getIteratee(predicate, thisArg, 3), false, true) : []; } @@ -5704,7 +5704,7 @@ */ function takeWhile(array, predicate, thisArg) { return (array && array.length) - ? baseWhile(array, getCallback(predicate, thisArg, 3)) + ? baseWhile(array, getIteratee(predicate, thisArg, 3)) : []; } @@ -5786,8 +5786,8 @@ iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted; isSorted = false; } - var callback = getCallback(); - if (!(iteratee == null && callback === baseCallback)) { + var callback = getIteratee(); + if (!(iteratee == null && callback === baseIteratee)) { iteratee = callback(iteratee, thisArg, 3); } return (isSorted && getIndexOf() === baseIndexOf) @@ -6420,7 +6420,7 @@ predicate = undefined; } if (typeof predicate != 'function' || thisArg !== undefined) { - predicate = getCallback(predicate, thisArg, 3); + predicate = getIteratee(predicate, thisArg, 3); } return func(collection, predicate); } @@ -6476,7 +6476,7 @@ */ function filter(collection, predicate, thisArg) { var func = isArray(collection) ? arrayFilter : baseFilter; - predicate = getCallback(predicate, thisArg, 3); + predicate = getIteratee(predicate, thisArg, 3); return func(collection, predicate); } @@ -6877,7 +6877,7 @@ */ function map(collection, iteratee, thisArg) { var func = isArray(collection) ? arrayMap : baseMap; - iteratee = getCallback(iteratee, thisArg, 3); + iteratee = getIteratee(iteratee, thisArg, 3); return func(collection, iteratee); } @@ -7072,7 +7072,7 @@ */ function reject(collection, predicate, thisArg) { var func = isArray(collection) ? arrayFilter : baseFilter; - predicate = getCallback(predicate, thisArg, 3); + predicate = getIteratee(predicate, thisArg, 3); return func(collection, function(value, index, collection) { return !predicate(value, index, collection); }); @@ -7217,7 +7217,7 @@ predicate = undefined; } if (typeof predicate != 'function' || thisArg !== undefined) { - predicate = getCallback(predicate, thisArg, 3); + predicate = getIteratee(predicate, thisArg, 3); } return func(collection, predicate); } @@ -7278,7 +7278,7 @@ iteratee = undefined; } var index = -1; - iteratee = getCallback(iteratee, thisArg, 3); + iteratee = getIteratee(iteratee, thisArg, 3); var result = baseMap(collection, function(value, key, collection) { return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value }; @@ -10223,7 +10223,7 @@ */ function transform(object, iteratee, accumulator, thisArg) { var isArr = isArray(object) || isTypedArray(object); - iteratee = getCallback(iteratee, thisArg, 4); + iteratee = getIteratee(iteratee, thisArg, 4); if (accumulator == null) { if (isArr || isObject(object)) { @@ -11293,53 +11293,6 @@ } }); - /** - * 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 - * created callback returns the property value for a given element. If `func` - * is an object the created callback returns `true` for elements that contain - * the equivalent object properties, otherwise it returns `false`. - * - * @static - * @memberOf _ - * @alias iteratee - * @category Utility - * @param {*} [func=_.identity] The value to convert to a callback. - * @param {*} [thisArg] The `this` binding of `func`. - * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. - * @returns {Function} Returns the callback. - * @example - * - * var users = [ - * { 'user': 'barney', 'age': 36 }, - * { 'user': 'fred', 'age': 40 } - * ]; - * - * // wrap to create custom callback shorthands - * _.callback = _.wrap(_.callback, function(callback, func, thisArg) { - * var match = /^(.+?)__([gl]t)(.+)$/.exec(func); - * if (!match) { - * return callback(func, thisArg); - * } - * return function(object) { - * return match[2] == 'gt' - * ? object[match[1]] > match[3] - * : object[match[1]] < match[3]; - * }; - * }); - * - * _.filter(users, 'age__gt36'); - * // => [{ 'user': 'fred', 'age': 40 }] - */ - function callback(func, thisArg, guard) { - if (guard && isIterateeCall(func, thisArg, guard)) { - thisArg = undefined; - } - return isObjectLike(func) - ? matches(func) - : baseCallback(func, thisArg); - } - /** * Creates a function that returns `value`. * @@ -11381,6 +11334,53 @@ return value; } + /** + * 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 + * created callback returns the property value for a given element. If `func` + * is an object the created callback returns `true` for elements that contain + * the equivalent object properties, otherwise it returns `false`. + * + * @static + * @memberOf _ + * @alias iteratee + * @category Utility + * @param {*} [func=_.identity] The value to convert to a callback. + * @param {*} [thisArg] The `this` binding of `func`. + * @param- {Object} [guard] Enables use as a callback for functions like `_.map`. + * @returns {Function} Returns the callback. + * @example + * + * var users = [ + * { 'user': 'barney', 'age': 36 }, + * { 'user': 'fred', 'age': 40 } + * ]; + * + * // wrap to create custom callback shorthands + * _.iteratee = _.wrap(_.iteratee, function(callback, func, thisArg) { + * var match = /^(.+?)__([gl]t)(.+)$/.exec(func); + * if (!match) { + * return callback(func, thisArg); + * } + * return function(object) { + * return match[2] == 'gt' + * ? object[match[1]] > match[3] + * : object[match[1]] < match[3]; + * }; + * }); + * + * _.filter(users, 'age__gt36'); + * // => [{ 'user': 'fred', 'age': 40 }] + */ + function iteratee(func, thisArg, guard) { + if (guard && isIterateeCall(func, thisArg, guard)) { + thisArg = undefined; + } + return isObjectLike(func) + ? matches(func) + : baseIteratee(func, thisArg); + } + /** * Creates a function that performs a deep comparison between a given object * and `source`, returning `true` if the given object has equivalent property @@ -12018,7 +12018,7 @@ if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { iteratee = undefined; } - iteratee = getCallback(iteratee, thisArg, 3); + iteratee = getIteratee(iteratee, thisArg, 3); return iteratee.length == 1 ? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee) : baseSum(collection, iteratee); @@ -12056,7 +12056,6 @@ lodash.bind = bind; lodash.bindAll = bindAll; lodash.bindKey = bindKey; - lodash.callback = callback; lodash.chain = chain; lodash.chunk = chunk; lodash.compact = compact; @@ -12094,6 +12093,7 @@ lodash.intersection = intersection; lodash.invert = invert; lodash.invoke = invoke; + lodash.iteratee = iteratee; lodash.keys = keys; lodash.keysIn = keysIn; lodash.map = map; @@ -12159,18 +12159,8 @@ lodash.zipWith = zipWith; // Add aliases. - lodash.backflow = flowRight; - lodash.collect = map; - lodash.compose = flowRight; lodash.each = forEach; lodash.eachRight = forEachRight; - lodash.extend = assign; - lodash.iteratee = callback; - lodash.methods = functions; - lodash.object = zipObject; - lodash.select = filter; - lodash.tail = rest; - lodash.unique = uniq; // Add functions to `lodash.prototype`. mixin(lodash, lodash); @@ -12266,17 +12256,8 @@ lodash.uniqueId = uniqueId; lodash.words = words; - // Add aliases. - lodash.all = every; - lodash.any = some; - lodash.contains = includes; + // Add aliases lodash.eq = isEqual; - lodash.detect = find; - lodash.foldl = reduce; - lodash.foldr = reduceRight; - lodash.head = first; - lodash.include = includes; - lodash.inject = reduce; mixin(lodash, (function() { var source = {}; @@ -12348,7 +12329,7 @@ LazyWrapper.prototype[methodName] = function(iteratee, thisArg) { var result = this.clone(); - result.__iteratees__.push({ 'iteratee': getCallback(iteratee, thisArg, 1), 'type': type }); + result.__iteratees__.push({ 'iteratee': getIteratee(iteratee, thisArg, 1), 'type': type }); result.__filtered__ = result.__filtered__ || isFilter; return result; }; @@ -12387,7 +12368,7 @@ }; LazyWrapper.prototype.reject = function(predicate, thisArg) { - predicate = getCallback(predicate, thisArg, 1); + predicate = getIteratee(predicate, thisArg, 1); return this.filter(function(value) { return !predicate(value); }); @@ -12524,12 +12505,6 @@ lodash.prototype.toString = wrapperToString; lodash.prototype.run = lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; - // Add function aliases to the `lodash` wrapper. - lodash.prototype.collect = lodash.prototype.map; - lodash.prototype.head = lodash.prototype.first; - lodash.prototype.select = lodash.prototype.filter; - lodash.prototype.tail = lodash.prototype.rest; - return lodash; } diff --git a/test/test.js b/test/test.js index defbdb213..2f10be14b 100644 --- a/test/test.js +++ b/test/test.js @@ -1068,10 +1068,6 @@ var expected = { 'a': undefined }; deepEqual(_.assign({}, expected, _.identity), expected); }); - - test('should be aliased', 1, function() { - strictEqual(_.extend, _.assign); - }); }()); /*--------------------------------------------------------------------------*/ @@ -2212,17 +2208,6 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.flowRight'); - - (function() { - test('should be aliased', 2, function() { - strictEqual(_.backflow, _.flowRight); - strictEqual(_.compose, _.flowRight); - }); - }()); - - /*--------------------------------------------------------------------------*/ - QUnit.module('flow methods'); _.each(['flow', 'flowRight'], function(methodName) { @@ -2567,598 +2552,6 @@ /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.callback'); - - (function() { - test('should provide arguments to `func`', 3, function() { - var fn = function() { - var result = [this]; - push.apply(result, arguments); - return result; - }; - - var callback = _.callback(fn), - actual = callback('a', 'b', 'c', 'd', 'e', 'f'); - - ok(actual[0] === null || actual[0] && actual[0].Array); - deepEqual(actual.slice(1), ['a', 'b', 'c', 'd', 'e', 'f']); - - var object = {}; - callback = _.callback(fn, object); - actual = callback('a', 'b'); - - deepEqual(actual, [object, 'a', 'b']); - }); - - test('should return `_.identity` when `func` is nullish', 1, function() { - var object = {}, - values = [, null, undefined], - expected = _.map(values, _.constant([!isNpm && _.identity, object])); - - var actual = _.map(values, function(value, index) { - var identity = index ? _.callback(value) : _.callback(); - return [!isNpm && identity, identity(object)]; - }); - - deepEqual(actual, expected); - }); - - test('should not error when `func` is nullish and a `thisArg` is provided', 2, function() { - var object = {}; - - _.each([null, undefined], function(value) { - try { - var callback = _.callback(value, {}); - strictEqual(callback(object), object); - } catch(e) { - ok(false, e.message); - } - }); - }); - - test('should create a callback with a falsey `thisArg`', 1, function() { - var fn = function() { return this; }, - object = {}; - - var expected = _.map(falsey, function(value) { - var result = fn.call(value); - return (result && result.Array) ? object : result; - }); - - var actual = _.map(falsey, function(value) { - var callback = _.callback(fn, value), - result = callback(); - - return (result && result.Array) ? object : result; - }); - - ok(_.isEqual(actual, expected)); - }); - - test('should return a callback created by `_.matches` when `func` is an object', 2, function() { - var matches = _.callback({ 'a': 1, 'b': 2 }); - strictEqual(matches({ 'a': 1, 'b': 2, 'c': 3 }), true); - strictEqual(matches({ 'b': 2 }), false); - }); - - test('should return a callback created by `_.matches` when `func` is an array', 2, function() { - var matches = _.callback(['a', 'b']); - strictEqual(matches({ '0': 'a', '1': 'b', '2': 'c' }), true); - strictEqual(matches({ '1': 'b' }), false); - }); - - test('should not change match behavior if `source` is augmented', 9, function() { - var sources = [ - { 'a': { 'b': 2, 'c': 3 } }, - { 'a': 1, 'b': 2 }, - { 'a': 1 } - ]; - - _.each(sources, function(source, index) { - var object = _.cloneDeep(source), - matches = _.callback(source); - - strictEqual(matches(object), true); - - if (index) { - source.a = 2; - source.b = 1; - source.c = 3; - } else { - source.a.b = 1; - source.a.c = 2; - source.a.d = 3; - } - strictEqual(matches(object), true); - strictEqual(matches(source), false); - }); - }); - - test('should return a callback created by `_.matchesProperty` when `func` is a number or string and `thisArg` is not `undefined`', 3, function() { - var array = ['a'], - matches = _.callback(0, 'a'); - - strictEqual(matches(array), true); - - matches = _.callback('0', 'a'); - strictEqual(matches(array), true); - - matches = _.callback(1, undefined); - strictEqual(matches(array), undefined); - }); - - test('should support deep paths for `_.matchesProperty` shorthands', 1, function() { - var object = { 'a': { 'b': { 'c': { 'd': 1, 'e': 2 } } } }, - matches = _.callback('a.b.c', { 'e': 2 }); - - strictEqual(matches(object), true); - }); - - test('should return a callback created by `_.property` when `func` is a number or string', 2, function() { - var array = ['a'], - prop = _.callback(0); - - strictEqual(prop(array), 'a'); - - prop = _.callback('0'); - strictEqual(prop(array), 'a'); - }); - - test('should support deep paths for `_.property` shorthands', 1, function() { - var object = { 'a': { 'b': { 'c': 3 } } }, - prop = _.callback('a.b.c'); - - strictEqual(prop(object), 3); - }); - - test('should work with functions created by `_.partial` and `_.partialRight`', 2, function() { - var fn = function() { - var result = [this.a]; - push.apply(result, arguments); - return result; - }; - - var expected = [1, 2, 3], - object = { 'a': 1 }, - callback = _.callback(_.partial(fn, 2), object); - - deepEqual(callback(3), expected); - - callback = _.callback(_.partialRight(fn, 3), object); - deepEqual(callback(2), expected); - }); - - test('should support binding built-in methods', 2, function() { - var fn = function() {}, - object = { 'a': 1 }, - bound = fn.bind && fn.bind(object), - callback = _.callback(hasOwnProperty, object); - - strictEqual(callback('a'), true); - - if (bound) { - callback = _.callback(bound, object); - notStrictEqual(callback, bound); - } - else { - skipTest(); - } - }); - - test('should work as an iteratee for methods like `_.map`', 1, function() { - var fn = function() { return this instanceof Number; }, - array = [fn, fn, fn], - callbacks = _.map(array, _.callback), - expected = _.map(array, _.constant(false)); - - var actual = _.map(callbacks, function(callback) { - return callback(); - }); - - deepEqual(actual, expected); - }); - - test('should be aliased', 1, function() { - strictEqual(_.iteratee, _.callback); - }); - }()); - - /*--------------------------------------------------------------------------*/ - - QUnit.module('custom `_.callback` methods'); - - (function() { - var array = ['one', 'two', 'three'], - callback = _.callback, - getPropA = _.partial(_.property, 'a'), - getPropB = _.partial(_.property, 'b'), - getLength = _.partial(_.property, 'length'); - - var getSum = function() { - return function(result, object) { - return result + object.a; - }; - }; - - var objects = [ - { 'a': 0, 'b': 0 }, - { 'a': 1, 'b': 0 }, - { 'a': 1, 'b': 1 } - ]; - - test('`_.countBy` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getLength; - deepEqual(_.countBy(array), { '3': 2, '5': 1 }); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.dropRightWhile` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - deepEqual(_.dropRightWhile(objects), objects.slice(0, 2)); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.dropWhile` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - deepEqual(_.dropWhile(objects.reverse()).reverse(), objects.reverse().slice(0, 2)); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.every` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropA; - strictEqual(_.every(objects.slice(1)), true); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.filter` should use `_.callback` internally', 1, function() { - if (!isModularize) { - var objects = [{ 'a': 0 }, { 'a': 1 }]; - - _.callback = getPropA; - deepEqual(_.filter(objects), [objects[1]]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.find` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropA; - strictEqual(_.find(objects), objects[1]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.findIndex` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropA; - strictEqual(_.findIndex(objects), 1); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.findLast` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropA; - strictEqual(_.findLast(objects), objects[2]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.findLastIndex` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropA; - strictEqual(_.findLastIndex(objects), 2); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.findLastKey` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - strictEqual(_.findKey(objects), '2'); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.findKey` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - strictEqual(_.findLastKey(objects), '2'); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.groupBy` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getLength; - deepEqual(_.groupBy(array), { '3': ['one', 'two'], '5': ['three'] }); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.indexBy` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getLength; - deepEqual(_.indexBy(array), { '3': 'two', '5': 'three' }); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.map` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropA; - deepEqual(_.map(objects), [0, 1, 1]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.mapKeys` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - deepEqual(_.mapKeys({ 'a': { 'b': 1 } }), { '1': { 'b': 1 } }); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.mapValues` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - deepEqual(_.mapValues({ 'a': { 'b': 1 } }), { 'a': 1 }); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.max` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - deepEqual(_.max(objects), objects[2]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.min` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - deepEqual(_.min(objects), objects[0]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.partition` should use `_.callback` internally', 1, function() { - if (!isModularize) { - var objects = [{ 'a': 1 }, { 'a': 1 }, { 'b': 2 }]; - - _.callback = getPropA; - deepEqual(_.partition(objects), [objects.slice(0, 2), objects.slice(2)]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.reduce` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getSum; - strictEqual(_.reduce(objects, undefined, 0), 2); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.reduceRight` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getSum; - strictEqual(_.reduceRight(objects, undefined, 0), 2); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.reject` should use `_.callback` internally', 1, function() { - if (!isModularize) { - var objects = [{ 'a': 0 }, { 'a': 1 }]; - - _.callback = getPropA; - deepEqual(_.reject(objects), [objects[0]]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.remove` should use `_.callback` internally', 1, function() { - if (!isModularize) { - var objects = [{ 'a': 0 }, { 'a': 1 }]; - - _.callback = getPropA; - _.remove(objects); - deepEqual(objects, [{ 'a': 0 }]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.some` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - strictEqual(_.some(objects), true); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.sortBy` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropA; - deepEqual(_.sortBy(objects.slice().reverse()), [objects[0], objects[2], objects[1]]); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.sortedIndex` should use `_.callback` internally', 1, function() { - if (!isModularize) { - var objects = [{ 'a': 30 }, { 'a': 50 }]; - - _.callback = getPropA; - strictEqual(_.sortedIndex(objects, { 'a': 40 }), 1); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.sortedLastIndex` should use `_.callback` internally', 1, function() { - if (!isModularize) { - var objects = [{ 'a': 30 }, { 'a': 50 }]; - - _.callback = getPropA; - strictEqual(_.sortedLastIndex(objects, { 'a': 40 }), 1); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.sum` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - strictEqual(_.sum(objects), 1); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.takeRightWhile` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - deepEqual(_.takeRightWhile(objects), objects.slice(2)); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.takeWhile` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - deepEqual(_.takeWhile(objects.reverse()), objects.reverse().slice(2)); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.transform` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = function() { - return function(result, object) { - result.sum += object.a; - }; - }; - - deepEqual(_.transform(objects, undefined, { 'sum': 0 }), { 'sum': 2 }); - _.callback = callback; - } - else { - skipTest(); - } - }); - - test('`_.uniq` should use `_.callback` internally', 1, function() { - if (!isModularize) { - _.callback = getPropB; - deepEqual(_.uniq(objects), [objects[0], objects[2]]); - _.callback = callback; - } - else { - skipTest(); - } - }); - }()); - - /*--------------------------------------------------------------------------*/ - QUnit.module('lodash.curry'); (function() { @@ -4431,10 +3824,6 @@ var actual = _.map([[1]], _.every); deepEqual(actual, [true]); }); - - test('should be aliased', 1, function() { - strictEqual(_.all, _.every); - }); }()); /*--------------------------------------------------------------------------*/ @@ -4630,10 +4019,6 @@ strictEqual(counter, 3); }); - - test('should be aliased', 1, function() { - strictEqual(_.select, _.filter); - }); }()); /*--------------------------------------------------------------------------*/ @@ -4733,11 +4118,6 @@ strictEqual(actual, expected); }); } - if (methodName == 'find') { - test('should be aliased', 1, function() { - strictEqual(_.detect, func); - }); - } }()); }); @@ -4851,10 +4231,6 @@ skipTest(2); } }); - - test('should be aliased', 1, function() { - strictEqual(_.head, _.first); - }); }()); /*--------------------------------------------------------------------------*/ @@ -6125,10 +5501,6 @@ Foo.prototype.c = _.noop; deepEqual(_.functions(new Foo).sort(), ['a', 'c']); }); - - test('should be aliased', 1, function() { - strictEqual(_.methods, _.functions); - }); }()); /*--------------------------------------------------------------------------*/ @@ -6511,11 +5883,6 @@ ok(_.every(array1, _.partial(_.includes, array2))); }); - - test('should be aliased', 2, function() { - strictEqual(_.contains, _.includes); - strictEqual(_.include, _.includes); - }); }(1, 2, 3, 4)); /*--------------------------------------------------------------------------*/ @@ -9062,6 +8429,594 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.iteratee'); + + (function() { + test('should provide arguments to `func`', 3, function() { + var fn = function() { + var result = [this]; + push.apply(result, arguments); + return result; + }; + + var iteratee = _.iteratee(fn), + actual = iteratee('a', 'b', 'c', 'd', 'e', 'f'); + + ok(actual[0] === null || actual[0] && actual[0].Array); + deepEqual(actual.slice(1), ['a', 'b', 'c', 'd', 'e', 'f']); + + var object = {}; + iteratee = _.iteratee(fn, object); + actual = iteratee('a', 'b'); + + deepEqual(actual, [object, 'a', 'b']); + }); + + test('should return `_.identity` when `func` is nullish', 1, function() { + var object = {}, + values = [, null, undefined], + expected = _.map(values, _.constant([!isNpm && _.identity, object])); + + var actual = _.map(values, function(value, index) { + var identity = index ? _.iteratee(value) : _.iteratee(); + return [!isNpm && identity, identity(object)]; + }); + + deepEqual(actual, expected); + }); + + test('should not error when `func` is nullish and a `thisArg` is provided', 2, function() { + var object = {}; + + _.each([null, undefined], function(value) { + try { + var iteratee = _.iteratee(value, {}); + strictEqual(iteratee(object), object); + } catch(e) { + ok(false, e.message); + } + }); + }); + + test('should create an iteratee with a falsey `thisArg`', 1, function() { + var fn = function() { return this; }, + object = {}; + + var expected = _.map(falsey, function(value) { + var result = fn.call(value); + return (result && result.Array) ? object : result; + }); + + var actual = _.map(falsey, function(value) { + var iteratee = _.iteratee(fn, value), + result = iteratee(); + + return (result && result.Array) ? object : result; + }); + + ok(_.isEqual(actual, expected)); + }); + + test('should return an iteratee created by `_.matches` when `func` is an object', 2, function() { + var matches = _.iteratee({ 'a': 1, 'b': 2 }); + strictEqual(matches({ 'a': 1, 'b': 2, 'c': 3 }), true); + strictEqual(matches({ 'b': 2 }), false); + }); + + test('should return an iteratee created by `_.matches` when `func` is an array', 2, function() { + var matches = _.iteratee(['a', 'b']); + strictEqual(matches({ '0': 'a', '1': 'b', '2': 'c' }), true); + strictEqual(matches({ '1': 'b' }), false); + }); + + test('should not change match behavior if `source` is augmented', 9, function() { + var sources = [ + { 'a': { 'b': 2, 'c': 3 } }, + { 'a': 1, 'b': 2 }, + { 'a': 1 } + ]; + + _.each(sources, function(source, index) { + var object = _.cloneDeep(source), + matches = _.iteratee(source); + + strictEqual(matches(object), true); + + if (index) { + source.a = 2; + source.b = 1; + source.c = 3; + } else { + source.a.b = 1; + source.a.c = 2; + source.a.d = 3; + } + strictEqual(matches(object), true); + strictEqual(matches(source), false); + }); + }); + + test('should return an iteratee created by `_.matchesProperty` when `func` is a number or string and `thisArg` is not `undefined`', 3, function() { + var array = ['a'], + matches = _.iteratee(0, 'a'); + + strictEqual(matches(array), true); + + matches = _.iteratee('0', 'a'); + strictEqual(matches(array), true); + + matches = _.iteratee(1, undefined); + strictEqual(matches(array), undefined); + }); + + test('should support deep paths for `_.matchesProperty` shorthands', 1, function() { + var object = { 'a': { 'b': { 'c': { 'd': 1, 'e': 2 } } } }, + matches = _.iteratee('a.b.c', { 'e': 2 }); + + strictEqual(matches(object), true); + }); + + test('should return an iteratee created by `_.property` when `func` is a number or string', 2, function() { + var array = ['a'], + prop = _.iteratee(0); + + strictEqual(prop(array), 'a'); + + prop = _.iteratee('0'); + strictEqual(prop(array), 'a'); + }); + + test('should support deep paths for `_.property` shorthands', 1, function() { + var object = { 'a': { 'b': { 'c': 3 } } }, + prop = _.iteratee('a.b.c'); + + strictEqual(prop(object), 3); + }); + + test('should work with functions created by `_.partial` and `_.partialRight`', 2, function() { + var fn = function() { + var result = [this.a]; + push.apply(result, arguments); + return result; + }; + + var expected = [1, 2, 3], + object = { 'a': 1 }, + iteratee = _.iteratee(_.partial(fn, 2), object); + + deepEqual(iteratee(3), expected); + + iteratee = _.iteratee(_.partialRight(fn, 3), object); + deepEqual(iteratee(2), expected); + }); + + test('should support binding built-in methods', 2, function() { + var fn = function() {}, + object = { 'a': 1 }, + bound = fn.bind && fn.bind(object), + iteratee = _.iteratee(hasOwnProperty, object); + + strictEqual(iteratee('a'), true); + + if (bound) { + iteratee = _.iteratee(bound, object); + notStrictEqual(iteratee, bound); + } + else { + skipTest(); + } + }); + + test('should work as an iteratee for methods like `_.map`', 1, function() { + var fn = function() { return this instanceof Number; }, + array = [fn, fn, fn], + iteratees = _.map(array, _.iteratee), + expected = _.map(array, _.constant(false)); + + var actual = _.map(iteratees, function(iteratee) { + return iteratee(); + }); + + deepEqual(actual, expected); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('custom `_.iteratee` methods'); + + (function() { + var array = ['one', 'two', 'three'], + getPropA = _.partial(_.property, 'a'), + getPropB = _.partial(_.property, 'b'), + getLength = _.partial(_.property, 'length'), + iteratee = _.iteratee; + + var getSum = function() { + return function(result, object) { + return result + object.a; + }; + }; + + var objects = [ + { 'a': 0, 'b': 0 }, + { 'a': 1, 'b': 0 }, + { 'a': 1, 'b': 1 } + ]; + + test('`_.countBy` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getLength; + deepEqual(_.countBy(array), { '3': 2, '5': 1 }); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.dropRightWhile` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + deepEqual(_.dropRightWhile(objects), objects.slice(0, 2)); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.dropWhile` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + deepEqual(_.dropWhile(objects.reverse()).reverse(), objects.reverse().slice(0, 2)); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.every` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropA; + strictEqual(_.every(objects.slice(1)), true); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.filter` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + var objects = [{ 'a': 0 }, { 'a': 1 }]; + + _.iteratee = getPropA; + deepEqual(_.filter(objects), [objects[1]]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.find` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropA; + strictEqual(_.find(objects), objects[1]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.findIndex` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropA; + strictEqual(_.findIndex(objects), 1); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.findLast` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropA; + strictEqual(_.findLast(objects), objects[2]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.findLastIndex` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropA; + strictEqual(_.findLastIndex(objects), 2); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.findLastKey` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + strictEqual(_.findKey(objects), '2'); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.findKey` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + strictEqual(_.findLastKey(objects), '2'); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.groupBy` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getLength; + deepEqual(_.groupBy(array), { '3': ['one', 'two'], '5': ['three'] }); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.indexBy` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getLength; + deepEqual(_.indexBy(array), { '3': 'two', '5': 'three' }); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.map` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropA; + deepEqual(_.map(objects), [0, 1, 1]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.mapKeys` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + deepEqual(_.mapKeys({ 'a': { 'b': 1 } }), { '1': { 'b': 1 } }); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.mapValues` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + deepEqual(_.mapValues({ 'a': { 'b': 1 } }), { 'a': 1 }); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.max` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + deepEqual(_.max(objects), objects[2]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.min` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + deepEqual(_.min(objects), objects[0]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.partition` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + var objects = [{ 'a': 1 }, { 'a': 1 }, { 'b': 2 }]; + + _.iteratee = getPropA; + deepEqual(_.partition(objects), [objects.slice(0, 2), objects.slice(2)]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.reduce` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getSum; + strictEqual(_.reduce(objects, undefined, 0), 2); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.reduceRight` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getSum; + strictEqual(_.reduceRight(objects, undefined, 0), 2); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.reject` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + var objects = [{ 'a': 0 }, { 'a': 1 }]; + + _.iteratee = getPropA; + deepEqual(_.reject(objects), [objects[0]]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.remove` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + var objects = [{ 'a': 0 }, { 'a': 1 }]; + + _.iteratee = getPropA; + _.remove(objects); + deepEqual(objects, [{ 'a': 0 }]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.some` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + strictEqual(_.some(objects), true); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.sortBy` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropA; + deepEqual(_.sortBy(objects.slice().reverse()), [objects[0], objects[2], objects[1]]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.sortedIndex` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + var objects = [{ 'a': 30 }, { 'a': 50 }]; + + _.iteratee = getPropA; + strictEqual(_.sortedIndex(objects, { 'a': 40 }), 1); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.sortedLastIndex` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + var objects = [{ 'a': 30 }, { 'a': 50 }]; + + _.iteratee = getPropA; + strictEqual(_.sortedLastIndex(objects, { 'a': 40 }), 1); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.sum` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + strictEqual(_.sum(objects), 1); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.takeRightWhile` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + deepEqual(_.takeRightWhile(objects), objects.slice(2)); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.takeWhile` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + deepEqual(_.takeWhile(objects.reverse()), objects.reverse().slice(2)); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.transform` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = function() { + return function(result, object) { + result.sum += object.a; + }; + }; + + deepEqual(_.transform(objects, undefined, { 'sum': 0 }), { 'sum': 2 }); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + + test('`_.uniq` should use `_.iteratee` internally', 1, function() { + if (!isModularize) { + _.iteratee = getPropB; + deepEqual(_.uniq(objects), [objects[0], objects[2]]); + _.iteratee = iteratee; + } + else { + skipTest(); + } + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('keys methods'); _.each(['keys', 'keysIn'], function(methodName) { @@ -9633,10 +9588,6 @@ skipTest(5); } }); - - test('should be aliased', 1, function() { - strictEqual(_.collect, _.map); - }); }()); /*--------------------------------------------------------------------------*/ @@ -13140,11 +13091,6 @@ strictEqual(actual, 'abc'); }); }); - - test('should be aliased', 2, function() { - strictEqual(_.foldl, _.reduce); - strictEqual(_.inject, _.reduce); - }); }()); /*--------------------------------------------------------------------------*/ @@ -13219,10 +13165,6 @@ strictEqual(actual, 'cba'); }); }); - - test('should be aliased', 1, function() { - strictEqual(_.foldr, _.reduceRight); - }); }()); /*--------------------------------------------------------------------------*/ @@ -13819,10 +13761,6 @@ skipTest(4); } }); - - test('should be aliased', 1, function() { - strictEqual(_.tail, _.rest); - }); }()); /*--------------------------------------------------------------------------*/ @@ -14566,10 +14504,6 @@ var actual = _.map([[1]], _.some); deepEqual(actual, [true]); }); - - test('should be aliased', 1, function() { - strictEqual(_.any, _.some); - }); }()); /*--------------------------------------------------------------------------*/ @@ -16789,10 +16723,6 @@ deepEqual(actual, [['a'], ['b']]); }); }); - - test('should be aliased', 1, function() { - strictEqual(_.unique, _.uniq); - }); }()); /*--------------------------------------------------------------------------*/ @@ -17173,10 +17103,6 @@ skipTest(); } }); - - test('should be aliased', 1, function() { - strictEqual(_.object, _.zipObject); - }); }()); /*--------------------------------------------------------------------------*/ @@ -17899,11 +17825,11 @@ (function() { var funcs = [ 'clone', - 'contains', 'every', 'find', 'first', 'has', + 'includes', 'isArguments', 'isArray', 'isBoolean', @@ -18094,8 +18020,6 @@ ]; var rejectFalsey = [ - 'backflow', - 'compose', 'flow', 'flowRight', 'tap', @@ -18143,7 +18067,7 @@ var acceptFalsey = _.difference(allMethods, rejectFalsey); - test('should accept falsey arguments', 229, function() { + test('should accept falsey arguments', 212, function() { var emptyArrays = _.map(falsey, _.constant([])); _.each(acceptFalsey, function(methodName) { @@ -18203,7 +18127,7 @@ }); }); - test('should throw an error for falsey arguments', 25, function() { + test('should throw an error for falsey arguments', 23, function() { _.each(rejectFalsey, function(methodName) { var expected = _.map(falsey, _.constant(true)), func = _[methodName];