Skip to content

Commit

Permalink
Replace Object.constructor with {}.constructor (#151)
Browse files Browse the repository at this point in the history
Co-authored-by: Hans Kim <hans.kim@freedgrouptech.com>
  • Loading branch information
hanse-kim and Hans Kim committed May 13, 2024
1 parent e7a7903 commit ff7fa00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
const map = require('map-obj')
const { snakeCase } = require('snake-case')

const PlainObjectConstructor = {}.constructor

module.exports = function (obj, options) {
if (Array.isArray(obj)) {
if (obj.some(item => item.constructor !== Object)) {
if (obj.some(item => item.constructor !== PlainObjectConstructor)) {
throw new Error('obj must be array of plain objects')
}
} else {
if (obj.constructor !== Object) {
if (obj.constructor !== PlainObjectConstructor) {
throw new Error('obj must be an plain object')
}
}
Expand Down

0 comments on commit ff7fa00

Please sign in to comment.