Skip to content

Instantly share code, notes, and snippets.

@hillct
Forked from bowin/node.js PassThrough stream.md
Created January 28, 2020 22:13
Show Gist options
  • Save hillct/133bba682041d4203a7a13818c14639d to your computer and use it in GitHub Desktop.
Save hillct/133bba682041d4203a7a13818c14639d to your computer and use it in GitHub Desktop.
Node.js Stream PassThrough Usage
const {PassThrough} = require('stream')
const fs = require('fs')

const d = new PassThrough()  

fs.createReadStream('tt2.js').pipe(d)  // can be piped from reaable stream

d.pipe(process.stdout)                 // can pipe to writable stream 
d.on('data', console.log)              // also like readable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment