Fix the same format as other methods

I think the consistency of the format is good and necessary.
This commit is contained in:
lvzhenbang
2017-12-25 13:41:45 +08:00
committed by GitHub
parent d9e358990c
commit 83c5a947af

View File

@ -7,17 +7,16 @@ Also if you give it a special key (`childIndicator`) it will search deeply insid
```js ```js
const cleanObj = (obj, keysToKeep = [], childIndicator) => { const cleanObj = (obj, keysToKeep = [], childIndicator) => {
Object.keys(obj).forEach(key => { return Object.keys(obj).forEach(key => {
if (key === childIndicator) { if (key === childIndicator) {
cleanObj(obj[key], keysToKeep, childIndicator); cleanObj(obj[key], keysToKeep, childIndicator);
} else if (!keysToKeep.includes(key)) { } else if (!keysToKeep.includes(key)) {
delete obj[key]; delete obj[key];
} }
})  }), obj
} }
/* /*
const testObj = {a: 1, b: 2, children: {a: 1, b: 2}} const testObj = {a: 1, b: 2, children: {a: 1, b: 2}}
cleanObj(testObj, ["a"],"children") cleanObj(testObj, ["a"],"children") // { a: 1, children : { a: 1}}
console.log(testObj)// { a: 1, children : { a: 1}}
*/ */
``` ```