[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/API/ReadableStream/ReadableStream [Back]  [Original]

ReadableStream: ReadableStream() - Web API | MDN

MDN Web Docs

View in English Always switch to English

ReadableStream: ReadableStream()

Baseline

20201

ReadableStream()

underlyingSource

js
new ReadableStream()
new ReadableStream(underlyingSource)
new ReadableStream(underlyingSource, queuingStrategy)

underlyingSource

underlyingSource

start (controller)

controller ReadableStreamDefaultController ReadableByteStreamController type

pull (controller)

pull() controller ReadableStreamDefaultController ReadableByteStreamController type start() BYOB

cancel (reason)

ReadableStream.cancel() reason

type

"bytes" BYOB / ReadableByteStreamController ReadableStreamDefaultController

autoAllocateChunkSize

autoAllocateChunkSize ReadableByteStreamController.byobRequest

ReadableStreamDefaultReader ReadableByteStreamController.byobRequest null

queuingStrategy

2

highWaterMark

size(chunk)

chunk

: queuingStrategy ByteLengthQueuingStrategy CountQueuingStrategy queuingStrategy 1 CountQueuingStrategy

ReadableStream

RangeError

type "bytes" undefined

ReadableStream start() 1 ReadableStream.cancel() cancel()

ReadableStreamDefaultController.close()

js
const stream = new ReadableStream({
  start(controller) {
    interval = setInterval(() => {
      let string = randomChars();

      // 
      controller.enqueue(string);

      // 
      let listItem = document.createElement("li");
      listItem.textContent = string;
      list1.appendChild(listItem);
    }, 1000);

    button.addEventListener("click", () => {
      clearInterval(interval);
      fetchStream();
      controller.close();
    });
  },
  pull(controller) {
    //  pull 
  },
  cancel() {
    // 
    // 
    clearInterval(interval);
  },
});

Streams
# ref-for-rs-constructor


Web Proxy Viewer  |  New URL  |  Original Page