Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move web streams to dcore #1023

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function iteratorToStream(iterator) {
return new ReadableStream({
async pull(controller) {
const { value, done } = await iterator.next();

if (value) {
controller.enqueue(value);
}
if (done) {
controller.close();
}
},
});
}

const iterator = (async function* () {
yield "Hello";
yield "world";
})();

const stream = iteratorToStream(iterator);

const reader = stream.getReader();

while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
console.log(value);
}
2 changes: 2 additions & 0 deletions testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ path = "./lib.rs"

[dependencies]
anyhow.workspace = true
bytes.workspace = true
deno_ast.workspace = true
deno_core.workspace = true
deno_core.features = ["unsafe_use_unprotected_platform", "snapshot_flags_eager_parse"]
futures.workspace = true
thiserror.workspace = true
tokio.workspace = true
url.workspace = true

Expand Down
11 changes: 11 additions & 0 deletions testing/checkin/runner/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::checkin::runner::ops_buffer;
use crate::checkin::runner::ops_error;
use crate::checkin::runner::ops_io;
use crate::checkin::runner::ops_worker;
use crate::checkin::runner::streams;
use crate::checkin::runner::Output;
use crate::checkin::runner::TestData;

Expand Down Expand Up @@ -49,6 +50,14 @@ deno_core::extension!(
ops_worker::op_worker_parent,
ops_worker::op_worker_await_close,
ops_worker::op_worker_terminate,
streams::op_readable_stream_resource_allocate,
streams::op_readable_stream_resource_allocate_sized,
streams::op_readable_stream_resource_get_sink,
streams::op_readable_stream_resource_write_error,
streams::op_readable_stream_resource_write_buf,
streams::op_readable_stream_resource_write_sync,
streams::op_readable_stream_resource_close,
streams::op_readable_stream_resource_await_close,
],
objects = [
ops::DOMPoint,
Expand All @@ -61,8 +70,10 @@ deno_core::extension!(
"checkin:async" = "async.ts",
"checkin:console" = "console.ts",
"checkin:object" = "object.ts",
"checkin:streams" = "streams.ts",
"checkin:error" = "error.ts",
"checkin:timers" = "timers.ts",
"checkin:webidl" = "webidl.ts",
"checkin:worker" = "worker.ts",
"checkin:throw" = "throw.ts",
],
Expand Down
1 change: 1 addition & 0 deletions testing/checkin/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ mod ops_error;
mod ops_io;
mod ops_worker;
pub mod snapshot;
mod streams;
#[cfg(test)]
pub mod testing;
mod ts_module_loader;
Expand Down
Loading
Loading