mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Add baseIsFunction.
This commit is contained in:
@@ -331,6 +331,20 @@
|
|||||||
return -1;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer`
|
* The base implementation of `_.sortBy` and `_.sortByAll` which uses `comparer`
|
||||||
* to define the sort order of `array` and replaces criteria objects with their
|
* to define the sort order of `array` and replaces criteria objects with their
|
||||||
@@ -7502,7 +7516,7 @@
|
|||||||
if (!length) {
|
if (!length) {
|
||||||
return function() { return arguments[0]; };
|
return function() { return arguments[0]; };
|
||||||
}
|
}
|
||||||
if (!arrayEvery(funcs, isFunction)) {
|
if (!arrayEvery(funcs, baseIsFunction)) {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
return function() {
|
return function() {
|
||||||
@@ -7547,7 +7561,7 @@
|
|||||||
if (fromIndex < 0) {
|
if (fromIndex < 0) {
|
||||||
return function() { return arguments[0]; };
|
return function() { return arguments[0]; };
|
||||||
}
|
}
|
||||||
if (!arrayEvery(funcs, isFunction)) {
|
if (!arrayEvery(funcs, baseIsFunction)) {
|
||||||
throw new TypeError(FUNC_ERROR_TEXT);
|
throw new TypeError(FUNC_ERROR_TEXT);
|
||||||
}
|
}
|
||||||
return function() {
|
return function() {
|
||||||
@@ -8297,20 +8311,12 @@
|
|||||||
* _.isFunction(/abc/);
|
* _.isFunction(/abc/);
|
||||||
* // => false
|
* // => false
|
||||||
*/
|
*/
|
||||||
function isFunction(value) {
|
var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
|
||||||
// Avoid a Chakra JIT bug in compatibility modes of IE 11.
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||||||
// See https://github.com/jashkenas/underscore/issues/1621 for more details.
|
// in older versions of Chrome and Safari which return 'function' for regexes
|
||||||
return typeof value == 'function' || false;
|
// and Safari 8 equivalents which return 'object' for typed array constructors.
|
||||||
}
|
return objToString.call(value) == funcTag;
|
||||||
// Fallback for environments that return incorrect `typeof` operator results.
|
};
|
||||||
if (isFunction(/x/) || (Uint8Array && !isFunction(Uint8Array))) {
|
|
||||||
isFunction = function(value) {
|
|
||||||
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
||||||
// in older versions of Chrome and Safari which return 'function' for regexes
|
|
||||||
// and Safari 8 equivalents which return 'object' for typed array constructors.
|
|
||||||
return objToString.call(value) == funcTag;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if `value` is the language type of `Object`.
|
* Checks if `value` is the language type of `Object`.
|
||||||
|
|||||||
Reference in New Issue
Block a user