1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-15 08:07:38 +00:00

LibWeb: Implement FileAPI::Blob::stream()

This commit is contained in:
Shannon Booth 2023-06-13 07:36:00 +12:00 committed by Andreas Kling
parent 9f39be6e23
commit bd26d022ac
3 changed files with 9 additions and 0 deletions

View file

@ -252,6 +252,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> Blob::slice(Optional<i64> start, Opt
return MUST_OR_THROW_OOM(heap().allocate<Blob>(realm(), realm(), move(byte_buffer), move(relative_content_type))); return MUST_OR_THROW_OOM(heap().allocate<Blob>(realm(), realm(), move(byte_buffer), move(relative_content_type)));
} }
// https://w3c.github.io/FileAPI/#dom-blob-stream
WebIDL::ExceptionOr<JS::NonnullGCPtr<Streams::ReadableStream>> Blob::stream()
{
// The stream() method, when invoked, must return the result of calling get stream on this.
return this->get_stream();
}
// https://w3c.github.io/FileAPI/#blob-get-stream // https://w3c.github.io/FileAPI/#blob-get-stream
WebIDL::ExceptionOr<JS::NonnullGCPtr<Streams::ReadableStream>> Blob::get_stream() WebIDL::ExceptionOr<JS::NonnullGCPtr<Streams::ReadableStream>> Blob::get_stream()
{ {

View file

@ -43,6 +43,7 @@ public:
WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> slice(Optional<i64> start = {}, Optional<i64> end = {}, Optional<String> const& content_type = {}); WebIDL::ExceptionOr<JS::NonnullGCPtr<Blob>> slice(Optional<i64> start = {}, Optional<i64> end = {}, Optional<String> const& content_type = {});
WebIDL::ExceptionOr<JS::NonnullGCPtr<Streams::ReadableStream>> stream();
WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> text(); WebIDL::ExceptionOr<JS::NonnullGCPtr<JS::Promise>> text();
JS::Promise* array_buffer(); JS::Promise* array_buffer();

View file

@ -9,6 +9,7 @@ interface Blob {
Blob slice(optional long long start, optional long long end, optional DOMString contentType); Blob slice(optional long long start, optional long long end, optional DOMString contentType);
// read from the Blob. // read from the Blob.
[NewObject] ReadableStream stream();
[NewObject] Promise<USVString> text(); [NewObject] Promise<USVString> text();
[NewObject] Promise<ArrayBuffer> arrayBuffer(); [NewObject] Promise<ArrayBuffer> arrayBuffer();
}; };