diff --git a/lib/fp/base.js b/lib/fp/base.js index 69f47979a..f43ee6240 100644 --- a/lib/fp/base.js +++ b/lib/fp/base.js @@ -102,7 +102,7 @@ function baseConvert(util, name, func) { arity = arity > 2 ? (arity - 2) : 1; func = iteratee(func); var length = func.length; - return length <= arity ? func : baseAry(func, arity); + return (length && length <= arity) ? func : baseAry(func, arity); }; }, 'mixin': function(mixin) { diff --git a/test/test-fp.js b/test/test-fp.js index e178d56cd..a8f4b9fb5 100644 --- a/test/test-fp.js +++ b/test/test-fp.js @@ -567,6 +567,28 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('reduce methods'); + + _.each(['reduce', 'reduceRight'], function(methodName) { + var func = fp[methodName], + array = [1, 2, 3], + isReduce = methodName == 'reduce'; + + QUnit.test('`_.' + methodName + '` should provide the correct `iteratee` arguments', function(assert) { + assert.expect(1); + + var args; + + func(function() { + args || (args = slice.call(arguments)); + })(0, array); + + assert.deepEqual(args, isReduce ? [0, 1] : [0, 3]); + }); + }); + + /*--------------------------------------------------------------------------*/ + QUnit.module('fp.runInContext'); (function() {