Make _.reduce, _.reduceRight, & _.transform to use lodash.createCallback. [closes #388]

This commit is contained in:
John-David Dalton
2013-11-04 08:01:32 -08:00
parent 61e9aac92d
commit 617f31b47f
7 changed files with 62 additions and 61 deletions

6
dist/lodash.js vendored
View File

@@ -2773,7 +2773,7 @@
}
}
if (callback) {
callback = baseCreateCallback(callback, thisArg, 4);
callback = lodash.createCallback(callback, thisArg, 4);
(isArr ? forEach : forOwn)(object, function(value, index, object) {
return callback(accumulator, value, index, object);
});
@@ -3625,7 +3625,7 @@
function reduce(collection, callback, accumulator, thisArg) {
if (!collection) return accumulator;
var noaccum = arguments.length < 3;
callback = baseCreateCallback(callback, thisArg, 4);
callback = lodash.createCallback(callback, thisArg, 4);
var index = -1,
length = collection.length;
@@ -3668,7 +3668,7 @@
*/
function reduceRight(collection, callback, accumulator, thisArg) {
var noaccum = arguments.length < 3;
callback = baseCreateCallback(callback, thisArg, 4);
callback = lodash.createCallback(callback, thisArg, 4);
forEachRight(collection, function(value, index, collection) {
accumulator = noaccum
? (noaccum = false, value)