main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
991 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import baseGetTag from './_baseGetTag.js';
|
---|
| 2 | import isObject from './isObject.js';
|
---|
| 3 |
|
---|
| 4 | /** `Object#toString` result references. */
|
---|
| 5 | var asyncTag = '[object AsyncFunction]',
|
---|
| 6 | funcTag = '[object Function]',
|
---|
| 7 | genTag = '[object GeneratorFunction]',
|
---|
| 8 | proxyTag = '[object Proxy]';
|
---|
| 9 |
|
---|
| 10 | /**
|
---|
| 11 | * Checks if `value` is classified as a `Function` object.
|
---|
| 12 | *
|
---|
| 13 | * @static
|
---|
| 14 | * @memberOf _
|
---|
| 15 | * @since 0.1.0
|
---|
| 16 | * @category Lang
|
---|
| 17 | * @param {*} value The value to check.
|
---|
| 18 | * @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
---|
| 19 | * @example
|
---|
| 20 | *
|
---|
| 21 | * _.isFunction(_);
|
---|
| 22 | * // => true
|
---|
| 23 | *
|
---|
| 24 | * _.isFunction(/abc/);
|
---|
| 25 | * // => false
|
---|
| 26 | */
|
---|
| 27 | function isFunction(value) {
|
---|
| 28 | if (!isObject(value)) {
|
---|
| 29 | return false;
|
---|
| 30 | }
|
---|
| 31 | // The use of `Object#toString` avoids issues with the `typeof` operator
|
---|
| 32 | // in Safari 9 which returns 'object' for typed arrays and other constructors.
|
---|
| 33 | var tag = baseGetTag(value);
|
---|
| 34 | return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | export default isFunction;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.