Simplify _.where but don't make it an official alias of _.filter.

Former-commit-id: 794ab4eb814e8872443e282beb32cc636dedc43a
This commit is contained in:
John-David Dalton
2013-02-03 21:44:53 -08:00
parent 6ee606e3e2
commit 0fb4f7e1c4
2 changed files with 14 additions and 5 deletions

View File

@@ -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] : '';
}
/**

View File

@@ -2944,9 +2944,7 @@
* _.where(stooges, { 'age': 40 });
* // => [{ 'name': 'moe', 'age': 40 }]
*/
function where(collection, properties) {
return filter(collection, properties);
}
var where = filter;
/*--------------------------------------------------------------------------*/