Immutable Deep Update
Immutably update deeply nested data structures with ease.
example
const over set view = const user = firstname: 'Han' location: city: 'Paris' friends: fisrtname: 'Luke' location: city: 'New York' fisrtname: 'Darth Vador' location: city: 'Dark star' console/* => { firstname: 'Han', location: { city: 'Paris' } friends: [ { fisrtname: 'Luke', location: { city: 'New York City' } }, { fisrtname: 'Darth Vador', location: { city: 'Dark star' } } ]} */ console/* => { firstname: 'Han', location: { city: 'Paris' } friends: [ { fisrtname: 'Luke', location: { city: 'New York' } }, { fisrtname: 'Darth Vador', location: { city: 'Dark star' } }, { fisrtname: 'Chewi' location: { city: '?' } } ]} */
Map over array values
console// => [ 'New York', 'Dark star' ] console/* => { firstname: 'Han', location: { city: 'Paris' } friends: [ { fisrtname: 'Luke', location: { city: 'Tokyo' } }, { fisrtname: 'Darth Vador', location: { city: 'Tokyo' } } ]} */
Map over object values
const state = usersById: 'a': firstname: 'Rick' id: 'a' 'b': firstname: 'Morty' id: 'b' console// => { a: 'Rick', b: 'Morty' } console// => { usersById: { a: 'Rick - a', b: 'Morty - b' } }
Supported path
'azerty'
=> prop 'azerty''aze.rty'
=> compose (prop 'aze') (prop 'rty')'aze["rty"]'
=> compose (prop 'aze') (prop 'rty')'0'
=> index 0'[0]'
=> index 0'aze[0].rty'
=> compose (prop 'aze') (index 0) (prop 'rty')'aze.0.rty'
=> compose (prop 'aze') (index 0) (prop 'rty')'[..]'
=> map over all the items of an array'{..}'
=> map over all values of an object
Roadmap
- Nice error handling