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
KRNL-221 add callChunked array function #41
KRNL-221 add callChunked array function #41
Changes from 5 commits
b9e7cc0
1a4d339
b89c83d
64f879a
aaedab9
e526406
044553c
58ddc2d
ce1ff5a
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.
🟢 Feel free to ignore this comment as beyond the scope of this PR... but I really don't like what's going on in the
chunk
function. Ignoringno-unsafe-return
is dangerous, and the implementation is especially fiddly and prone to error.Chunking can be expressed rather naturally with a generator function which yields one chunk at a time. We can gather them into an array with
Array.from
. Here's an example alternative 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.
This seems to contradict the RED flag.
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.
That's fair. My instinct had been "this is something I feel very strongly about"... but it is naturally contradicted by "... but it might not at all be relevant to this PR".
I'll edit to 🟢
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.
🔶 Very surprised that you don't use the
chunk
function directly above. If you did you could have: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.
This can also be done as a promise reducer:
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.
for of
is slower than old-school looping, so for a low-level library I would recommend keeping the original approach.see https://github.com/kibertoad/nodejs-benchmark-tournament/blob/master/loops/_results/results.md
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.
And I'm not sure how I feel about using reduce here, sounds like an overcomplication. Original version is pretty simple.
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.
So, what should I do at the end?:)
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.
Personally I see no reason to change this code, for me it is as simple as it needs to be, I see no advantages, performance or complexity-wise in suggested alternatives.
@rupert-mckay This is a yellow, non-blocking-but-please-explain-your-position comment, right?
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.
Yup. Happy for the PR to merge as-is. Still a bit surprised that the
chunk
helper isn't used, but it's not important.