dominictarr / scuttlebutt

peer-to-peer replicatable data structure
Other
1.32k stars 66 forks source link

idea: just use one type of stream #13

Closed dominictarr closed 11 years ago

dominictarr commented 11 years ago

I want to adjust the protocol so that I only need one type of stream. you will still replicate with duplex streams...

stream.pipe(scuttlebutt.createStream()).pipe(stream)

but I want to make that work with fs streams also,


var rs = fs.createReadStream(file)
var ss = scuttlebutt.createStream()

rs.pipe(ss)
ss.pause()
rs.on('close', function () {
  ss.pipe(fs.createWriteStream(file, {flags: 'a'}))
})

or, use make a duplex fs stream that works like that...

dominictarr commented 11 years ago

done