Skip to content
Browse files

pipe tap to the console

  • Loading branch information...
1 parent 11b72c1 commit cc268b319deb4e34e7788e695a5df69b5c11ca82 @substack committed
Showing with 26 additions and 6 deletions.
  1. +11 −4 bin/cmd.js
  2. +13 −1 browser/output.js
  3. +1 −0 example/form.js
  4. +1 −1 package.json
View
15 bin/cmd.js
@@ -15,9 +15,9 @@ var port = {
server : 54046
};
-var script = '<script src="http://localhost:'
- + port.server
- + '/proxy.js"></script>'
+var script = '<script src="'
+ + 'http://localhost:' + port.server + '/proxy.js'
+ + '"></script>'
;
var proxy = insertProxy(script, [ 'http://localhost:' + port.server ]);
proxy.listen(port.proxy);
@@ -25,8 +25,15 @@ proxy.listen(port.proxy);
var server = http.createServer(ecstatic);
server.listen(port.server);
+var JSONStream = require('JSONStream');
var sock = shoe(function (stream) {
- stream.pipe(process.stdout, { end : false });
+ var tapProducer = new(require('tap/lib/tap-producer'));
+ stream
+ .pipe(JSONStream.parse([ true ]))
+ .pipe(tapProducer)
+ .on('end', function () { console.log('--------') })
+ .pipe(process.stdout, { end : false })
+ ;
});
sock.install(server, '/push');
View
14 browser/output.js
@@ -6,6 +6,18 @@ var push = JSONStream.stringify();
push.pipe(require('shoe')('/push'));
var es = require('event-stream');
-var stream = module.exports = es.through();
+var stream = module.exports = (function () {
+ var s = new Stream;
+ s.writable = true;
+ s.readable = true;
+
+ s.write = function (buf) { s.emit('data', buf) };
+
+ s.end = function (buf) {
+ if (buf !== undefined) s.write(buf);
+ s.emit('end');
+ };
+ return s;
+})();
stream.pipe(render);
stream.pipe(push);
View
1 example/form.js
@@ -5,6 +5,7 @@ test('submit a form', function (t) {
var uri = 'http://localhost:7272/test-form/';
var w = t.createWindow(uri, { t : t });
+
w.next(function (win, $) {
t.log('page[0]: ' + win.location.href);
View
2 package.json
@@ -29,7 +29,7 @@
"mkdirp" : "~0.3.3",
"tap" : "~0.2.5",
"browserify" : "~1.13.1",
- "shoe" : "~0.0.0",
+ "shoe" : "~0.0.1",
"event-stream" : "~2.0.4",
"JSONStream" : "~0.3.0"
},

0 comments on commit cc268b3

Please sign in to comment.
Something went wrong with that request. Please try again.