Javascript's Object.freeze does not recursively freeze objects. This module does that for you.
nestedfreeze
is faster than deepfreeze
.
npm install nestedfreeze --save
const freeze = require('nestedfreeze')
let obj = {
foo: {
baz: 'do esse esse et dolor'
},
bar: {
qux: 'sit cupidatat anim occaecat elit'
}
}
freeze(obj)
obj.foo.baz = 'change me'
console.log(obj.foo.baz) // do esse esse et dolor
npm run test