Files
lodash/isFunction.js
2017-01-10 14:43:43 -08:00

31 lines
837 B
JavaScript

import baseGetTag from './.internal/baseGetTag.js';
import isObject from './isObject.js';
/**
* Checks if `value` is classified as a `Function` object.
*
* @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 == '[object Function]' || tag == '[object AsyncFunction]' ||
tag == '[object GeneratorFunction]' || tag == '[object Proxy]';
}
export default isFunction;