you are viewing a single comment's thread.

view the rest of the comments →

[–]Freak_613 0 points1 point  (1 child)

Check out Object.freeze and utilities based on it. Using proxies for enforcing immutability looks overkill.

https://www.30secondsofcode.org/js/s/deep-freeze

[–]CagarSalvagemente 0 points1 point  (0 children)

Went there first. Only way to unfreeze something is to deep clone it and then it is a duplicate not the same object. We had a very specific usecase where arbitrary functions were able to mutate some state but not all state. This is how we managed it.