From 1a58a70494bcf38f89402acbf72d0ff5070a7b25 Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 1 Feb 2015 02:44:33 -0800 Subject: [PATCH] Reduce deps on `matches` in favor of `baseMatches`. --- lodash.src.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 25514c53e..697d47b8f 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -1803,7 +1803,7 @@ } // Handle "_.property" and "_.matches" style callback shorthands. return type == 'object' - ? baseMatches(func, !argCount) + ? baseMatches(func) : baseProperty(func + ''); } @@ -2427,10 +2427,9 @@ * * @private * @param {Object} source The object of property values to match. - * @param {boolean} [isCloned] Specify cloning the source object. * @returns {Function} Returns the new function. */ - function baseMatches(source, isCloned) { + function baseMatches(source) { var props = keys(source), length = props.length; @@ -2444,9 +2443,6 @@ }; } } - if (isCloned) { - source = baseClone(source, true); - } var values = Array(length), strictCompareFlags = Array(length); @@ -5861,7 +5857,7 @@ * // => 'fred' */ function findWhere(collection, source) { - return find(collection, matches(source)); + return find(collection, baseMatches(source)); } /** @@ -6609,7 +6605,7 @@ * // => ['barney', 'fred'] */ function where(collection, source) { - return filter(collection, matches(source)); + return filter(collection, baseMatches(source)); } /*------------------------------------------------------------------------*/ @@ -10207,7 +10203,9 @@ if (guard && isIterateeCall(func, thisArg, guard)) { thisArg = null; } - return baseCallback(func, thisArg); + return isObjectLike(func) + ? matches(func) + : baseCallback(func, thisArg); } /** @@ -10275,7 +10273,7 @@ * // => { 'user': 'barney', 'age': 36 } */ function matches(source) { - return baseMatches(source, true); + return baseMatches(baseClone(source, true)); } /** @@ -10898,7 +10896,7 @@ // Add `LazyWrapper` methods for `_.pluck` and `_.where`. arrayEach(['pluck', 'where'], function(methodName, index) { var operationName = index ? 'filter' : 'map', - createCallback = index ? matches : property; + createCallback = index ? baseMatches : property; LazyWrapper.prototype[methodName] = function(value) { return this[operationName](createCallback(value));