-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't modify passed options #13
Comments
This is an expected behaviour, and follows the convention. If you want to maintain the object, pass it as a copy to themis. |
Which convention? Modifying passed in objects unless they're clearly defined as output variables is a cardinal sin everywhere, regardless of language. Any random book on good API design talks about that. ;-) |
@kumarharsh means the convention for applying defaults is followed, however I think @moll has a point. @moll I agree, there wasn't enough thought put in during the design phase while writing the initial code. Themis has largely been used as an internal tool and I've not had the time to make and document improvements in the last few months. However I'm currently working on a new version of themis which will have a much cleaner code base and one that will not mutate schema or options objects. Object mutations will occur only if you allow Themis to apply defaults. In the meanwhile if you could open a pull request to fix this issue I would be happy to merge it. |
@moll I meant to say that it was in line with what other popular libraries, like lodash, have been doing. |
Themis modifies the passed-in options object. That causes unexpected stuff when that object is shared between invocations. E.g. when given immutable options:
The text was updated successfully, but these errors were encountered: