buffered-text-reader

1.0.1 • Public • Published

BufferedReader

A module to read text files in the browser without having to load the whole content into memory.

API

Constructor

Creates an instance of BufferedReader

const bufferedReader = new BufferedReader(file);

Where file is a HTML5 File.

ReadLine

Reads the next available line. This method can be called multiple times til EOL is reached.

const line = await bufferedReader.readLine();

To check if the EOL is reached, you can query it by using isEOL().

while (!bufferedReader.isEOL()) {
  const line = await bufferedReader.readLine();
}

You can, optionally, defines the chunk size to be used when trying to read a line. The default is set to 1024 bytes, but it can be overridden when calling readLine.

const line = await bufferedReader.readLine(2048);
const line = await bufferedReader.readLine(16);

/buffered-text-reader/

    Package Sidebar

    Install

    npm i buffered-text-reader

    Weekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    13.1 kB

    Total Files

    11

    Last publish

    Collaborators

    • maxmaccari
    • brunoocasali