Created
June 19, 2012 10:28
-
-
Save tanepiper/2953426 to your computer and use it in GitHub Desktop.
new pipe-able dnode api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var dnode = require('../../lib/dnode'); | |
| var net = require('net'); | |
| var d = new dnode(); | |
| d.on('remote', function (remote) { | |
| remote.transform('beep', function (s) { | |
| console.log('beep => ' + s); | |
| d.end(); | |
| }); | |
| }); | |
| var c = net.connect(5004); | |
| c.pipe(d).pipe(c); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var dnode = require('../../lib/dnode'); | |
| var net = require('net'); | |
| var server = net.createServer(function (c) { | |
| var d = new dnode({ | |
| transform : function (s, cb) { | |
| cb(s.replace(/[aeiou]{2,}/, 'oo').toUpperCase()) | |
| } | |
| }); | |
| c.pipe(d).pipe(c); | |
| }); | |
| server.listen(5004); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| substack : stream $ node listen.js & | |
| [1] 19229 | |
| substack : stream $ node connect.js | |
| beep => BOOP | |
| substack : stream $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment