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

Add support for top-level-for-await #3212

Merged
merged 3 commits into from Oct 27, 2019

Conversation

@hayd
Copy link
Contributor

hayd commented Oct 27, 2019

Looks like top-level for-await already works with js. This PR allows it in typescript files too.

Unfortunately prettier/babel doesn't accept it (eslint does). So the js test file is ignored... Confusingly the ts file doesn't suffer with the same issue.
I'm not sure a good resolution going forward but am putting the PR up anyways.

cc #471

Copy link
Collaborator

ry left a comment

Lovely ! I believe there are a couple of examples in the manual that could benefit from this feature. Would you mind editing those too?

hayd added 2 commits Oct 27, 2019
@hayd

This comment has been minimized.

Copy link
Contributor Author

hayd commented Oct 27, 2019

Ok, I added in a few places I saw it. Assuming this should be preferred over window.onload...

I also discovered the ws README example code was broken, so I ported it over from the examples. Although it may be better just to delete it (and point to those examples).


_048_media_types_jsx failed in the first commit, presumably it's this:

deno/cli/test_util.rs

Lines 71 to 72 in 51dd91a

// Wait 1 second for the server to come up. TODO(ry) this is Racy.
std::thread::sleep(std::time::Duration::from_secs(2));
.

(This particularly test requires the http_server to be up at compile time.)

const body = new TextEncoder().encode("Hello World\n");
for await (const req of serve(":8000")) {
req.respond({ body });
}

This comment has been minimized.

Copy link
@ry

ry Oct 27, 2019

Collaborator

sexy

@ry
ry approved these changes Oct 27, 2019
Copy link
Collaborator

ry left a comment

LGTM

@ry ry merged commit aec5a64 into denoland:master Oct 27, 2019
10 checks passed
10 checks passed
test macOS-10.14
Details
test_std macOS-10.14
Details
test windows-2019
Details
test_std windows-2019
Details
test ubuntu-16.04
Details
test_debug ubuntu-16.04
Details
test_std ubuntu-16.04
Details
bench ubuntu-16.04
Details
lint ubuntu-16.04
Details
license/cla Contributor License Agreement is signed.
Details
@bartlomieju bartlomieju deleted the hayd:top-level-for-await branch Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.