Add function checks to _.modArgs.

This commit is contained in:
jdalton
2015-06-02 20:14:55 -07:00
parent f402dbd1e3
commit 50e129bd8f
2 changed files with 20 additions and 2 deletions

View File

@@ -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);