|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +/* |
| 4 | +The following code is extracted and adapted from the lodash library. |
| 5 | +It is protected by the the MIT License. |
| 6 | +
|
| 7 | +Copyright JS Foundation and other contributors <https://js.foundation/> |
| 8 | +
|
| 9 | +Based on Underscore.js, copyright Jeremy Ashkenas, |
| 10 | +DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> |
| 11 | +
|
| 12 | +This software consists of voluntary contributions made by many |
| 13 | +individuals. For exact contribution history, see the revision history |
| 14 | +available at https://github.com/lodash/lodash |
| 15 | +
|
| 16 | +The following license applies to all parts of this software except as |
| 17 | +documented below: |
| 18 | +
|
| 19 | +==== |
| 20 | +
|
| 21 | +Permission is hereby granted, free of charge, to any person obtaining |
| 22 | +a copy of this software and associated documentation files (the |
| 23 | +"Software"), to deal in the Software without restriction, including |
| 24 | +without limitation the rights to use, copy, modify, merge, publish, |
| 25 | +distribute, sublicense, and/or sell copies of the Software, and to |
| 26 | +permit persons to whom the Software is furnished to do so, subject to |
| 27 | +the following conditions: |
| 28 | +
|
| 29 | +The above copyright notice and this permission notice shall be |
| 30 | +included in all copies or substantial portions of the Software. |
| 31 | +
|
| 32 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 33 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 34 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 35 | +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 36 | +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 37 | +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 38 | +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 39 | +*/ |
| 40 | + |
| 41 | +var |
| 42 | + asyncTag = '[object AsyncFunction]', |
| 43 | + funcTag = '[object Function]', |
| 44 | + genTag = '[object GeneratorFunction]', |
| 45 | + proxyTag = '[object Proxy]', |
| 46 | + nullTag = '[object Null]', |
| 47 | + stringTag = '[object String]', |
| 48 | + undefinedTag = '[object Undefined]'; |
| 49 | + |
| 50 | +function baseGetTag(value) { |
| 51 | + if (value === undefined) { |
| 52 | + return undefinedTag; |
| 53 | + } |
| 54 | + |
| 55 | + if (value === null) { |
| 56 | + return nullTag; |
| 57 | + } |
| 58 | + |
| 59 | + return Object.prototype.toString.call(value); |
| 60 | +} |
| 61 | + |
| 62 | +function isObject(value) { |
| 63 | + var type = typeof value; |
| 64 | + return value !== undefined && value !== null && (type === 'object' || type === 'function'); |
| 65 | +} |
| 66 | + |
| 67 | +function isFunction(value) { |
| 68 | + if (!isObject(value)) { |
| 69 | + return false; |
| 70 | + } |
| 71 | + |
| 72 | + var tag = baseGetTag(value); |
| 73 | + return tag === funcTag || tag === genTag || tag === asyncTag || tag === proxyTag; |
| 74 | +} |
| 75 | + |
| 76 | +function isObjectLike(value) { |
| 77 | + return value !== undefined && value !== null && typeof value === 'object'; |
| 78 | +} |
| 79 | + |
| 80 | +function isString(value) { |
| 81 | + return typeof value === 'string' || |
| 82 | + !Array.isArray(value) && isObjectLike(value) && baseGetTag(value) === stringTag; |
| 83 | +} |
| 84 | + |
| 85 | +module.exports = { |
| 86 | + isFunction: isFunction, |
| 87 | + isString: isString, |
| 88 | + isObjectLike: isObjectLike |
| 89 | +}; |
0 commit comments