GithubHelp home page GithubHelp logo

hvoecking / filereader-stream Goto Github PK

View Code? Open in Web Editor NEW

This project forked from max-mapper/filereader-stream

0.0 2.0 0.0 216 KB

Read an HTML5 File object (from e.g. HTML5 drag and drops) as a stream.

License: BSD 2-Clause "Simplified" License

HTML 14.64% JavaScript 85.36%

filereader-stream's Introduction

filereader-stream

Given an HTML5 File object (from e.g. HTML5 drag and drops), turn it into a readable stream.

install

Use it with npm & browserify

$ npm install filereader-stream

example

var drop = require('drag-and-drop-files')
var concat = require('concat-stream')
var fileReaderStream = require('filereader-stream')

test('should read file when one is dropped', function(t) {
  drop(document.body, function(files) {
    var first = files[0]
    fileReaderStream(first).pipe(concat(function(contents) {
      // contents is the contents of the entire file
    }))
  })
})

usage

var fileReaderStream = require('filereader-stream')
var readStream = fileReaderStream(file, [options])

fileReaderStream is a Streams 2 Readable Stream, so you can do all the streamy things with it like .pipe etc.

options:

  • chunkSize - default 1024 * 1024 (1MB) - How many bytes will be read at a time
  • offset - default 0 - Where in the file to start reading

run the tests

npm install
npm test

then open your browser to the address provided, open your JS console, and drag and drop files onto the page until the test suite passes/fails

filereader-stream's People

Contributors

1n50mn14 avatar jarofghosts avatar leetreveil avatar max-mapper avatar

Watchers

 avatar  avatar

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.