深入浅出了解Node.js Streams(2)

const Stream = require('stream') const readableStream = new Stream.Readable() readableStream._read = (size) => { console.log('read', size) } const writableStream = new Stream.Writable() writableStream._write = (chunk, encoding, next) => { console.log('write', chunk.toString()) next() } readableStream.pipe(writableStream) readableStream.push('hi!') readableStream.push('ho!') /* log: read 16384 write hi! write ho! */

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/e8ccc7aaa067b1de1b0b49bbd83ca2aa.html