mariocasciaro / object-path

A tiny JavaScript utility to access deep properties using a path (for Node and the Browser)
MIT License
1.06k stars 84 forks source link

Transform properties #117

Open bartbutenaers opened 3 years ago

bartbutenaers commented 3 years ago

Dear, Thanks for sharing this useful library!

I was wondering if it is somehow possible to transform object properties (from original value into a new value).

Something like this:

objectPath.set(obj, "a.j.0.f", function(originalValue) {
   var newValue = originalValue + 2;
   return newValue;
});

Kind regards, Bart