Skip to content

Instantly share code, notes, and snippets.

@dominictarr
Forked from Raynos/through vs duplex
Created August 4, 2012 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dominictarr/3253235 to your computer and use it in GitHub Desktop.
Save dominictarr/3253235 to your computer and use it in GitHub Desktop.

through stream

.----------------------------------------.
| write(data)-------->emit('data', data`)|
`----------------------------------------`

duplex stream (across a network)

                               |
 .--client-stream---------.    |     .----server-stream-------.
 |                        |    |     |                        |
 |  write(data1) ----------------------> emit('data', data1)  |
 |                        |    |     |                        |
 |  emit('data', data2) <-------------- write(data2)          |
 |                        |    |     |                        |
 `------------------------`    |     `------------------------`
                               |

duplex stream (to an abstraction)

                               |
 .--dnode-stream----------.    | 
 |                        |    |   /* what does dnode do here ? */  
 |  write(data1) --------------->  
 |                        |    |     D N O D E
 |  emit('data', data2) <-------
 |                        |    |   /*  that is up to dnode  */
 `------------------------`    |`
                               |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment