JavaScript CSS HTML
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
lib
src
tasks
.editorconfig
.eslintrc
.gitignore
.npmignore
LICENSE
README.md
bower.json
package.json
webpack.config.js
yarn.lock

README.md

binary-fetch Beta

Fetch incremental binary packets from a browser

Currently, the only way to access the progress from a request or upload in a browser is with the XMLHttpRequest API. However, the the progress data from the XMLHttpRequest API does not give you access to the actual binary data that has been recieved.

Binary fetch solves this problem by giving you immediate access to the binary data while it is being recieved.

Binary fetch is loosely based on the JavaScript fetch API.

npm install --save binary-fetch
import binaryFetch from 'binary-fetch';

binaryFetch('http://example.com/file.binary', {
  method: 'GET'
}, (res) => { // fires 1 or more times during request
  return res.arrayBuffer().then((body) => {
    console.log('binary data recieved so far =>');
    console.log(body);
  });
}).then((res) => { // fires when request is finished
  return res.arrayBuffer().then((body) => {
    console.log('all binary data recieved =>');
    console.log(body);
  });
});

Support on Beerpay

Hey dude! Help me out for a couple of 🍻!

Beerpay Beerpay