Created
August 21, 2018 19:05
-
-
Save mafintosh/9c3b1ea99186a6590f61e205d7816026 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stream = require('stream') | |
const r = new stream.Readable({ | |
read () { | |
this.push('hello') | |
this.push('world') | |
this.push(null) | |
} | |
}) | |
r.on('data', data => console.log('r data', data)) | |
r.on('end', () => console.log('r end')) | |
r.on('close', () => console.log('r close')) | |
const t = new stream.Transform({ | |
transform (data, enc, cb) { | |
cb(null, data) | |
} | |
}) | |
t.write('hello') | |
t.write('world') | |
t.end() | |
t.on('data', data => console.log('t data', data)) | |
t.on('end', () => console.log('t end')) | |
t.on('finish', () => console.log('t finish')) | |
t.on('close', () => console.log('t close')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment