Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Maintainers
1
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc