Big file loader in chunks for browser
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
img
src
.babelrc
.eslintrc
.gitignore
.npmignore
.travis.yml
LICENSE
README.md
package-lock.json
package.json
rollup.config.base.js
rollup.config.cjs.js
rollup.config.es.js
rollup.config.iife.js
rollup.config.iife.min.js

README.md

portfolio_view

Build Status BCH compliance dependencies Status License: MIT

NPM

Big file loader in chunks for browser

Installing

Package is available in npm. It's in cjs,es and iife format so it will work correctly with all popular bundlers(webpack) and also nodejs.

npm install readery --save

Using yarn

yarn add readery --save

For direct usage without bundler, use iife format and import file directly:

<script src="dist/readery.iife.min.js"></script>

API

import {readFromFile} from "readery"

readFromFile(readFromFile(
  file,
  dataCb,
  loadingProgressCb = progress => {},
  finishedCb = () => {},
  config = { splitBy: /\r?\n/, encoding: "UTF-8" },
  chunkSize = 256 * 1024
)

If splitBy is undefined then there is no splitting.

Example usage

<body>
    <input type="file" id="file-input" name="file" />
    <script>
        function handleFileSelect(evt) {
            var file = evt.target.files[0];
           
            readery.readFromFile(file, d => {
                console.log("Chunk = ", d);
                }, 
                p => { console.log("Progress: " + p) }, 
                () => {  console.log("finished") 
            });
        }
        document.getElementById('file-input').addEventListener('change', handleFileSelect, false);
    </script>
</body>

Compatibility

Licensing

The code in this project is licensed under MIT license.