Skip to content

Commit

Permalink
Update object checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Apr 24, 2017
1 parent a6019d5 commit f03b3ed
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .internal/cloneBuffer.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion .internal/freeGlobal.js
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .internal/nodeUtil.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion .internal/root.js
Original file line number Diff line number Diff line change
@@ -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')()
Expand Down
2 changes: 1 addition & 1 deletion isArguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions isBuffer.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion isObjectLike.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object'
return typeof value == 'object' && value !== null
}

export default isObjectLike
2 changes: 1 addition & 1 deletion isSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion isTypedArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion isWeakMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion isWeakSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f03b3ed

Please sign in to comment.