Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var baseIsFunction = require('../internal/baseIsFunction'),
2
getNative = require('../internal/getNative');
3
4
/** `Object#toString` result references. */
5
var funcTag = '[object Function]';
6
7
/** Used for native method references. */
8
var objectProto = Object.prototype;
9
10
/**
11
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
12
* of values.
13
*/
14
var objToString = objectProto.toString;
15
16
/** Native method references. */
17
var Uint8Array = getNative(global, 'Uint8Array');
18
19
/**
20
* Checks if `value` is classified as a `Function` object.
21
*
22
* @static
23
* @memberOf _
24
* @category Lang
25
* @param {*} value The value to check.
26
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
27
* @example
28
*
29
* _.isFunction(_);
30
* // => true
31
*
32
* _.isFunction(/abc/);
33
* // => false
34
*/
35
var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) {
36
// The use of `Object#toString` avoids issues with the `typeof` operator
37
// in older versions of Chrome and Safari which return 'function' for regexes
38
// and Safari 8 equivalents which return 'object' for typed array constructors.
39
return objToString.call(value) == funcTag;
40
};
41
42
module.exports = isFunction;
43
44