vanillaes/absurdum

Should Set and Update return objects instead of values?

Closed this issue · 5 comments

Set and update are for changing a value at the end of a path, however in the lodash functions, the functionality is arguably in that they mutate the original object. However, they only return the mutated value where absurdum should probably return the new object with an updated value.

References

I'm conflicted. I want to say drop both but I can see their usefulness.

I agree that not mutating the input is the way to go. It's too bad Lodash doesn't combine both into the same operator.

Maybe we should add a mention in README.md that all operators are side-effect free. For example, an immutable set/update could be really useful for performing React state updates. It beats the ugly double spread sandwich pattern.

something like this?
immutibility-helper

More like what you originally suggested. Not mutating the input = immutable. Part of me still wants to exclude these from the 1.0 release.

How do you feel about it?

The usefulness seems specific to a few different patterns, so it may be better just to implement when someone asks for it.

Cool. I'll going to table them for now.