immutator
a redux-inspired state mutator.
npm install immutator
be aware: immutator uses Proxy
. see node support and browser support.
example
const immutator = const state = try statecount++ catch err console console // { count: 0 } // define mutator `increment`state statecount++ // call mutatorstate console // { count: 1 }
state
is a proxy whose target can only be mutated by defining and calling a mutator.
functions defined on the immutator are mutators. mutators are passed a mutable copy of state as their first argument when they are called. while they share the same namespace, defining a mutator does not affect state.