From c1f805f4972843b675056b2786f1165f7db81737 Mon Sep 17 00:00:00 2001 From: alireza valizade Date: Mon, 19 Feb 2018 11:56:01 +0330 Subject: [PATCH] use isObjectLike module instead of (typeof value == 'object' && value !== null) in another modules (#3650) --- isArguments.js | 3 ++- isSet.js | 3 ++- isTypedArray.js | 3 ++- isWeakMap.js | 3 ++- isWeakSet.js | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/isArguments.js b/isArguments.js index abee6554d..0bfdbe12c 100644 --- a/isArguments.js +++ b/isArguments.js @@ -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 diff --git a/isSet.js b/isSet.js index 3314cca71..c03d00c3c 100644 --- a/isSet.js +++ b/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 diff --git a/isTypedArray.js b/isTypedArray.js index 9d2bf2a51..bef03b9b9 100644 --- a/isTypedArray.js +++ b/isTypedArray.js @@ -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 diff --git a/isWeakMap.js b/isWeakMap.js index 6cdbe1dfa..e1e2226ea 100644 --- a/isWeakMap.js +++ b/isWeakMap.js @@ -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 diff --git a/isWeakSet.js b/isWeakSet.js index 339f50257..e371002cb 100644 --- a/isWeakSet.js +++ b/isWeakSet.js @@ -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