mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
Changed reduceRight to avoid unnecessarily cloning an array.
`toArray` returns the first argument unmodified if it passes `isArray`. So if `obj` passes `isArray`, call `slice` on it directly, otherwise use `toArray`.
This commit is contained in:
@@ -110,7 +110,7 @@
|
||||
if (context) iterator = _.bind(iterator, context);
|
||||
return obj.reduceRight(iterator, memo);
|
||||
}
|
||||
var reversed = _.clone(_.toArray(obj)).reverse();
|
||||
var reversed = (_.isArray(obj) ? obj.slice() : _.toArray(obj)).reverse();
|
||||
return _.reduce(reversed, iterator, memo, context);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user