当流中没有数据可供消费时触发。

    'end' 事件只有在数据被完全消费掉后才会触发。 要想触发该事件,可以将流转换到流动模式,或反复调用 [stream.read()][stream-read] 直到数据被消费完。

    1. const readable = getReadableStreamSomehow();
    2. readable.on('data', (chunk) => {
    3. console.log(`接收到 ${chunk.length} 个字节的数据`);
    4. });
    5. readable.on('end', () => {
    6. console.log('已没有数据');
    7. });