mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
9 years ago
|
var isObject = require('./isObject');
|
||
10 years ago
|
|
||
|
/** `Object#toString` result references. */
|
||
9 years ago
|
var funcTag = '[object Function]',
|
||
|
genTag = '[object GeneratorFunction]';
|
||
10 years ago
|
|
||
9 years ago
|
/** Used for built-in method references. */
|
||
10 years ago
|
var objectProto = Object.prototype;
|
||
|
|
||
|
/**
|
||
9 years ago
|
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
||
10 years ago
|
* of values.
|
||
|
*/
|
||
9 years ago
|
var objectToString = objectProto.toString;
|
||
10 years ago
|
|
||
|
/**
|
||
|
* Checks if `value` is classified as a `Function` object.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @category Lang
|
||
|
* @param {*} value The value to check.
|
||
|
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
||
|
* @example
|
||
|
*
|
||
|
* _.isFunction(_);
|
||
|
* // => true
|
||
|
*
|
||
|
* _.isFunction(/abc/);
|
||
|
* // => false
|
||
|
*/
|
||
9 years ago
|
function isFunction(value) {
|
||
10 years ago
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
||
9 years ago
|
// in Safari 8 which returns 'object' for typed array constructors, and
|
||
|
// PhantomJS 1.9 which returns 'function' for `NodeList` instances.
|
||
|
var tag = isObject(value) ? objectToString.call(value) : '';
|
||
|
return tag == funcTag || tag == genTag;
|
||
9 years ago
|
}
|
||
10 years ago
|
|
||
|
module.exports = isFunction;
|