- Version: 6.2.2
- Platform: Windows 7 x64
The 'readable' event is emitted when there is data available to be read from the stream... The 'readable' event will also be emitted once the end of the stream data has been reached but before the 'end' event is emitted.
Why in this script (saved in UTF-8 with BOM) the handler is called no more and no less than twice?
/******************************************************************************/
'use strict';
/******************************************************************************/
const fs = require('fs');
const readStream = fs.createReadStream(__filename, { encoding: 'utf8' });
readStream.on('readable', () => {
console.log(readStream.read(3));
});
The output:
Why in this script (saved in UTF-8 with BOM) the handler is called no more and no less than twice?
The output: