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
Merged

Conversation

hayd
Copy link
Contributor

@hayd 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
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
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 });
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sexy

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ry ry merged commit aec5a64 into denoland:master Oct 27, 2019
@bartlomieju bartlomieju deleted the top-level-for-await branch October 27, 2019 13:23
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 21, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants