Travis build: 313
This commit is contained in:
32
README.md
32
README.md
@ -359,6 +359,7 @@ average(1, 2, 3);
|
|||||||
|
|
||||||
* [`bindAll`](#bindall)
|
* [`bindAll`](#bindall)
|
||||||
* [`deepClone`](#deepclone)
|
* [`deepClone`](#deepclone)
|
||||||
|
* [`deepFreeze`](#deepfreeze)
|
||||||
* [`defaults`](#defaults)
|
* [`defaults`](#defaults)
|
||||||
* [`dig`](#dig)
|
* [`dig`](#dig)
|
||||||
* [`equals`](#equals-)
|
* [`equals`](#equals-)
|
||||||
@ -6496,6 +6497,37 @@ const b = deepClone(a); // a !== b, a.obj !== b.obj
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<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
|
### defaults
|
||||||
|
|
||||||
Assigns default values for all properties in an object that are `undefined`.
|
Assigns default values for all properties in an object that are `undefined`.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -8,9 +8,7 @@ Calls `Object.freeze(obj)` recursively on all unfrozen properties of passed obje
|
|||||||
const deepFreeze = obj =>
|
const deepFreeze = obj =>
|
||||||
Object.keys(obj).forEach(
|
Object.keys(obj).forEach(
|
||||||
prop =>
|
prop =>
|
||||||
!obj[prop] instanceof Object || Object.isFrozen(obj[prop])
|
!obj[prop] instanceof Object || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop])
|
||||||
? null
|
|
||||||
: deepFreeze(obj[prop])
|
|
||||||
) || Object.freeze(obj);
|
) || Object.freeze(obj);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user