mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
Simplify isType methods.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import baseGetTag from './.internal/baseGetTag.js'
|
||||
import isObjectLike from './isObjectLike.js'
|
||||
import getTag from './.internal/getTag.js'
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `String` primitive or object.
|
||||
@@ -17,8 +16,8 @@ import isObjectLike from './isObjectLike.js'
|
||||
* // => false
|
||||
*/
|
||||
function isString(value) {
|
||||
return typeof value == 'string' ||
|
||||
(!Array.isArray(value) && isObjectLike(value) && baseGetTag(value) == '[object String]')
|
||||
const type = typeof value
|
||||
return type == 'string' || (type == 'object' && value != null && !Array.isArray(value) && getTag(value) == '[object String]')
|
||||
}
|
||||
|
||||
export default isString
|
||||
|
||||
Reference in New Issue
Block a user