mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
Update object checks.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import root from './root.js'
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
const freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports
|
||||
const freeExports = typeof exports == 'object' && exports !== null && !exports.nodeType && exports
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
const freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module
|
||||
const freeModule = freeExports && typeof module == 'object' && module !== null && !module.nodeType && module
|
||||
|
||||
/** Detect the popular CommonJS extension `module.exports`. */
|
||||
const moduleExports = freeModule && freeModule.exports === freeExports
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
const freeGlobal = typeof global == 'object' && global && global.Object === Object && global
|
||||
const freeGlobal = typeof global == 'object' && global !== null && global.Object === Object && global
|
||||
|
||||
export default freeGlobal
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import freeGlobal from './freeGlobal.js'
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
const freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports
|
||||
const freeExports = typeof exports == 'object' && exports !== null && !exports.nodeType && exports
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
const freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module
|
||||
const freeModule = freeExports && typeof module == 'object' && module !== null && !module.nodeType && module
|
||||
|
||||
/** Detect the popular CommonJS extension `module.exports`. */
|
||||
const moduleExports = freeModule && freeModule.exports === freeExports
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import freeGlobal from './freeGlobal.js'
|
||||
|
||||
/** Detect free variable `self`. */
|
||||
const freeSelf = typeof self == 'object' && self && self.Object === Object && self
|
||||
const freeSelf = typeof self == 'object' && self !== null && self.Object === Object && self
|
||||
|
||||
/** Used as a reference to the global object. */
|
||||
const root = freeGlobal || freeSelf || Function('return this')()
|
||||
|
||||
@@ -16,7 +16,7 @@ import getTag from './.internal/getTag.js'
|
||||
* // => false
|
||||
*/
|
||||
function isArguments(value) {
|
||||
return typeof value == 'object' && value != null && getTag(value) == '[object Arguments]'
|
||||
return typeof value == 'object' && value !== null && getTag(value) == '[object Arguments]'
|
||||
}
|
||||
|
||||
export default isArguments
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import root from './.internal/root.js'
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
const freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports
|
||||
const freeExports = typeof exports == 'object' && exports !== null && !exports.nodeType && exports
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
const freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module
|
||||
const freeModule = freeExports && typeof module == 'object' && module !== null && !module.nodeType && module
|
||||
|
||||
/** Detect the popular CommonJS extension `module.exports`. */
|
||||
const moduleExports = freeModule && freeModule.exports === freeExports
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* // => false
|
||||
*/
|
||||
function isObjectLike(value) {
|
||||
return value != null && typeof value == 'object'
|
||||
return typeof value == 'object' && value !== null
|
||||
}
|
||||
|
||||
export default isObjectLike
|
||||
|
||||
2
isSet.js
2
isSet.js
@@ -21,6 +21,6 @@ const nodeIsSet = nodeUtil && nodeUtil.isSet
|
||||
*/
|
||||
const isSet = nodeIsSet
|
||||
? (value) => nodeIsSet(value)
|
||||
: (value) => typeof value == 'object' && value != null && getTag(value) == '[object Set]'
|
||||
: (value) => typeof value == 'object' && value !== null && getTag(value) == '[object Set]'
|
||||
|
||||
export default isSet
|
||||
|
||||
@@ -24,6 +24,6 @@ const nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray
|
||||
*/
|
||||
const isTypedArray = nodeIsTypedArray
|
||||
? (value) => nodeIsTypedArray(value)
|
||||
: (value) => typeof value == 'object' && value != null && reTypedTag.test(getTag(value))
|
||||
: (value) => typeof value == 'object' && value !== null && reTypedTag.test(getTag(value))
|
||||
|
||||
export default isTypedArray
|
||||
|
||||
@@ -16,7 +16,7 @@ import getTag from './.internal/getTag.js'
|
||||
* // => false
|
||||
*/
|
||||
function isWeakMap(value) {
|
||||
return typeof value == 'object' && value != null && getTag(value) == '[object WeakMap]'
|
||||
return typeof value == 'object' && value !== null && getTag(value) == '[object WeakMap]'
|
||||
}
|
||||
|
||||
export default isWeakMap
|
||||
|
||||
@@ -16,7 +16,7 @@ import getTag from './.internal/getTag.js'
|
||||
* // => false
|
||||
*/
|
||||
function isWeakSet(value) {
|
||||
return typeof value == 'object' && value != null && getTag(value) == '[object WeakSet]'
|
||||
return typeof value == 'object' && value !== null && getTag(value) == '[object WeakSet]'
|
||||
}
|
||||
|
||||
export default isWeakSet
|
||||
|
||||
Reference in New Issue
Block a user