Open
Conversation
OlliV
requested changes
Sep 18, 2019
Collaborator
OlliV
left a comment
There was a problem hiding this comment.
If nr would be set to null this would happen: null | 0 === 0
| capacity?: number; | ||
| } = {} | ||
| ) { | ||
| if ((nr | 0) !== nr) { |
Collaborator
There was a problem hiding this comment.
Suggested change
| if ((nr | 0) !== nr) { | |
| if (nr && !Number.isInteger(nr)) { |
Author
There was a problem hiding this comment.
actually, nr should be a positive non-zero integer, so how about if (!nr || nr < 1 || (nr | 0) !== nr)?
Number.isInteger doesn't exist in IE, but maybe that's not an issue?
Collaborator
There was a problem hiding this comment.
Good point, that seems good to me!
Oh no, I didn't thought about that. The polyfill is actually quite simple:
Number.isInteger = Number.isInteger || function(value) {
return typeof value === 'number' &&
isFinite(value) &&
Math.floor(value) === value;
};Of course we shouldn't actually polyfill it but maybe just do these checks in the if clause.
Number.isFinite() seems to have an implemented in all browsers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 mistakenly assumed that 0.5 rps would work…