mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
our #reduceRight delegates to #reduce after reversing.
no need to reimplement it. also, reduceRight is worthless :)
This commit is contained in:
@@ -90,10 +90,7 @@
|
|||||||
_.reduceRight = function(obj, memo, iterator, context) {
|
_.reduceRight = function(obj, memo, iterator, context) {
|
||||||
if (obj && _.isFunction(obj.reduceRight)) return obj.reduceRight(_.bind(iterator, context), memo);
|
if (obj && _.isFunction(obj.reduceRight)) return obj.reduceRight(_.bind(iterator, context), memo);
|
||||||
var reversed = _.clone(_.toArray(obj)).reverse();
|
var reversed = _.clone(_.toArray(obj)).reverse();
|
||||||
each(reversed, function(value, index) {
|
return reduce(reversed, memo, iterator, context);
|
||||||
memo = iterator.call(context, memo, value, index, obj);
|
|
||||||
});
|
|
||||||
return memo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Return the first value which passes a truth test.
|
// Return the first value which passes a truth test.
|
||||||
|
|||||||
Reference in New Issue
Block a user