Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mesaugat committed Sep 23, 2023
1 parent 247a8bd commit e267b55
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions chai-exclude.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,15 @@ function chaiExclude (chai, utils) {
*/
function removeKeysFromObject (obj, props, recursive = false) {
const res = {}
const keys = Object.keys(obj)
const isRecursive = !!recursive

for (let i = 0; i < keys.length; i++) {
const key = keys[i]
const val = obj[key]
for (const [key, val] of Object.entries(obj)) {
if (props.includes(key)) continue

const hasKey = props.indexOf(key) === -1

if (isRecursive && hasKey && isObject(val)) {
if (recursive && isObject(val)) {
res[key] = removeKeysFromObject(val, props, true)
} else if (isRecursive && hasKey && isArray(val)) {
} else if (recursive && isArray(val)) {
res[key] = removeKeysFromArray(val, props, true)
} else if (hasKey) {
} else {
res[key] = val
}
}
Expand Down

0 comments on commit e267b55

Please sign in to comment.