flatcopy
Micro-Library for flat object or array copies in context of immutable objects/arrays. This is just a small wrapper library with some checks, designed for writing safe code for object mutation.
Immutable States
Many change detection strategies profit from immutable structures. That recursively means, that if a piece of data needs to be changed, the parent has to be copied before, to not mutate it and that applies up to the root node.
If oldNode === newNode
then nothing changed. E.g. for view updates etc. this can be
a great performance boost.
// example impl. of a state transition with immutable states // flat copy or an empty object; // 1. flat copy or an empty array// 2. mutation of our `_state` copy; // 1. flat copy of an empty object// 2. mutation of our `_persons` copy;_person.name = personName; // `_state` is the next state without mutation of any objects// _state.persons !== state.persons// _state.persons[personId] !== state.persons[personId]// _state.persons[personId].name !== state.persons[personId].name