replace extra method with string parameter #24
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.
I really don't like having two almost identical methods which differ only in their handling of an edge case. This PR removes
sliding
and adds a string parameter towindows
which controls the behavior in the case of an undersized iterator, with possible values"discard"
(the default) or"truncate"
(the previous behavior forsliding
). Feel free to bikeshed the values if you have strong opinions. I left out"throw"
but I guess it's also a valid thing to want (edit: #25).I've chosen to go with a string argument instead of a boolean so that we can later turn this into an options bag if we really feel the need. Boolean would also be fine but makes it harder to do that change (because we said we'd allow coercion to boolean).
Fixes #23 (by causing it not to be a problem).