diff --git a/lodash.src.js b/lodash.src.js index 8356a0597..cebf3bc95 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -348,6 +348,20 @@ } return -1; } + + /** + * The base implementation of `_.isFunction` without support for environments + * with incorrect `typeof` results. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. + */ + function baseIsFunction(value) { + // Avoid a Chakra JIT bug in compatibility modes of IE 11. + // See https://github.com/jashkenas/underscore/issues/1621 for more details. + return typeof value == 'function' || false; + } /** * Converts `value` to a string if it's not one. An empty string is returned @@ -8033,6 +8047,9 @@ * // => [25, 20] */ var modArgs = restParam(function(func, transforms) { + if (typeof func != 'function' || !arrayEvery(transforms, baseIsFunction)) { + throw new TypeError(FUNC_ERROR_TEXT); + } var length = transforms.length; return restParam(function(args) { var index = nativeMin(args.length, length); diff --git a/test/test.js b/test/test.js index 87669eb0d..5b7292000 100644 --- a/test/test.js +++ b/test/test.js @@ -17836,6 +17836,7 @@ 'defer', 'delay', 'memoize', + 'modArgs', 'negate', 'once', 'partial', @@ -17896,7 +17897,7 @@ var acceptFalsey = _.difference(allMethods, rejectFalsey); - test('should accept falsey arguments', 226, function() { + test('should accept falsey arguments', 225, function() { var emptyArrays = _.map(falsey, _.constant([])), isExposed = '_' in root, oldDash = root._; @@ -17962,7 +17963,7 @@ }); }); - test('should throw an error for falsey arguments', 24, function() { + test('should throw an error for falsey arguments', 25, function() { _.each(rejectFalsey, function(methodName) { var expected = _.map(falsey, _.constant(true)), func = _[methodName];