mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 17:07:49 +00:00
use isObjectLike module instead of (typeof value == 'object' && value !== null) in another modules (#3650)
This commit is contained in:
committed by
John-David Dalton
parent
678eb000b7
commit
c1f805f497
@@ -1,4 +1,5 @@
|
||||
import getTag from './.internal/getTag.js'
|
||||
import isObjectLike from './isObjectLike'
|
||||
|
||||
/**
|
||||
* Checks if `value` is likely an `arguments` object.
|
||||
@@ -16,7 +17,7 @@ import getTag from './.internal/getTag.js'
|
||||
* // => false
|
||||
*/
|
||||
function isArguments(value) {
|
||||
return typeof value == 'object' && value !== null && getTag(value) == '[object Arguments]'
|
||||
return isObjectLike(value) && getTag(value) == '[object Arguments]'
|
||||
}
|
||||
|
||||
export default isArguments
|
||||
|
||||
3
isSet.js
3
isSet.js
@@ -1,5 +1,6 @@
|
||||
import getTag from './.internal/getTag.js'
|
||||
import nodeUtil from './.internal/nodeUtil.js'
|
||||
import isObjectLike from './isObjectLike'
|
||||
|
||||
/* Node.js helper references. */
|
||||
const nodeIsSet = nodeUtil && nodeUtil.isSet
|
||||
@@ -21,6 +22,6 @@ const nodeIsSet = nodeUtil && nodeUtil.isSet
|
||||
*/
|
||||
const isSet = nodeIsSet
|
||||
? (value) => nodeIsSet(value)
|
||||
: (value) => typeof value == 'object' && value !== null && getTag(value) == '[object Set]'
|
||||
: (value) => isObjectLike(value) && getTag(value) == '[object Set]'
|
||||
|
||||
export default isSet
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import getTag from './.internal/getTag.js'
|
||||
import nodeUtil from './.internal/nodeUtil.js'
|
||||
import isObjectLike from './isObjectLike'
|
||||
|
||||
/** Used to match `toStringTag` values of typed arrays. */
|
||||
const reTypedTag = /^\[object (?:Float(?:32|64)|(?:Int|Uint)(?:8|16|32)|Uint8Clamped)\]$/
|
||||
@@ -24,6 +25,6 @@ const nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray
|
||||
*/
|
||||
const isTypedArray = nodeIsTypedArray
|
||||
? (value) => nodeIsTypedArray(value)
|
||||
: (value) => typeof value == 'object' && value !== null && reTypedTag.test(getTag(value))
|
||||
: (value) => isObjectLike(value) && reTypedTag.test(getTag(value))
|
||||
|
||||
export default isTypedArray
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import getTag from './.internal/getTag.js'
|
||||
import isObjectLike from './isObjectLike'
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `WeakMap` object.
|
||||
@@ -16,7 +17,7 @@ import getTag from './.internal/getTag.js'
|
||||
* // => false
|
||||
*/
|
||||
function isWeakMap(value) {
|
||||
return typeof value == 'object' && value !== null && getTag(value) == '[object WeakMap]'
|
||||
return isObjectLike(value) && getTag(value) == '[object WeakMap]'
|
||||
}
|
||||
|
||||
export default isWeakMap
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import getTag from './.internal/getTag.js'
|
||||
import isObjectLike from './isObjectLike'
|
||||
|
||||
/**
|
||||
* Checks if `value` is classified as a `WeakSet` object.
|
||||
@@ -16,7 +17,7 @@ import getTag from './.internal/getTag.js'
|
||||
* // => false
|
||||
*/
|
||||
function isWeakSet(value) {
|
||||
return typeof value == 'object' && value !== null && getTag(value) == '[object WeakSet]'
|
||||
return isObjectLike(value) && getTag(value) == '[object WeakSet]'
|
||||
}
|
||||
|
||||
export default isWeakSet
|
||||
|
||||
Reference in New Issue
Block a user