diff --git a/fp/_baseConvert.js b/fp/_baseConvert.js index 6ebd71622..9b2db001f 100644 --- a/fp/_baseConvert.js +++ b/fp/_baseConvert.js @@ -152,15 +152,15 @@ function baseConvert(util, name, func, options) { 'iteratee': function(iteratee) { return function() { var func = arguments[0], - arity = arguments[1]; + arity = arguments[1], + result = iteratee(func, arity), + length = result.length; - if (!config.cap) { - return iteratee(func, arity); + if (config.cap && typeof arity == 'number') { + arity = arity > 2 ? (arity - 2) : 1; + return (length && length <= arity) ? result : baseAry(result, arity); } - arity = arity > 2 ? (arity - 2) : 1; - func = iteratee(func); - var length = func.length; - return (length && length <= arity) ? func : baseAry(func, arity); + return result; }; }, 'mixin': function(mixin) { diff --git a/lodash.js b/lodash.js index fb042312d..51b4ad7f3 100644 --- a/lodash.js +++ b/lodash.js @@ -11684,7 +11684,7 @@ * // => { 'b': '2' } */ function omitBy(object, predicate) { - predicate = getIteratee(predicate, 2); + predicate = getIteratee(predicate); return basePickBy(object, function(value, key) { return !predicate(value, key); }); @@ -11729,7 +11729,7 @@ * // => { 'a': 1, 'c': 3 } */ function pickBy(object, predicate) { - return object == null ? {} : basePickBy(object, getIteratee(predicate, 2)); + return object == null ? {} : basePickBy(object, getIteratee(predicate)); } /** diff --git a/test/test-fp.js b/test/test-fp.js index 5ae7f525b..3b6f72b4f 100644 --- a/test/test-fp.js +++ b/test/test-fp.js @@ -1173,6 +1173,27 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('fp.omitBy and fp.pickBy'); + + _.each(['omitBy', 'pickBy'], function(methodName) { + var func = fp[methodName]; + + QUnit.test('`fp.' + methodName + '` should provide `value` and `key` to `iteratee`', function(assert) { + assert.expect(1); + + var args, + object = { 'a': 1 }; + + func(function() { + args || (args = slice.call(arguments)); + })(object); + + assert.deepEqual(args, [1, 'a']); + }); + }); + + /*--------------------------------------------------------------------------*/ + QUnit.module('fp.partial and fp.partialRight'); _.each(['partial', 'partialRight'], function(methodName) {