Travis build: 313

This commit is contained in:
30secondsofcode
2018-09-01 10:09:50 +00:00
parent 1fe1d4318b
commit cb98d837b2
13 changed files with 55 additions and 14 deletions

View File

@ -359,6 +359,7 @@ average(1, 2, 3);
* [`bindAll`](#bindall)
* [`deepClone`](#deepclone)
* [`deepFreeze`](#deepfreeze)
* [`defaults`](#defaults)
* [`dig`](#dig)
* [`equals`](#equals-)
@ -6496,6 +6497,37 @@ const b = deepClone(a); // a !== b, a.obj !== b.obj
<br>[⬆ Back to top](#table-of-contents)
### deepFreeze
Deep freezes an object.
Calls `Object.freeze(obj)` recursively on all unfrozen properties of passed object that are `instanceof` object.
```js
const deepFreeze = obj =>
Object.keys(obj).forEach(
prop =>
!obj[prop] instanceof Object || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])
) || Object.freeze(obj);
```
<details>
<summary>Examples</summary>
```js
'use strict';
const o = deepFreeze([1, [2, 3]]);
o[0] = 3; // not allowed
o[1][0] = 4; // not allowed as well
```
</details>
<br>[⬆ Back to top](#table-of-contents)
### defaults
Assigns default values for all properties in an object that are `undefined`.