Skip to content

BorisChumichev/node-nthline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-nthline Build Status Coverage Status

nthline reads specific line from file without buffering the entire file to memory. Under the hood it uses Node’s readline module.

Install

npm i -S nthline

Usage

Module exposes a function with signature: (rowIndex:Number, filePath:String) → Promise<String>. Row indexing is zero-based.

const nthline = require('nthline'),
  filePath = '/path/to/100-million-rows-file',
  rowIndex = 42

console.log(await nthline(rowIndex, filePath))

Since it returns a promise you could rewrite previous example like that:

const nthline = require('nthline'),
  filePath = '/path/to/100-million-rows-file',
  rowIndex = 42

nthline(rowIndex, filePath).then(console.log)

About

Read nth line without reading entire file

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published