Name: js-handler/node_modules/nodeunit/node_modules/tap/bin/tap-reader.js
| 1: | #!/usr/bin/env node |
| 2: | |
| 3: | // read a tap stream from stdin. |
| 4: | |
| 5: | var TapConsumer = require("../lib/tap-consumer") |
| 6: | , TapProducer = require("../lib/tap-producer") |
| 7: | |
| 8: | var tc = new TapConsumer |
| 9: | , tp = new TapProducer |
| 10: | |
| 11: | //process.stdin.pipe(tc) |
| 12: | process.stdin.on("data", function (c) { |
| 13: | c = c + "" |
| 14: | // console.error(JSON.stringify(c).substr(0, 100)) |
| 15: | tc.write(c) |
| 16: | }) |
| 17: | process.stdin.on("end", function () { tc.end() }) |
| 18: | process.stdin.resume() |
| 19: | //tc.pipe(tp) |
| 20: | tc.on("data", function (c) { |
| 21: | tp.write(c) |
| 22: | }) |
| 23: | tc.on("end", function () { tp.end() }) |
| 24: | |
| 25: | tp.on("data", function (c) { |
| 26: | console.error(["output write", c]) |
| 27: | process.stdout.write(c) |
| 28: | }) |
| 29: | |
| 30: | tp.on("end", function (er, total, ok) { |
| 31: | if (er) throw er |
| 32: | process.exit(total - ok) |
| 33: | }) |
