Closed iamjochem closed 7 years ago
This solves the #66 for me
Also solving #66 in my case. Cheers to @iamjochem!
Hey! I left a few comments. I am not a fan of Object.assign()
tbh, mainly because it's not quite supported everywhere, so I am a bit hesitant. I am down to use extend or xtend, however to create a new object.
Object.assign()
in node v4+ (not sure down to what version you are supporting) is fine for simple object cloning, but extend()
is better here if only because it is doing a deep clone (which even if you don't need it now will save us all another round of time-wasting musical-"options-are-changing-under-my-feet"-chairs.)
@lrlna - I rebased my PR to get rid of the conflicts with master but ended up doing this in a fork of my fork (silly rabbit)... which meant I couldn't push the changes ... probably there are git incantations that will fix such a situation but I took the easy/crufty way out and created a new PR.
see #66 for reasoning.
1. & 2. are easy to fix -
Object.assign()
is your friend - if everyone would just do this we'd be free of so many bugs related to objects passed in as parameters being changed by the callee.3. - this one requires a change of mindset so that we start treating options object parameters as collections from which known/valid option properties are extracted; this is in constrast to the heavy-handed use of, for instance, JSON schema to validate a given options object and throw an esoteric Error if the options are "invalid" ... which is really helpful when your using a lib indirectly (e.g.
babel
from the context ofuglifyify
)