Created
April 5, 2019 20:41
-
-
Save chrishalebarnes/9e7b1350dd38fb40b4a4c0f6e793489f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deepFreeze(obj) { | |
return Object.entries(obj).reduce((result, [name, value]) => { | |
Object.freeze(result); | |
result[name] = value && value !== null && typeof value === 'object' ? deepFreeze(value) : value; | |
return result; | |
}, obj); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment