File tree 1 file changed +5
-10
lines changed
1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -53,20 +53,15 @@ function chaiExclude (chai, utils) {
53
53
*/
54
54
function removeKeysFromObject ( obj , props , recursive = false ) {
55
55
const res = { }
56
- const keys = Object . keys ( obj )
57
- const isRecursive = ! ! recursive
58
56
59
- for ( let i = 0 ; i < keys . length ; i ++ ) {
60
- const key = keys [ i ]
61
- const val = obj [ key ]
57
+ for ( const [ key , val ] of Object . entries ( obj ) ) {
58
+ if ( props . includes ( key ) ) continue
62
59
63
- const hasKey = props . indexOf ( key ) === - 1
64
-
65
- if ( isRecursive && hasKey && isObject ( val ) ) {
60
+ if ( recursive && isObject ( val ) ) {
66
61
res [ key ] = removeKeysFromObject ( val , props , true )
67
- } else if ( isRecursive && hasKey && isArray ( val ) ) {
62
+ } else if ( recursive && isArray ( val ) ) {
68
63
res [ key ] = removeKeysFromArray ( val , props , true )
69
- } else if ( hasKey ) {
64
+ } else {
70
65
res [ key ] = val
71
66
}
72
67
}
You can’t perform that action at this time.
0 commit comments