diff --git a/isFunction.js b/isFunction.js index 4c96c365a..a432556ce 100644 --- a/isFunction.js +++ b/isFunction.js @@ -1,5 +1,3 @@ -import getTag from './.internal/getTag.js' -import isObject from './isObject.js' /** * Checks if `value` is classified as a `Function` object. @@ -10,21 +8,26 @@ import isObject from './isObject.js' * @returns {boolean} Returns `true` if `value` is a function, else `false`. * @example * - * isFunction(_) + * isFunction(class Any{}) * // => true * + * isFunction(() => {}) + * // => true + * + * isFunction(async () => {}) + * // => true + * + * isFunction(function * Any() {}) + * // => true + * + * isFunction(Math.round) + * // => 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 = getTag(value) - return tag == '[object Function]' || tag == '[object AsyncFunction]' || - tag == '[object GeneratorFunction]' || tag == '[object Proxy]' + return typeof value === 'function' } export default isFunction