Skip to content

Instantly share code, notes, and snippets.

@chrishalebarnes
Created April 5, 2019 20:41
Show Gist options
  • Save chrishalebarnes/9e7b1350dd38fb40b4a4c0f6e793489f to your computer and use it in GitHub Desktop.
Save chrishalebarnes/9e7b1350dd38fb40b4a4c0f6e793489f to your computer and use it in GitHub Desktop.
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