Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
blob-stream
Advanced tools
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.
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);
});
The blob-util package provides utilities for working with Blob objects, including creating Blobs from various data types, converting Blobs to other formats, and more. It offers more general-purpose utilities compared to blob-stream, which is specifically focused on creating Blobs from streams.
The stream-to-blob package is a simple utility that converts a readable stream into a Blob. It is similar to blob-stream but is more lightweight and focused solely on the conversion process without additional features.
The blob-polyfill package provides a polyfill for the Blob constructor, making it possible to use Blob-related functionality in environments where it is not natively supported. While it does not directly compete with blob-stream, it can be used in conjunction to ensure broader compatibility.
A Node-style writable stream for HTML5 Blobs, mostly useful in Browserify. Allows you to take the output of any Node stream, and turn it into a Blob or Blob URL for opening in the browser, uploading to a server, etc.
If you don't want to use Browserify, you can also download a prebuilt version of the library.
var blobStream = require('blob-stream');
someStream
.pipe(blobStream())
.on('finish', function() {
// get a blob
var blob = this.toBlob();
// or get a blob URL
var url = this.toBlobURL();
window.open(url);
});
MIT
FAQs
A Node-style writable stream for HTML5 Blobs
The npm package blob-stream receives a total of 69,943 weekly downloads. As such, blob-stream popularity was classified as popular.
We found that blob-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.