🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

screw-filereader

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

screw-filereader

For those lazzy bastard who don't like the FileReader

latest
Source
npmnpm
Version
1.4.3
Version published
Weekly downloads
34
61.9%
Maintainers
1
Weekly downloads
 
Created
Source

Screw-FileReader

For those lazzy bastard who don't like the FileReader :)

npm version

npm install screw-filereader

A promisified Blob reader was proposed. But not as a external API like FileReader... Nooo - this is prototyped to blob directly!

This makes it easier to read stuff from Blob's and File's

Here is an example

// require('screw-filereader')
// import screw-filereader

arrayBuffer = await blob.arrayBuffer() // awaits a promise
text = await blob.text() // awaits a promise
dataUrl = await blob.dataUrl() // awaits a promise
stream = blob.stream() // returns a web ReadableStream

// BinaryString has been avoided
// - Binaries just don't work well with strings face it.
//   Send the blob with ajax instead or use ArrayBuffer if you want to work with the data
//
// Until someone gives me a good reason why I should add them


// Just bonuses
// ------------
json = await blob.json() // awaits a promise (rejects if fail to parse)
img = await blob.image([preventRevoke=false]) // awaits a new Image object (rejects if fail to load)

// returns a blob url (same as [webkit]URL.createObjectURL(blob))
// can also return null if it's not possible like on chrome for iOS...
url = blob.url() || await blob.dataUrl() // this is what blob.image() dose behind the scene...

blob.image() will read the Exif rotation in jpeg images and rotate it accordingly

If streams are enhanced with web-streams-polyfill then you get all the benefits of pipes as well :v:
Otherwise only a ReadableStream without pipe will be returned (but only in Blink)

Keywords

Promise

FAQs

Package last updated on 23 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts