Skip to content

Support Blob #140

@coyotte508

Description

@coyotte508

hyparquet has an AsyncBuffer type, but it would be great if it could support Blob out of the box:

  • Blob have a .slice() function that return Promise<Blob>
  • They also have a .arrayBuffer() that returns Promise<ArrayBuffer>
  • They have a .stream() function that return a web stream

It's an interoperable types, returned by the browser when handling user files, or by BunFile from bun, etc (our specifc usecase is for the downloadFile of @huggingface/hub which also implements Blob subclasses like WebBlob, FileBlob, ...)

A wrapper could look like this:

function blobToAsyncBuffer(blob: Blob) {
	return {
		byteLength: blob.size,
		slice(start, end) => blob.slice(star,end).then(blob => blob.arrayBuffer())
	}
}

but the lib handling blob.stream() natively would be nice as well, avoiding making several range request on a fetch for example, and reading the data as it comes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions