buffered-file-line-reader-sync

    0.1.0 • Public • Published

    Synchroneous, Buffered, Line by Line File Reader

    Simple library to read a file line by line, without loading the full file in memory. Ideal to read massive files.

    Usage:

    var BufferedFileLineReaderSync = require('buffered-file-line-reader-sync');
     
    var line;
    var filename = 'path/to/big/file';
     
    var options = {
        encoding: 'utf8',
        bufferSize: 8192
    }
     
    bufferedReader = new BufferedFileLineReaderSync(filename, options);
     
    while (bufferedReader.hasNextLine()) {
        console.log(bufferedReader.nextLine());
    }

    API:

    Class: BufferedFileLineReaderSync(path [, options])

    • path: path to the file to read
    • options: object with the following parameters:
      • string encoding (defaults to 'utf8'): any encoding supported by Buffer.toString method of the Buffer node base class.
      • int bufferSize (defaults to 8192): size in octets (bytes) of the underlying buffer used.

    nextLine()

    Reads the next line in the file. Returns null if done reading.

    hasNextLine()

    Returns a boolean value to indicate if all lines have been read.

    Install

    npm i buffered-file-line-reader-sync

    DownloadsWeekly Downloads

    9

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • dtrack