Inflate Object Spread
The library exposes one function inflate(obj: Object, newObj: Object) => Object
.
Example:
const oldState = { foo: { bar: 0 } };
const increment = (state) => inflate(state, { 'foo.bar': state.foo.bar + 1 });
const newState = increment(oldState); // { foo: { bar: 1 } }
increment(newState); // { foo: { bar: 2 } }
Installation & Usage
You can import the mixin and use it in the app like so:
;// umd// const inflate = inflateObjectSpread;// pre es6// var inflate = inflateObjectSpread.inflate;
Deep object with spread
Set an the properties of a deep path, while retaining the other properties. This means that you can send an object, and it's properties will be set instead of the new object replaces the existing one
before
after
Author notes
Further improvements:
- array manipulation with index (possible api's)
{ 'app.counters.0.value': 10 }
{ 'app.counters[0].value': 10 }
{ 'app.counters.[0].value': 10 }