/*************BEEP BOOP*****************/
//console.log('beep boop');
/*************MEET PIPE******************/
// var fs = require("fs");
// var file = process.argv[2];
// fs.createReadStream(file).pipe(process.stdout);
/**************INPUT OUTPUT*******************/
//process.stdin.pipe(process.stdout);
/***************TRANSFORM*********************/
// var through = require("through2");
// var stream = through(function(buffer, encoding, next) {
// this.push(buffer.toString().toUpperCase());
// next();
// }, function(done) {
// done();
// });
// process.stdin.pipe(stream).pipe(process.stdout);
/********************LINES *************************/
// var through = require("through2");
// var split = require("split");
// var flag = true;
// var stream = through(function(buf, _, next) {
// var out = flag ? buf.toString().toLowerCase() : buf.toString().toUpperCase();
// this.push(out + "\n");
// flag = !flag;
// next();
// });
// process.stdin.pipe(split()).pipe(stream).pipe(process.stdout);
/********************CONCAT***************************/
// var cs = require("concat-stream");
// var through = require("through2");
// function reverse(str) {
// var r = "";
// for (var i = str.length - 1; i >= 0; i--) {
// r += str.charAt(i);
// }
// return r;
// }
// var reverseServer = cs(function(body) {
// var out = reverse(body.toString());
// process.stdout.write(out);
// });
// process.stdin.pipe(reverseServer);
/*********************http server********************/
// var http = require("http");
// var through = require("through2");
// var port = process.argv[2];
// var upperCase = through(function(buf, _, next) {
// this.push(buf.toString().toUpperCase());
// next();
// });
// http.createServer(function(req, res) {
// if (req.method === "POST") {
// req.pipe(upperCase).pipe(res);
// } else {
// req.pipe(res);
// }
// }).listen(port);
/*********************http client***************************/
// var request = require("request");
// var r = request.post("http://localhost:8099/");
// process.stdin.pipe(r);
// r.pipe(process.stdout);
/**********************web socket*************************/
// var ws = require("websocket-stream");
// var w = ws("ws://localhost:8099/");
// w.write("hello\n");
/**********************html stream**********************************/
// var trumpet = require("trumpet");
// var through = require("through2");
// var fs = require("fs");
// var tr = trumpet();
// var ele = tr.select(".loud").createStream();
// var th = through(function(buf, _, next) {
// this.push(buf.toString().toUpperCase());
// next();
// });
// ele.pipe(th).pipe(ele);
// process.stdin.pipe(tr).pipe(process.stdout);
/********************************duplexer*******************************/
// var duplexer2 = require("duplexer2");
// var span = require("child_process").spawn;
// module.exports = function(cmd, args) {
// var cp = span(cmd, args);
// return duplexer2(cp.stdin, cp.stdout);
// }
/***************************duplexer***************************************/
// var duplexer2 = require("duplexer2");
// var through = require('through2');
// var test = function(counter) {
// var countries = {};
// var th = through.obj(function(obj, encoding, done) {
// if (obj.country in countries) {
// countries[obj.country]++;
// } else {
// countries[obj.country] = 1;
// }
// done();
// }, function(d) {
// counter.setCounts(countries);
// d();
// });
// var duplex = duplexer2({
// objectMode: true
// }, th, counter);
// return duplex;
// };
// module.exports = test;
/************************************COMBINER*************************************/
// var combine = require("stream-combiner");
// var split = require("split");
// var through = require("through2");
// var zlib = require("zlib");
// module.exports = function() {
// var temp = null;
// return combine(split(), through.obj(function(data, _, next) {
// if (data.length > 0) {
// data = JSON.parse(data);
// var _type = data["type"];
// var _name = data["name"];
// if (_type == "genre") {
// if (temp) {
// this.push(JSON.stringify(temp));
// this.push("\n");
// }
// temp = new Object();
// temp.name = _name;
// temp.books = new Array();
// } else if (_type == "book") {
// temp.books.push(_name);
// }
// }
// next();
// }, function(end) {
// if (temp) {
// this.push(JSON.stringify(temp));
// this.push("\n");
// }
// end();
// }), zlib.createGzip());
// }
/********************************CRYPTO*****************************/
var crypto = require("crypto");
var key = process.argv[2];
var stream = crypto.createDecipher('aes256', key);
process.stdin.pipe(stream).pipe(process.stdout);
NodeSchool教程stream-adventure的实现
最新推荐文章于 2024-05-16 09:42:19 发布