@remix-run/web-blob
Web API compatible Blob implementation
Last updated a year ago by mjackson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @remix-run/web-blob 
SYNC missed versions from official npm registry.

@remix-run/web-blob

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 using nodejs native Readable stream. We found this to be problematic when sharing code across nodejs and browser runtimes. Instead this library stays true to the specification by using ReadableStream implementation from @remix-run/web-stream library even if that is less convenient in nodejs context.

Note: Both node Readable streams and web ReadableStream implement AsyncIterable interface and in theory either could be used with for await loops. In practice however major browsers do not yet ship AsyncIterable support for ReadableStreams which 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 "@remix-run/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 definitions along with typed definition maps. So you should be able to get all the type inference out of the box.

Install

npm install @remix-run/web-blob

Current Tags

  • 3.1.0                                ...           latest (a year ago)
  • 3.1.0-pre.0                                ...           pre (a year ago)

4 Versions

  • 3.1.0                                ...           a year ago
  • 3.1.0-pre.0                                ...           a year ago
  • 3.0.5                                ...           a year ago
  • 3.0.4                                ...           3 years ago
Downloads
Total 1
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (12)

© 2010 - cnpmjs.org x YWFE | Home | YWFE