-
Notifications
You must be signed in to change notification settings - Fork 293
Stream 'readable' event oddness #198
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
Comments
I think the I don’t know the specific reasons for this, though. |
@addaleax Does |
I’m not entirely sure I understand the question, but maybe the source of confusion is the fact that The size of that buffer is configurable through the /******************************************************************************/
'use strict';
/******************************************************************************/
const fs = require('fs');
const readStream = fs.createReadStream(__filename, {
encoding: 'utf8',
highWaterMark: 5
});
readStream.on('readable', () => {
console.log(readStream.read(3));
}); Here the |
O, I think I see now. So |
It is rather fired “as soon as it is clear that no more data will be added to the internal buffer, because the data source (i.e. the file itself) contains no more content”. After the last The event that is fired when all data has been read and the internal buffer has fully been cleared is the |
Phew) Got it. Thank you for all your time and explanations! |
Glad if it helped, and of course feel free to ask more questions here! |
@addaleax I have a csv file and it contains 6K records and I am using streams to read and csv-parse package only. So practically
|
Uh oh!
There was an error while loading. Please reload this page.
Why in this script (saved in UTF-8 with BOM) the handler is called no more and no less than twice?
The output:
The text was updated successfully, but these errors were encountered: