Skip to content

Latest commit

 

History

History
56 lines (36 loc) · 1.49 KB

File metadata and controls

56 lines (36 loc) · 1.49 KB
title short-title slug page-type browser-compat
ReadableStreamBYOBReader: ReadableStreamBYOBReader() constructor
ReadableStreamBYOBReader()
Web/API/ReadableStreamBYOBReader/ReadableStreamBYOBReader
web-api-constructor
api.ReadableStreamBYOBReader.ReadableStreamBYOBReader

{{APIRef("Streams")}}{{AvailableInWorkers}}

The ReadableStreamBYOBReader() constructor creates and returns a ReadableStreamBYOBReader object instance.

Note: You generally wouldn't use this constructor manually; instead, you'd use the {{domxref("ReadableStream.getReader()")}} method with the argument "byob".

Syntax

new ReadableStreamBYOBReader(stream)

Parameters

  • stream
    • : The {{domxref("ReadableStream")}} to be read.

Return value

An instance of the {{domxref("ReadableStreamBYOBReader")}} object.

Exceptions

  • {{jsxref("TypeError")}}
    • : Thrown if the supplied stream parameter is not a {{domxref("ReadableStream")}}, or it is already locked for reading by another reader, or its stream controller is not a {{domxref("ReadableByteStreamController")}}.

Examples

The constructor is rarely called directly. Instead call {{domxref("ReadableStream.getReader()")}} as shown:

const reader = stream.getReader({ mode: "byob" });

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also