mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
37 lines
991 B
JavaScript
37 lines
991 B
JavaScript
import baseGetTag from './.internal/baseGetTag.js';
|
|
import isObject from './isObject.js';
|
|
|
|
/** `Object#toString` result references. */
|
|
const asyncTag = '[object AsyncFunction]';
|
|
const funcTag = '[object Function]';
|
|
const genTag = '[object GeneratorFunction]';
|
|
const proxyTag = '[object Proxy]';
|
|
|
|
/**
|
|
* Checks if `value` is classified as a `Function` object.
|
|
*
|
|
* @static
|
|
* @since 0.1.0
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
* @example
|
|
*
|
|
* isFunction(_);
|
|
* // => true
|
|
*
|
|
* isFunction(/abc/);
|
|
* // => false
|
|
*/
|
|
function isFunction(value) {
|
|
if (!isObject(value)) {
|
|
return false;
|
|
}
|
|
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
// in Safari 9 which returns 'object' for typed arrays and other constructors.
|
|
const tag = baseGetTag(value);
|
|
return tag == funcTag || tag == asyncTag || tag == genTag || tag == proxyTag;
|
|
}
|
|
|
|
export default isFunction;
|