From 0fb4f7e1c43c07a3530de297824b7958681f6a93 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 3 Feb 2013 21:44:53 -0800 Subject: [PATCH] Simplify `_.where` but don't make it an official alias of `_.filter`. Former-commit-id: 794ab4eb814e8872443e282beb32cc636dedc43a --- build.js | 15 +++++++++++++-- lodash.js | 4 +--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/build.js b/build.js index cbfcba81d..928608440 100755 --- a/build.js +++ b/build.js @@ -621,7 +621,7 @@ * @returns {String} Returns the method name's category. */ function getCategory(source, methodName) { - var result = /@category *(\w+)/.exec(matchFunction(source, methodName)); + var result = /@category +(\w+)/.exec(matchFunction(source, methodName)); return result ? result[1] : ''; } @@ -816,7 +816,18 @@ ')\\n' )); - return result ? result[0] : ''; + if (result) { + return result[0]; + } + // match variables that are explicitly defined as functions + result = source.match(RegExp( + // match multi-line comment block + '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/)?\\n' + + // match a simple variable declaration + ' *var ' + funcName + ' *=.+?;\\n' + )); + + return /@type +Function/.test(result) ? result[0] : ''; } /** diff --git a/lodash.js b/lodash.js index 7861b9810..0e963bbe4 100644 --- a/lodash.js +++ b/lodash.js @@ -2944,9 +2944,7 @@ * _.where(stooges, { 'age': 40 }); * // => [{ 'name': 'moe', 'age': 40 }] */ - function where(collection, properties) { - return filter(collection, properties); - } + var where = filter; /*--------------------------------------------------------------------------*/