Skip to content

Commit 04a138f

Browse files
committed
Use hasOwnProperty from prototype
1 parent 976f2ad commit 04a138f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/io/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const os = require('os')
55
const linux = require('./linux')
66
const noop = require('./noop')
77

8+
const has = (obj, k) => Object.prototype.hasOwnProperty.call(obj, k)
9+
810
const types = {
911
linux,
1012
darwin: linux,
@@ -20,7 +22,7 @@ const getDefaultType = () => {
2022
module.exports = (type) => {
2123
const typeIsNotNil = type != null
2224
const typeIsCustomObject = typeIsNotNil && typeof type === 'object'
23-
const typeIsNotSupported = typeIsNotNil && !types.hasOwnProperty(type)
25+
const typeIsNotSupported = typeIsNotNil && !has(types, type)
2426

2527
if (typeIsCustomObject) return type
2628

lib/package-checker.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ const defaultType = () => {
6060
if (commandExists('pkg')) return 'pkgng'
6161
}
6262

63+
const has = (obj, k) => Object.prototype.hasOwnProperty.call(obj, k)
64+
6365
module.exports = (type) => {
6466
const typeIsNotNil = type != null
6567
const typeIsCustomFunction = typeIsNotNil && typeof type === 'function'
66-
const typeIsNotSupported = typeIsNotNil && !types.hasOwnProperty(type)
68+
const typeIsNotSupported = typeIsNotNil && !has(types, type)
6769

6870
if (typeIsCustomFunction) return type
6971

0 commit comments

Comments
 (0)