Skip to content

Commit cefddab

Browse files
RajuPeddajdalton
authored andcommitted
Updated the check of isFunction method (lodash#4555)
1 parent a6b960b commit cefddab

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

isFunction.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import getTag from './.internal/getTag.js'
2-
import isObject from './isObject.js'
31

42
/**
53
* Checks if `value` is classified as a `Function` object.
@@ -10,21 +8,26 @@ import isObject from './isObject.js'
108
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
119
* @example
1210
*
13-
* isFunction(_)
11+
* isFunction(class Any{})
1412
* // => true
1513
*
14+
* isFunction(() => {})
15+
* // => true
16+
*
17+
* isFunction(async () => {})
18+
* // => true
19+
*
20+
* isFunction(function * Any() {})
21+
* // => true
22+
*
23+
* isFunction(Math.round)
24+
* // => true
25+
*
1626
* isFunction(/abc/)
1727
* // => false
1828
*/
1929
function isFunction(value) {
20-
if (!isObject(value)) {
21-
return false
22-
}
23-
// The use of `Object#toString` avoids issues with the `typeof` operator
24-
// in Safari 9 which returns 'object' for typed arrays and other constructors.
25-
const tag = getTag(value)
26-
return tag == '[object Function]' || tag == '[object AsyncFunction]' ||
27-
tag == '[object GeneratorFunction]' || tag == '[object Proxy]'
30+
return typeof value === 'function'
2831
}
2932

3033
export default isFunction

0 commit comments

Comments
 (0)