{"action":"created","comment":{"url":"https://api.github.com/repos/google/WebFundamentals/pulls/comments/82389630","pull_request_review_id":3301518,"id":82389630,"diff_hunk":"@@ -0,0 +1,317 @@\n+project_path: /web/_project.yaml\n+book_path: /web/fundamentals/_book.yaml\n+description: Async functions allow you to write promise-based code as if it were synchronous\n+\n+{# wf_published_on: 2016-10-07 #}\n+{# wf_updated_on: 2016-10-07 #}\n+\n+# Async functions - making promises friendly {: .page-title }\n+\n+{% include \"web/_shared/contributors/jakearchibald.html\" %}\n+\n+Async functions are enabled by default in Chrome 55 and they're quite frankly\n+marvelous. They allow you to write promise-based code as if it were synchronous,\n+but without blocking the main thread. They make your asynchronous code less\n+\"clever\" and more readable.\n+\n+Async functions look like this:\n+\n+    async function myFirstAsyncFunction() {\n+      try {\n+        const fulfilledValue = await promise;\n+      }\n+      catch (rejectedValue) {\n+        // …\n+      }\n+    }\n+\n+If you use the `async` keyword before a function definition, you can then use\n+`await` within the function. When you `await` a promise, the function is paused\n+until the promise settles. If the promise fulfills, you get the value back. If\n+the promise rejects, the rejected value is thrown.\n+\n+Note: If you're unfamiliar with promises & promise terminology, check out [our\n+promises guide](/web/fundamentals/getting-started/primers/promises).\n+\n+Calling an async function returns a promise for whatever the function returns or\n+throws. So with:\n+\n+    // wait ms milliseconds\n+    function wait(ms) {\n+      return new Promise(r => setTimeout(r, ms));\n+    }\n+\n+    async function hello() {\n+      await wait(500);","path":"src/content/en/fundamentals/getting-started/primers/async-functions.md","position":45,"original_position":45,"commit_id":"4a8d6f7f0afd855db6258956a57197cfe9b727f0","original_commit_id":"4a8d6f7f0afd855db6258956a57197cfe9b727f0","user":{"login":"ithinkihaveacat","id":51244,"avatar_url":"https://avatars.githubusercontent.com/u/51244?v=3","gravatar_id":"","url":"https://api.github.com/users/ithinkihaveacat","html_url":"https://github.com/ithinkihaveacat","followers_url":"https://api.github.com/users/ithinkihaveacat/followers","following_url":"https://api.github.com/users/ithinkihaveacat/following{/other_user}","gists_url":"https://api.github.com/users/ithinkihaveacat/gists{/gist_id}","starred_url":"https://api.github.com/users/ithinkihaveacat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ithinkihaveacat/subscriptions","organizations_url":"https://api.github.com/users/ithinkihaveacat/orgs","repos_url":"https://api.github.com/users/ithinkihaveacat/repos","events_url":"https://api.github.com/users/ithinkihaveacat/events{/privacy}","received_events_url":"https://api.github.com/users/ithinkihaveacat/received_events","type":"User","site_admin":false},"body":"Might be worth explaining why adding an additional `await wait(500)` will result in this function taking 1s to run, and why something like\r\n\r\n```js\r\nconst p1 = wait(500);\r\nconst p2 = wait(500);\r\nconst v1 = await p1;\r\nconst v2 = await p2;\r\n```\r\n\r\n(which seems more or less equivalent) takes 0.5s.","created_at":"2016-10-07T13:36:28Z","updated_at":"2016-10-07T13:43:10Z","html_url":"https://github.com/google/WebFundamentals/pull/3617#discussion_r82389630","pull_request_url":"https://api.github.com/repos/google/WebFundamentals/pulls/3617","_links":{"self":{"href":"https://api.github.com/repos/google/WebFundamentals/pulls/comments/82389630"},"html":{"href":"https://github.com/google/WebFundamentals/pull/3617#discussion_r82389630"},"pull_request":{"href":"https://api.github.com/repos/google/WebFundamentals/pulls/3617"}}},"pull_request":{"url":"https://api.github.com/repos/google/WebFundamentals/pulls/3617","id":88295926,"html_url":"https://github.com/google/WebFundamentals/pull/3617","diff_url":"https://github.com/google/WebFundamentals/pull/3617.diff","patch_url":"https://github.com/google/WebFundamentals/pull/3617.patch","issue_url":"https://api.github.com/repos/google/WebFundamentals/issues/3617","number":3617,"state":"open","locked":false,"title":"Article: async functions","user":{"login":"jakearchibald","id":93594,"avatar_url":"https://avatars.githubusercontent.com/u/93594?v=3","gravatar_id":"","url":"https://api.github.com/users/jakearchibald","html_url":"https://github.com/jakearchibald","followers_url":"https://api.github.com/users/jakearchibald/followers","following_url":"https://api.github.com/users/jakearchibald/following{/other_user}","gists_url":"https://api.github.com/users/jakearchibald/gists{/gist_id}","starred_url":"https://api.github.com/users/jakearchibald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakearchibald/subscriptions","organizations_url":"https://api.github.com/users/jakearchibald/orgs","repos_url":"https://api.github.com/users/jakearchibald/repos","events_url":"https://api.github.com/users/jakearchibald/events{/privacy}","received_events_url":"https://api.github.com/users/jakearchibald/received_events","type":"User","site_admin":false},"body":"I haven't proof-read this myself, and I don't really have an ending yet, but here it is.","created_at":"2016-10-06T16:24:12Z","updated_at":"2016-10-07T13:43:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a1d0c166532e78cd6256ef7c10e6abd564288ec6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/WebFundamentals/pulls/3617/commits","review_comments_url":"https://api.github.com/repos/google/WebFundamentals/pulls/3617/comments","review_comment_url":"https://api.github.com/repos/google/WebFundamentals/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/WebFundamentals/issues/3617/comments","statuses_url":"https://api.github.com/repos/google/WebFundamentals/statuses/4a8d6f7f0afd855db6258956a57197cfe9b727f0","head":{"label":"google:article-async-functions","ref":"article-async-functions","sha":"4a8d6f7f0afd855db6258956a57197cfe9b727f0","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":19249835,"name":"WebFundamentals","full_name":"google/WebFundamentals","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/WebFundamentals","description":"Best practices for modern web development","fork":false,"url":"https://api.github.com/repos/google/WebFundamentals","forks_url":"https://api.github.com/repos/google/WebFundamentals/forks","keys_url":"https://api.github.com/repos/google/WebFundamentals/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/WebFundamentals/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/WebFundamentals/teams","hooks_url":"https://api.github.com/repos/google/WebFundamentals/hooks","issue_events_url":"https://api.github.com/repos/google/WebFundamentals/issues/events{/number}","events_url":"https://api.github.com/repos/google/WebFundamentals/events","assignees_url":"https://api.github.com/repos/google/WebFundamentals/assignees{/user}","branches_url":"https://api.github.com/repos/google/WebFundamentals/branches{/branch}","tags_url":"https://api.github.com/repos/google/WebFundamentals/tags","blobs_url":"https://api.github.com/repos/google/WebFundamentals/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/WebFundamentals/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/WebFundamentals/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/WebFundamentals/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/WebFundamentals/statuses/{sha}","languages_url":"https://api.github.com/repos/google/WebFundamentals/languages","stargazers_url":"https://api.github.com/repos/google/WebFundamentals/stargazers","contributors_url":"https://api.github.com/repos/google/WebFundamentals/contributors","subscribers_url":"https://api.github.com/repos/google/WebFundamentals/subscribers","subscription_url":"https://api.github.com/repos/google/WebFundamentals/subscription","commits_url":"https://api.github.com/repos/google/WebFundamentals/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/WebFundamentals/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/WebFundamentals/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/WebFundamentals/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/WebFundamentals/contents/{+path}","compare_url":"https://api.github.com/repos/google/WebFundamentals/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/WebFundamentals/merges","archive_url":"https://api.github.com/repos/google/WebFundamentals/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/WebFundamentals/downloads","issues_url":"https://api.github.com/repos/google/WebFundamentals/issues{/number}","pulls_url":"https://api.github.com/repos/google/WebFundamentals/pulls{/number}","milestones_url":"https://api.github.com/repos/google/WebFundamentals/milestones{/number}","notifications_url":"https://api.github.com/repos/google/WebFundamentals/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/WebFundamentals/labels{/name}","releases_url":"https://api.github.com/repos/google/WebFundamentals/releases{/id}","deployments_url":"https://api.github.com/repos/google/WebFundamentals/deployments","created_at":"2014-04-28T18:45:45Z","updated_at":"2016-10-07T08:06:22Z","pushed_at":"2016-10-07T13:09:48Z","git_url":"git://github.com/google/WebFundamentals.git","ssh_url":"git@github.com:google/WebFundamentals.git","clone_url":"https://github.com/google/WebFundamentals.git","svn_url":"https://github.com/google/WebFundamentals","homepage":"https://developers.google.com/web/fundamentals","size":1160520,"stargazers_count":6563,"watchers_count":6563,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1232,"mirror_url":null,"open_issues_count":120,"forks":1232,"open_issues":120,"watchers":6563,"default_branch":"master"}},"base":{"label":"google:next-version","ref":"next-version","sha":"66a4822b14a1f790bade4d0cc856eafbc5734ab4","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":19249835,"name":"WebFundamentals","full_name":"google/WebFundamentals","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/WebFundamentals","description":"Best practices for modern web development","fork":false,"url":"https://api.github.com/repos/google/WebFundamentals","forks_url":"https://api.github.com/repos/google/WebFundamentals/forks","keys_url":"https://api.github.com/repos/google/WebFundamentals/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/WebFundamentals/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/WebFundamentals/teams","hooks_url":"https://api.github.com/repos/google/WebFundamentals/hooks","issue_events_url":"https://api.github.com/repos/google/WebFundamentals/issues/events{/number}","events_url":"https://api.github.com/repos/google/WebFundamentals/events","assignees_url":"https://api.github.com/repos/google/WebFundamentals/assignees{/user}","branches_url":"https://api.github.com/repos/google/WebFundamentals/branches{/branch}","tags_url":"https://api.github.com/repos/google/WebFundamentals/tags","blobs_url":"https://api.github.com/repos/google/WebFundamentals/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/WebFundamentals/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/WebFundamentals/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/WebFundamentals/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/WebFundamentals/statuses/{sha}","languages_url":"https://api.github.com/repos/google/WebFundamentals/languages","stargazers_url":"https://api.github.com/repos/google/WebFundamentals/stargazers","contributors_url":"https://api.github.com/repos/google/WebFundamentals/contributors","subscribers_url":"https://api.github.com/repos/google/WebFundamentals/subscribers","subscription_url":"https://api.github.com/repos/google/WebFundamentals/subscription","commits_url":"https://api.github.com/repos/google/WebFundamentals/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/WebFundamentals/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/WebFundamentals/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/WebFundamentals/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/WebFundamentals/contents/{+path}","compare_url":"https://api.github.com/repos/google/WebFundamentals/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/WebFundamentals/merges","archive_url":"https://api.github.com/repos/google/WebFundamentals/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/WebFundamentals/downloads","issues_url":"https://api.github.com/repos/google/WebFundamentals/issues{/number}","pulls_url":"https://api.github.com/repos/google/WebFundamentals/pulls{/number}","milestones_url":"https://api.github.com/repos/google/WebFundamentals/milestones{/number}","notifications_url":"https://api.github.com/repos/google/WebFundamentals/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/WebFundamentals/labels{/name}","releases_url":"https://api.github.com/repos/google/WebFundamentals/releases{/id}","deployments_url":"https://api.github.com/repos/google/WebFundamentals/deployments","created_at":"2014-04-28T18:45:45Z","updated_at":"2016-10-07T08:06:22Z","pushed_at":"2016-10-07T13:09:48Z","git_url":"git://github.com/google/WebFundamentals.git","ssh_url":"git@github.com:google/WebFundamentals.git","clone_url":"https://github.com/google/WebFundamentals.git","svn_url":"https://github.com/google/WebFundamentals","homepage":"https://developers.google.com/web/fundamentals","size":1160520,"stargazers_count":6563,"watchers_count":6563,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1232,"mirror_url":null,"open_issues_count":120,"forks":1232,"open_issues":120,"watchers":6563,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/WebFundamentals/pulls/3617"},"html":{"href":"https://github.com/google/WebFundamentals/pull/3617"},"issue":{"href":"https://api.github.com/repos/google/WebFundamentals/issues/3617"},"comments":{"href":"https://api.github.com/repos/google/WebFundamentals/issues/3617/comments"},"review_comments":{"href":"https://api.github.com/repos/google/WebFundamentals/pulls/3617/comments"},"review_comment":{"href":"https://api.github.com/repos/google/WebFundamentals/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/WebFundamentals/pulls/3617/commits"},"statuses":{"href":"https://api.github.com/repos/google/WebFundamentals/statuses/4a8d6f7f0afd855db6258956a57197cfe9b727f0"}}}}
{"actor":{"display_login":"ithinkihaveacat"}}