最近,我開始學習與Nodeschool練習Node.js。但我有問題,對這個問題的理解解決方案:瞭解異步Javascript代碼
Your program will get some html written to stdin. Convert all the inner html to
upper-case for elements with a class name of "loud".
官方的解決辦法是:
var trumpet = require('trumpet');
var through = require('through');
var tr = trumpet();
var loud = tr.select('.loud').createStream();
loud.pipe(through(function(buf){
this.queue(buf.toString().toUpperCase());
})).pipe(loud);
process.stdin.pipe(tr).pipe(process.stdout);
我不能理解的是,這一部分:
process.stdin.pipe(tr).pipe(process.stdout);
這個代碼不使用響亮變量輸出解決方案。任何人都可以解釋我這個魔法代碼?
P.S:我來自PHP的Node.js,並且在理解Async Javascript時遇到了問題。
你應該閱讀'trumpet'的文檔可以[在這裏找到](https://github.com/substack/node-trumpet),因爲這似乎是你不理解的模塊。 –