Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function createStream(meta) {
var ps = PauseStream()
, stream = mdm.createStream(meta)
, write = WriteStream()
, read = ReadStream()
write.pipe(ps).pipe(stream).pipe(read)
mdm.on("disconnect", function () {
ps.pause()
})
mdm.on("connect", function () {
var stream = mdm.createStream(meta)
ps.pipe(stream).pipe(read)
ps.resume()
})
return es.duplex(write, read)
}
function createStream(meta) {
var duplex = DuplexStream(write, end)
, stream = createMdmStream(meta, duplex)
mdm.on("disconnect", function () {
duplex.pause()
})
mdm.on("connect", function () {
createMdmStream(meta, duplex)
duplex.resume()
})
return duplex
function write(data) {
this.sendData(data)
}
function end() {
this.sendEnd()
}
function createMdmStream(meta, duplex) {
stream && stream.destroy()
stream = _createStream(meta, duplex)
duplex.pipe(stream).pipe(duplex, {
end: false
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.