Ensure _.first and _.last have the correct chaining behavior when passing a callback and thisArg.

Former-commit-id: 4d54fd677fa48bf8de033696c58ee66babd77a81
This commit is contained in:
John-David Dalton
2013-01-16 01:39:58 -08:00
parent b60d0cdb17
commit ab83f2d5e2
4 changed files with 53 additions and 5 deletions

View File

@@ -4542,9 +4542,11 @@
forOwn(lodash, function(func, methodName) {
if (!lodash.prototype[methodName]) {
lodash.prototype[methodName]= function(n, guard) {
var result = func(this.__wrapped__, n, guard);
return (n == null || guard) ? result : new lodash(result);
lodash.prototype[methodName]= function(callback, thisArg) {
var result = func(this.__wrapped__, callback, thisArg);
return callback == null || (thisArg && typeof callback != 'function')
? result
: new lodash(result);
};
}
});