Skip to content

Commit

Permalink
Use is-plain-obj
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Sep 22, 2019
1 parent c7085c0 commit 82211b3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
21 changes: 17 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -34,6 +34,7 @@
"abstract-parser": "^0.1.0",
"chalk": "^2.4.2",
"core-js": "^3.2.1",
"is-plain-obj": "^2.0.0",
"jest-validate": "^24.9.0",
"supports-color": "^7.0.0",
"yargs": "^14.0.0"
Expand Down
5 changes: 2 additions & 3 deletions src/options.js
@@ -1,6 +1,5 @@
import { validate } from 'jest-validate'

import { isPlainObject } from './utils.js'
import isPlainObj from 'is-plain-obj'

// Validate options and assign default values
export const handleOpts = function(opts, defaultOpts, exampleConfig) {
Expand All @@ -11,7 +10,7 @@ export const handleOpts = function(opts, defaultOpts, exampleConfig) {
}

export const validateBasicOpts = function(opts) {
if (!isPlainObject(opts)) {
if (!isPlainObj(opts)) {
throw new TypeError(`Options must be a plain object: ${opts}`)
}
}
10 changes: 0 additions & 10 deletions src/utils.js
@@ -1,13 +1,3 @@
// Is a plain object, including `Object.create(null)`
export const isPlainObject = function(val) {
return (
typeof val === 'object' &&
val !== null &&
// istanbul ignore next
(val.constructor === Object || val.constructor === undefined)
)
}

// Like lodash _.omitBy()
export const omitBy = function(object, condition) {
const pairs = Object.entries(object)
Expand Down

0 comments on commit 82211b3

Please sign in to comment.