Travis build: 1312

This commit is contained in:
30secondsofcode
2018-01-19 11:07:33 +00:00
parent 0e89e52d50
commit 435260d6f4
2 changed files with 2 additions and 48 deletions

View File

@ -272,7 +272,6 @@ average(1, 2, 3);
<details>
<summary>View contents</summary>
* [`cleanObj`](#cleanobj)
* [`equals`](#equals-)
* [`forOwn`](#forown)
* [`forOwnRight`](#forownright)
@ -4156,39 +4155,6 @@ UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc'
---
## 🗃️ Object
### cleanObj
Removes any properties except the ones specified from a JSON object.
Use `Object.keys()` method to loop over given JSON object and deleting keys that are not included in given array.
If you pass a special key,`childIndicator`, it will search deeply apply the function to inner objects, too.
```js
const cleanObj = (obj, keysToKeep = [], childIndicator) => {
Object.keys(obj).forEach(key => {
if (key === childIndicator) {
cleanObj(obj[key], keysToKeep, childIndicator);
} else if (!keysToKeep.includes(key)) {
delete obj[key];
}
});
return obj;
};
```
<details>
<summary>Examples</summary>
```js
const testObj = { a: 1, b: 2, children: { a: 1, b: 2 } };
cleanObj(testObj, ['a'], 'children'); // { a: 1, children : { a: 1}}
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### equals ![advanced](/advanced.svg)
Performs a deep comparison between two values to determine if they are equivalent.

File diff suppressed because one or more lines are too long