Im이 기사를 읽고 : http://elegantcode.com/2011/04/06/taking-baby-steps-with-node-js-pumping-data-between-streams/ 및 스트림을 이해하는 데 약간의 문제가 있습니다.nodejs 스트림과 콜백
견적 :
"Suppose we want to develop a simple web application that reads a particular file from disk and send it to the browser. The following code shows a very simple and naïve implementation in order to make this happen."
그래서 코드 샘플은 다음과 같다 :
var readStream = fileSystem.createReadStream(filePath);
readStream.on('data', function(data) {
response.write(data);
});
readStream.on('end', function() {
response.end();
});
을 우리는 위의 방법 것을 사용하는 것이 왜 우리는 간단하게 할 수있는 경우 :
fs.readFile(filePath, function(err, data){
response.write(data);
response.end();
});
스트림을 사용해야하는시기 또는 이유는 무엇입니까?