What would be the equivalent here to Ramda's lensPath and set functionality
const obj = {
a: {
b: {
c: 1
}
},
d: {
e: 2
}
}
const obj2 = R.set(R.lensPath(['a','b','c'] ),99,obj)
// now let do bad things and mutate
obj.d.e = 99
console.log(obj2)
// ... e: 99 ...
It seems that only the modified path is updated, other branches of the object are left referencing nodes as before. I imagine this is for efficiency purposes, for example, illustrated in this video--only the updated node is copied.
Sanctuary will one day provide S.view, S.over, S.set, and at least one function for defining lenses (#177). This was not a high priority for me until I found myself making heavy use of lenses in a project last week, and added Ramda as a dependency just to use the handful of lens-related functions.
Most helpful comment
Sanctuary will one day provide
S.view,S.over,S.set, and at least one function for defining lenses (#177). This was not a high priority for me until I found myself making heavy use of lenses in a project last week, and added Ramda as a dependency just to use the handful of lens-related functions.