blob: b1273683188f9f22e67669b837de644f2f044488 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
"use strict";
var log = [];
const stream = new ReadableStream({
start(controller) {
log.push("started");
},
pull(controller) {
log.push("pulled");
controller.enqueue("hi from pull");
},
cancel() {
log.push("cancelled");
},
});
print(log); // Currently prints "started"!
add_task(async function helper() {
var reader = stream.getReader();
var readPromise = reader.read();
readPromise.then(x => print(`Printing promise result ${x}, log ${log}`));
print(log);
var x = await readPromise;
print(`Promise result ${x} ${x.value}`);
Assert.equal(x.value, "hi from pull");
Assert.ok(true);
});
|