Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web-blob

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-blob

Web API compatible Blob implementation

  • 2.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.2K
increased by39.74%
Maintainers
1
Weekly downloads
 
Created
Source

web-blob

Node.js CI package downloads styled with prettier

Web API compatible Blob for nodejs.

Comparison to Alternatives

fetch-blob

The reason this library exists is because fetch-blob chooses to compromise Web API compatibility of blob.stream() by useing nodejs native Readable stream. We found this to be problematic when sharing code across nodejs and browser rutimes. Instead this library stays true to the specification by using ReadableStream implementation from web-streams-polyfill library even if that is less convinient in nodejs context.

Note: Both node Readable streams and web ReadableStream implement AsyncIterable intreface and in theory either could be used with for await loops. In practice however major browsers do not yet ship AsyncIterable support for ReadableStreams wich in our experience makes choice made by node-fetch impractical.

fetch-blob is build around node Buffers. This implementation is built around standard Uint8Arrays.

fetch-blob chooses to use WeakMaps for encapsulating private state. This library chooses to use to use properties with names that start with _. While those properties aren't truly private they do have better performance profile and make it possible to interop with this library, which we found impossible to do with node-fetch.

Usage

import { Blob } from "web-blob"
const blob = new Blob(["hello", new TextEncoder().encode("world")])
for await (const chunk of blob.stream()) {
  console.log(chunk)
}

Usage from Typescript

This library makes use of typescript using JSDOC annotations and also generates type difinitions along with typed definition maps. So you should be able to get all the type innference out of the box.

Install

npm install web-blob

Keywords

FAQs

Package last updated on 22 Jul 2020

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