Stream이란?

Namlulu·2021년 12월 1일
0

CS

목록 보기
2/2
코드를 입력하세요
import { open } from 'fs/promises';

const fd = await open('/dev/input/event0');
// Create a stream from some character device.
const stream = fd.createReadStream();
setTimeout(() => {
  stream.close(); // This may not close the stream.
  // Artificially marking end-of-stream, as if the underlying resource had
  // indicated end-of-file by itself, allows the stream to close.
  // This does not cancel pending read operations, and if there is such an
  // operation, the process may still not be able to exit successfully
  // until it finishes.
  stream.push(null);
  stream.read(0);
}, 100);

=> 스트림은 하나의 리소스를 작게 조각내여 처리하는 것을 의미한다. 보통 영상이나 엄청 큰 파일을 전송할 때, 한 번에 툭 던지는 것이 불가능하기 때문에 조각 Chunk 사이즈를 정의하고 통신하거나 처리하게 된다.

profile
Better then yesterday

0개의 댓글