npm.io
0.2.0 • Published 4 years ago

reverse-read-line

Licence
ISC
Version
0.2.0
Deps
0
Size
12 kB
Vulns
0
Weekly
0
Stars
3

Build Status Coverage Status

reverse-read-line

Read text file line by line from end.

install

npm install reverse-read-line

Usage

import * as rrl from 'reverse-read-line';

const reader = rrl.create(filename, options); 
const lines = await reader.readLines(2);
await reader.close();
console.log(lines);

stream:

import * as rrl from 'reverse-read-line';

const stream = rrl.createStream(filename, options); 
stream.on('data', (line) => {
  console.log(line);
});

read lines:

import * as rrl from 'reverse-read-line';

const lines = await rrl.readLines(filename, 5, options); 
console.log(lines);

Options:

name type default description
encoding string 'utf8' the file encoding
bufferSize number 4096 the size will be read once
separator string undefined line separator. if undefined it will auto judging

Keywords