Giter VIP home page Giter VIP logo

linereader's Introduction

LineReader

Reads files line by line using the HTML5 File API.

Usage

After the user has selected a file:

// Grab a file reference
var file = document.getElementById('my-file-input').files[0];

// Create a new instance of the LineReader
var lr = new LineReader();

// Bind to the line event
lr.on('line', function (line, next) {
  // Do something with line....

  next(); // Call next to resume...
});

// Begin reading the file
lr.read(file);

LineReader( [options] )

The LineReader constructor. You can pass in options here.

Available Options

chunkSize: How much data to read at a time. Defaults to 1024

Example

var myLineReader = new LineReader({
  chunkSize: 500
});

LineReader.on( eventName, callback )

Binds events.

line (line, next): Triggered every time a line is read. A line string and a next function are passed in as arguments. To read the next line, next must be called.

error (errorObj): Triggered when an error occurs while reading a file. A DOMError is passed to the callback.

end: Triggered when the file has been read completely, or when the LineReader#abort method has been called.

LineReader.read( file )

Starts the read process on the passed in file reference.

LineReader.abort()

Aborts the read process and prevents lines from being emitted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.