Socket
Socket
Sign inDemoInstall

blob-stream

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blob-stream

A Node-style writable stream for HTML5 Blobs


Version published
Weekly downloads
92K
decreased by-20.18%
Maintainers
1
Weekly downloads
 
Created

What is blob-stream?

The blob-stream npm package is used to create a writable stream that generates a Blob. This is particularly useful for generating files in the browser, such as PDFs, images, or any other binary data that can be represented as a Blob.

What are blob-stream's main functionalities?

Creating a Blob from a Stream

This feature allows you to create a Blob from a writable stream. In this example, a PDF document is created using the pdfkit library, and its output is piped to a blob-stream. Once the stream is finished, you can get the Blob and use it as needed, such as creating a URL for download.

const blobStream = require('blob-stream');
const PDFDocument = require('pdfkit');

// Create a document
const doc = new PDFDocument();

// Pipe its output somewhere, like to a blob
const stream = doc.pipe(blobStream());

// Add some content to the document
doc.text('Hello, world!');

// Finalize the PDF and end the stream
doc.end();

// When the stream is finished, get the blob
stream.on('finish', function() {
  // get a blob you can do whatever you like with
  const blob = stream.toBlob('application/pdf');
  const url = stream.toBlobURL('application/pdf');
  console.log(url);
});

Other packages similar to blob-stream

FAQs

Package last updated on 24 Nov 2014

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