Complete the code to create a ReadableStream that outputs the string 'Hello'.
const stream = new ReadableStream({
start(controller) {
controller.[1]('Hello');
controller.close();
}
});The enqueue method adds chunks to the stream's internal queue.
Complete the code to create a WritableStream that logs each chunk it receives.
const writable = new WritableStream({
write(chunk) {
console.[1](chunk);
}
});The console.log method outputs messages to the console, suitable for logging chunks.
Fix the error in the code to pipe a ReadableStream to a WritableStream.
await readable.[1](writable);The pipeTo method connects a ReadableStream to a WritableStream, forwarding data.
Fill both blanks to create a ReadableStream that outputs numbers 1 to 3 and then closes.
const stream = new ReadableStream({
start(controller) {
for(let i = 1; i <= 3; i++) {
controller.[1](i);
}
controller.[2]();
}
});enqueue adds chunks to the stream, and close signals the end of the stream.
Fill all three blanks to create a WritableStream that converts chunks to uppercase and logs them.
const writable = new WritableStream({
write([1]) {
const upper = [2].toUpperCase();
console.[3](upper);
}
});The parameter is named chunk, which is converted to uppercase and logged with console.log.
