forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: top-level-for-await (denoland#3212)
- Loading branch information
Showing
18 changed files
with
257 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
cli/tests/error_syntax.js | ||
cli/tests/badly_formatted.js | ||
cli/tests/top_level_for_await.js | ||
std/**/testdata | ||
std/**/vendor | ||
std/node_modules | ||
std/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. | ||
async function main(): Promise<void> { | ||
const res = await fetch("https://localhost:4545/std/examples/colors.ts"); | ||
console.log(`Response http: ${await res.text()}`); | ||
} | ||
|
||
main(); | ||
const res = await fetch("https://localhost:4545/std/examples/colors.ts"); | ||
console.log(`Response http: ${await res.text()}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
async function* asyncGenerator() { | ||
let i = 0; | ||
while (i < 3) { | ||
yield i++; | ||
} | ||
} | ||
|
||
for await (const num of asyncGenerator()) { | ||
console.log(num); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
0 | ||
1 | ||
2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
async function* asyncGenerator(): AsyncIterableIterator<number> { | ||
let i = 0; | ||
while (i < 3) { | ||
yield i++; | ||
} | ||
} | ||
|
||
for await (const num of asyncGenerator()) { | ||
console.log(num); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. | ||
async function cat(filenames: string[]): Promise<void> { | ||
for (const filename of filenames) { | ||
const file = await Deno.open(filename); | ||
await Deno.copy(Deno.stdout, file); | ||
file.close(); | ||
} | ||
const filenames = Deno.args.slice(1); | ||
for (const filename of filenames) { | ||
const file = await Deno.open(filename); | ||
await Deno.copy(Deno.stdout, file); | ||
file.close(); | ||
} | ||
|
||
cat(Deno.args.slice(1)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. | ||
async function curl(url: string): Promise<void> { | ||
const res = await fetch(url); | ||
await Deno.copy(Deno.stdout, res.body); | ||
} | ||
|
||
await curl(Deno.args[1]); | ||
Deno.exit(0); | ||
const url = Deno.args[1]; | ||
const res = await fetch(url); | ||
await Deno.copy(Deno.stdout, res.body); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.