Closed dckc closed 1 year ago
BufferReader
takes an ArrayBuffer
which can be obtained from a Blob
. I'm not sure where node Buffer
comes in.
Btw, the type looks wrong on ZipReader
, it likely takes an ArrayBuffer
, not an UInt8Array
...
Edit: according to the spec, the typed array constructors takes either, so I guess we're fine. The documented types however are inconsistent.
Interoperating with other zip implementations is a win I’ll take. But, @endo/zip
uses Uint8Array
as the coin of its realm.
These steps should be sufficient to bridge:
const buffer = await blob.arrayBuffer();
const bytes = new Uint8Array(buffer);
const zip = new ZipReader(bytes);
step 2 seem to only be necessary to satisfy types.
... I'm not sure where node
Buffer
comes in.
oops! Looks like I was just reading too fast.
Describe the bug
I recently prototyped a browser-based bundle explorer tool:
I tried to use
@endo/zip
but the endoZipReader()
constructor depends on theBufferReader
implementation:I don't see a way to slot in a
BlobReader
.I suppose I could have used a
Buffer
shim for the browser, but I had the data in aBlob
. It turned out to be easier to use zip-loader.cc @kriskowal