Skip to content

Instantly share code, notes, and snippets.

@chilijung
Last active August 29, 2015 14:03
Show Gist options
  • Save chilijung/7818f33b074b693b71e7 to your computer and use it in GitHub Desktop.
Save chilijung/7818f33b074b693b71e7 to your computer and use it in GitHub Desktop.
testing various streaming library
node_modules
var csvBuffStream = require('csv-multibuffer-stream');
var fs = require('fs');
var wstream = fs.createWriteStream('output');
var encoder = csvBuffStream()
fs.createReadStream('./test.csv').pipe(encoder).pipe(wstream);
var multiplex = require('multiplex')
var plex1 = multiplex()
var stream1 = plex1.createStream()
var stream2 = plex1.createStream()
var plex2 = multiplex(function onStream(stream, id) {
stream.on('data', function(c) {
console.log('data', id, c.toString())
})
})
plex1.pipe(plex2)
stream1.write(new Buffer('stream one!'))
stream2.write(new Buffer('stream two!'))
test1 test2 test3
1 2 3
test1 test2 test3
1 2 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment