🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

blob2web-stream

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blob2web-stream

Create a stream from blobs

1.0.1
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

blob2web-stream

Read W3C Blob & File objects as a Web stream.

Getting started

Load it however you want

require('blob2web-stream')
import from 'blob2web-stream'
<script src="https://wzrd.in/standalone/blob2web-stream@1.0.0"></script>
<script src="https://cdn.rawgit.com/jimmywarting/blob2web-stream/master/blob2web-stream"></script>

EXAMPLE

<script src="https://wzrd.in/standalone/blob2web-stream@1.0.0"></script>
<script src="https://wzrd.in/standalone/web-streams-polyfill@1.1.1"
	integrity="sha384-8EYry4yokV53rGHMFtPqeVlAPgxn8yxr/RvxC4bZt3vlneaDPzWkSJCvBDBTuXAV"
	crossorigin
></script>
<script>
    var myFile = new File(['parts'], 'filename.txt')
    var stream = myFile._createReadableByteStream()

    // You can do this
    stream.pipeTo(destination)
    // or this
    stream
        .pipeThrough(decompressorTransform)
        .pipeThrough(ignoreNonImageFilesTransform)
        .pipeTo(mediaGallery);

    // Or more manual work...

    // Web streams need a consumer to read the data unlike node-streams where
    // you get data from a data-event. Web streams it's also all promisifed.
    var reader = readableStream.getReader()
    var chunks = []

    var pump() =>
        reader.read().then( ({ value, done }) => {
            if (done)
                return chunks

            chunks.push(value) // Uint8array
            return pump()
        })


    pump().then(chunks => {
        console.log('done reading the hole file')
        console.log(chunks)
    })
</script>

FAQs

Package last updated on 22 Jun 2016

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