-
Notifications
You must be signed in to change notification settings - Fork 19
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
add bytesRead to FileStream #51
Conversation
…eadBytes-to-FileStream � Conflicts: � CHANGELOG.md
Before: Mean time for fastify-busboy is 291910.52376131905 nanoseconds So approximately 1% loss of performance, which is likely to be within the margin of error. Of course, it is still faster than the original: @Uzlopak Thoughts? Personally I think it's acceptable if there is benefit to having this data exposed. |
On second thought I think this is not the best solution. I reread the code and I think we just need to assign nsize in that branch and the branch above when we truncate the file. There is I think no need for the ternary operation. Will check that later. |
…pak/busboy into add-readBytes-to-FileStream
Is the mathemal changes made by me correct? |
Will be back in few hours and will check! |
wonder if we can have interim state unit test for this |
I actually find it prone to a race condition that I first emit the limit event and later set the bytesRead attribute. That's why I moved the truncated attribute change above the emit. Should we set the bytesRead above the emit? Additional to the bytesRead below the if block. In worst case bytesRead is set twice it limit is hit, which is imho acceptable. Wdyt? |
made it less race condition prone |
Inspired by mscdex/busboy#174 by @ahuigo
FileStream will be similar to FS.ReadStream and provide the attribute bytesRead.
Checklist
npm run test
andnpm run benchmark
and the Code of conduct