Skip to content

nnsay/node-rl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 

Repository files navigation

1. 自述

按行读取大文件, nodejs工具包.

2. 原理

利用stream.Readable读取按照一定大小chunk读取大文件, 读取后检查换行符, 一行一行的发送数据给调用者.

3. 使用

const path = './test/data.csv';
const options = {
  encoding: 'utf8',
  highWaterMark: 1024
}
const ReadLine = require('../');
const rl = new ReadLine(path, options);
const assert = require('assert');
let i = 0;

rl.on('row', function (row) {
  console.log(++i, row);
});
rl.on('end', function () {
  assert.equal(i, 5, 'failure');
});

About

read large file by rows

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published