Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Issue 374: Allow an option to choose the hashing algorithm #375
Issue 374: Allow an option to choose the hashing algorithm #375
Changes from 1 commit
a230423
7349650
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to throw an error in this case, since we already have a default value and this probably a result of an error.
What do u think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To save you time, my current commit has your suggestion implemented. Feel free to ignore the below text if that satisfies you.
You did, however, ask for my thoughts. 0:-)
I went back and forth on this.
Keep in mind, all of the text below is internal library design discussion. As written, all of these options work the same from an outside user's perspective.
What I think
buildOptions
should beIn my opinion, the purpose of the
buildOptions
function should be to provide a valid Options object to be used by the rest of the application. It should be able to take in an empty object or no object, and still provide back a valid Options object with the minimal/required properties set. It should also do some kind of value validation before the return, as the user may have provided incorrect values or value types in their argument. It should provide the default values in the scope of the function, rather than requiring them to be passed in as the 1st argument to the function.What
buildOptions
currently isDefault values is not an intrinsic part of
buildOptions
. All it does currently is it creates a union of the provided objects, where overlapping values are overwritten by the last object in the arguments.What
buildOptions
is with my changesThe same as current, but if no argument provides hashAlgorithm, we return an object that has the default value. Developer can still pass in objects that don't contain a hashAlgorithm, and we just add it to the returned options.
We throw an error if the Developer provides an unsupported value for hashAlgorithm.
What
buildOptions
is with the above suggestionThe same as current, but if no argument provides hashAlgorithm, we throw an error. The same behavior for if it receives an invalid hashAlgorithm.
I feel like the last one changes the intent of the function (as the current utilities tests describe it) as currently written, more than my previous implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of such formatting with concats?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm never sure if the + should be trailing, or start the new line. I moved to the new line for you.
If the question is "why did I concatenate?": It exceeded the defined linter character limit.