JavaScripture
Contribute via GitHub
Feedback
ReadableStreamDefaultController
Instance Properties
desiredSize
Instance Methods
close
enqueue
error
Streams API
All API
No API set selected.
ReadableStreamDefaultController
:
ReadableStreamController
Controls a
ReadableStream's
state and queue.
Spec
Instance Properties
desiredSize
:
Number
readonly
Instance Methods
close
() :
undefined
Causes the owning stream to close.
Example:
// Create a stream of strings. const stringStream = new ReadableStream({ start(controller) { controller.enqueue('a'); controller.enqueue('b'); controller.close(); } }); const reader = stringStream.getReader(); let result; while (!(result = await reader.read()).done) { console.log(result.value); } console.log('done');
Run
Results:
enqueue
(
chunk
:
Object
) :
undefined
Causes the owning stream to return
chunk
.
Example:
// Create a stream of strings. const stringStream = new ReadableStream({ start(controller) { ['a', 'b', 'c'].forEach(s => controller.enqueue(s)); controller.close(); } }); const reader = stringStream.getReader(); let result; while (!(result = await reader.read()).done) { console.log(result.value); }
Run
Results:
Spec
error
(
reason
:
Object
) :
undefined
home
license
contribute
feedback
toggle light/dark mode
Copyright © JavaScripture Contributors