Node.js streams triggers both end
and finish
events. What's the difference between both?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- How to reimport module with ES6 import
- In what practical case bool(std::ifstream) != std:
- Why is `node.js` dying when called from inside pyt
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
- MemoryStream disables reading when returned
end
andfinish
are the same event BUT on different types of Streams.stream.Readable
fires ONLYend
and NEVERfinish
stream.Writable
fires ONLYfinish
and NEVERend
Source: https://nodejs.org/dist/latest-v5.x/docs/api/stream.html
Why the different naming of the same event?
The only reason I could think of is because of duplex streams (
stream.Duplex
), which implement bothstream.Readable
andstream.Writable
interfaces (https://nodejs.org/dist/latest-v5.x/docs/api/stream.html#stream_class_stream_duplex) are readable and writable stream at the same time. To differentiate between end of reading and end of writing on the stream you must have a different event fired. SO, for Duplex streamsend
is end of reading andfinish
is end of writing.