Skip to content

This class allows you to get lines (a range) from very BIG FILES very fast

License

Notifications You must be signed in to change notification settings

mzalazar/file-indexer

Repository files navigation

file-indexer

This class allows you to get lines (a range) from very BIG FILES very fast

The class contains an useful function

getLines(filename, fromLine, toLine)

Usage

const indexer = require('./indexer')
const i = new indexer()

// Get lines deep inside file, from line 5000000 to line 5000010
let lines = i.getLines('/home/mzalazar/big_file.txt', 5000000, 5000010) // ultra-fast (once indexed)

Index file

  • Files are indexed using 64bits numbers stored in a file called filename.ext.index (as newline offsets)
  • Files are indexed automatically when *getLines() is called, or by calling makeIndex(filename)
  • Files/indexes are kept open and their handlers are saved (acting like a cache, for fast access)

This class is experimental, do whatever you need to improve it or use it as it is!

About

This class allows you to get lines (a range) from very BIG FILES very fast

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published