Nodejs some api~ (a) node stream 2

Source: Internet
Author: User

Writable Stream writable
Writable.write (chunk, [encoding], [callback])
Chunk {String | Buffer} The data to write
encoding {string} encoded, if chunk is a string
Callback after callback {Function} data block is written
Returns: {Boolean} True if the data has been processed all.
The return value indicates whether you should continue writing immediately. If the data needs to be stuck internally, it returns false; otherwise, it returns true.
Event Drain If. Write returns false then the drain event indicates that more data can continue to be written
writable.cork () forcibly detain all writes, the data that is stuck is written when the. uncork () or. End () is called
writable.uncork () writes all data that is stuck after the. Cork () call.
writable.end ([chunk],[encoding],[callback])
Chunk the data to write
Encoding encoded, if chunk is a string
The callback after the callback stream is called when no more data is written to the stream, and if given, the call is used as the listener for the finish event
After The event is called, and all data is written to the underlying system, this event is triggered
Event Pipe flow to the source stream of this writable stream occurs when the pipe () method of the readable stream is called and adds this writable stream as its target;

Writer.on (' pipe ',function(src) {    console.log (' Something is being channeled to writer ');})

Event Unpipe
Class stream. Duplex
For example, TCP nested word zlib stream Crypto stream
Class stream. Transform is a duplex output computed by the input, with both readable and writable interfaces
such as zlib flow, crypto flow

These two classes also do not introduce, I just look at, it is not used for the time being.

Nodejs some api~ (a) node stream 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.