Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clayrisser/binary-fetch
Fetch binary data with incremental progress from a browser
https://github.com/clayrisser/binary-fetch
binary fetch incremental progress request response xhr xmlhttprequest
Last synced: 2 months ago
JSON representation
Fetch binary data with incremental progress from a browser
- Host: GitHub
- URL: https://github.com/clayrisser/binary-fetch
- Owner: clayrisser
- License: mit
- Created: 2017-03-26T20:01:28.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2023-07-11T12:28:56.000Z (over 1 year ago)
- Last Synced: 2024-10-09T22:57:10.071Z (3 months ago)
- Topics: binary, fetch, incremental, progress, request, response, xhr, xmlhttprequest
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/binary-fetch
- Size: 1.01 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# binary-fetch _Beta_
Fetch incremental binary packets from a browser![](assets/binary-fetch.png)
Currently, the only way to access the progress from a request or upload in a browser is with the [XMLHttpRequest API](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest). 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](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).
```bash
npm install --save binary-fetch
``````js
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 :beers:![![Beerpay](https://beerpay.io/jamrizzi/binary-fetch/badge.svg?style=beer-square)](https://beerpay.io/jamrizzi/binary-fetch) [![Beerpay](https://beerpay.io/jamrizzi/binary-fetch/make-wish.svg?style=flat-square)](https://beerpay.io/jamrizzi/binary-fetch?focus=wish)