📜  从大型文本文件创建读取流 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:38.438000             🧑  作者: Mango

代码示例1
import { createReadStream, ReadStream } from 'fs';

var readStream: ReadStream = createReadStream('./data.txt');

readStream.on('data', chunk => {
  console.log('---------------------------------');
  console.log(chunk);
  console.log('---------------------------------');
});

readStream.on('open', () => {
  console.log('Stream opened...');
});

readStream.on('end', () => {
  console.log('Stream Closed...');
});