{"action":"created","comment":{"url":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/comments/134877766","pull_request_review_id":58221043,"id":134877766,"diff_hunk":"@@ -0,0 +1,124 @@\n+/**\n+ * Copyright 2017 Google Inc. All rights reserved.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+const esprima = require('esprima');\n+const ESTreeWalker = require('../ESTreeWalker');\n+\n+// This is converted from Babel's \"transform-async-to-generator\"\n+// https://babeljs.io/docs/plugins/transform-async-to-generator/\n+const asyncToGenerator = fn => {\n+  const gen = fn.call(this);\n+  return new Promise((resolve, reject) => {\n+    function step(key, arg) {\n+      let info, value;\n+      try {\n+        info = gen[key](arg);\n+        value = info.value;\n+      } catch (error) {\n+        reject(error);\n+        return;\n+      }\n+      if (info.done) {\n+        resolve(value);\n+      } else {\n+        return Promise.resolve(value).then(\n+            value => {\n+              step('next', value);\n+            },\n+            err => {\n+              step('throw', err);\n+            });\n+      }\n+    }\n+    return step('next');\n+  });\n+};\n+\n+/**\n+ * @param {string} text\n+ */\n+function transformAsyncFunctions(text) {\n+  const edits = [];\n+\n+  const ast = esprima.parseScript(text, {loc: true, range: true});\n+  const walker = new ESTreeWalker(node => {\n+    if (node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration' || node.type === 'ArrowFunctionExpression')\n+      onFunction(node);\n+    if (node.type === 'AwaitExpression')\n+      onAwait(node);\n+  });\n+  walker.walk(ast);\n+\n+  edits.sort((a, b) => b.from - a.from);\n+  for (const {replacement, from, to} of edits)\n+    text = text.substring(0, from) + replacement + text.substring(to);\n+\n+  return text;\n+\n+  /**\n+   * @param {ESTree.Node} node\n+   */\n+  function onFunction(node) {\n+    if (!node.async) return;\n+\n+    let range;\n+    if (node.parent.type === 'MethodDefinition')\n+      range = node.parent.range;\n+    else\n+      range = node.range;\n+    const index = textInRange(range[0], range[1]).indexOf('async') + range[0];\n+    insertText(index, index + 'async'.length, '/* async */');\n+\n+    let before = `{return (${asyncToGenerator.toString()})(function*()`;\n+    let after = `);}`;\n+    if (node.body.type !== 'BlockStatement') {\n+      before += `{ return `;\n+      after = `; }` + after;\n+    }\n+    insertText(node.body.range[0], node.body.range[0], before);\n+    insertText(node.body.range[1], node.body.range[1], after);\n+  }\n+\n+  /**\n+   * @param {ESTree.Node} node\n+   */\n+  function onAwait(node) {\n+    const text = textInRange(node.range[0], node.range[1]);\n+    const index = text.indexOf('await') + node.range[0];\n+    insertText(index, index + 'await'.length, '(yield');\n+    insertText(node.range[1], node.range[1], ')');\n+  }\n+\n+  /**\n+   * @param {number} from\n+   * @param {number} to\n+   * @param {string} replacement\n+   */\n+  function insertText(from, to, replacement) {\n+    edits.push({from, to, replacement});\n+  }\n+\n+  /**\n+   * @param {number} from\n+   * @param {number} to\n+   * @return {string}\n+   */\n+  function textInRange(from, to) {","path":"utils/node6-transform/TransformAsyncFunctions.js","position":119,"original_position":119,"commit_id":"0220307ae50d042621ba4a26cafca11f84574b09","original_commit_id":"0220307ae50d042621ba4a26cafca11f84574b09","user":{"login":"aslushnikov","id":746130,"avatar_url":"https://avatars3.githubusercontent.com/u/746130?v=4","gravatar_id":"","url":"https://api.github.com/users/aslushnikov","html_url":"https://github.com/aslushnikov","followers_url":"https://api.github.com/users/aslushnikov/followers","following_url":"https://api.github.com/users/aslushnikov/following{/other_user}","gists_url":"https://api.github.com/users/aslushnikov/gists{/gist_id}","starred_url":"https://api.github.com/users/aslushnikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aslushnikov/subscriptions","organizations_url":"https://api.github.com/users/aslushnikov/orgs","repos_url":"https://api.github.com/users/aslushnikov/repos","events_url":"https://api.github.com/users/aslushnikov/events{/privacy}","received_events_url":"https://api.github.com/users/aslushnikov/received_events","type":"User","site_admin":false},"body":"inline?","created_at":"2017-08-23T21:37:29Z","updated_at":"2017-08-23T21:49:09Z","html_url":"https://github.com/GoogleChrome/puppeteer/pull/484#discussion_r134877766","pull_request_url":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/484","_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/comments/134877766"},"html":{"href":"https://github.com/GoogleChrome/puppeteer/pull/484#discussion_r134877766"},"pull_request":{"href":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/484"}}},"pull_request":{"url":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/484","id":137110603,"html_url":"https://github.com/GoogleChrome/puppeteer/pull/484","diff_url":"https://github.com/GoogleChrome/puppeteer/pull/484.diff","patch_url":"https://github.com/GoogleChrome/puppeteer/pull/484.patch","issue_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/484","number":484,"state":"open","locked":false,"title":"Node 6 support","user":{"login":"JoelEinbinder","id":4624233,"avatar_url":"https://avatars1.githubusercontent.com/u/4624233?v=4","gravatar_id":"","url":"https://api.github.com/users/JoelEinbinder","html_url":"https://github.com/JoelEinbinder","followers_url":"https://api.github.com/users/JoelEinbinder/followers","following_url":"https://api.github.com/users/JoelEinbinder/following{/other_user}","gists_url":"https://api.github.com/users/JoelEinbinder/gists{/gist_id}","starred_url":"https://api.github.com/users/JoelEinbinder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoelEinbinder/subscriptions","organizations_url":"https://api.github.com/users/JoelEinbinder/orgs","repos_url":"https://api.github.com/users/JoelEinbinder/repos","events_url":"https://api.github.com/users/JoelEinbinder/events{/privacy}","received_events_url":"https://api.github.com/users/JoelEinbinder/received_events","type":"User","site_admin":false},"body":"I have to look this over again with fresh eyes.","created_at":"2017-08-23T01:03:55Z","updated_at":"2017-08-23T21:49:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"637f121c68bed3cdc45fdf94e213cb7ea5e96151","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/484/commits","review_comments_url":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/484/comments","review_comment_url":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/484/comments","statuses_url":"https://api.github.com/repos/GoogleChrome/puppeteer/statuses/0220307ae50d042621ba4a26cafca11f84574b09","head":{"label":"JoelEinbinder:node6","ref":"node6","sha":"0220307ae50d042621ba4a26cafca11f84574b09","user":{"login":"JoelEinbinder","id":4624233,"avatar_url":"https://avatars1.githubusercontent.com/u/4624233?v=4","gravatar_id":"","url":"https://api.github.com/users/JoelEinbinder","html_url":"https://github.com/JoelEinbinder","followers_url":"https://api.github.com/users/JoelEinbinder/followers","following_url":"https://api.github.com/users/JoelEinbinder/following{/other_user}","gists_url":"https://api.github.com/users/JoelEinbinder/gists{/gist_id}","starred_url":"https://api.github.com/users/JoelEinbinder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoelEinbinder/subscriptions","organizations_url":"https://api.github.com/users/JoelEinbinder/orgs","repos_url":"https://api.github.com/users/JoelEinbinder/repos","events_url":"https://api.github.com/users/JoelEinbinder/events{/privacy}","received_events_url":"https://api.github.com/users/JoelEinbinder/received_events","type":"User","site_admin":false},"repo":{"id":100542550,"name":"puppeteer","full_name":"JoelEinbinder/puppeteer","owner":{"login":"JoelEinbinder","id":4624233,"avatar_url":"https://avatars1.githubusercontent.com/u/4624233?v=4","gravatar_id":"","url":"https://api.github.com/users/JoelEinbinder","html_url":"https://github.com/JoelEinbinder","followers_url":"https://api.github.com/users/JoelEinbinder/followers","following_url":"https://api.github.com/users/JoelEinbinder/following{/other_user}","gists_url":"https://api.github.com/users/JoelEinbinder/gists{/gist_id}","starred_url":"https://api.github.com/users/JoelEinbinder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoelEinbinder/subscriptions","organizations_url":"https://api.github.com/users/JoelEinbinder/orgs","repos_url":"https://api.github.com/users/JoelEinbinder/repos","events_url":"https://api.github.com/users/JoelEinbinder/events{/privacy}","received_events_url":"https://api.github.com/users/JoelEinbinder/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JoelEinbinder/puppeteer","description":"Headless Chrome Node API","fork":true,"url":"https://api.github.com/repos/JoelEinbinder/puppeteer","forks_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/forks","keys_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/teams","hooks_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/hooks","issue_events_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/issues/events{/number}","events_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/events","assignees_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/assignees{/user}","branches_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/branches{/branch}","tags_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/tags","blobs_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/git/refs{/sha}","trees_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/statuses/{sha}","languages_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/languages","stargazers_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/stargazers","contributors_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/contributors","subscribers_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/subscribers","subscription_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/subscription","commits_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/commits{/sha}","git_commits_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/git/commits{/sha}","comments_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/comments{/number}","issue_comment_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/issues/comments{/number}","contents_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/contents/{+path}","compare_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/merges","archive_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/downloads","issues_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/issues{/number}","pulls_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/pulls{/number}","milestones_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/milestones{/number}","notifications_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/labels{/name}","releases_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/releases{/id}","deployments_url":"https://api.github.com/repos/JoelEinbinder/puppeteer/deployments","created_at":"2017-08-16T23:54:35Z","updated_at":"2017-08-16T23:54:37Z","pushed_at":"2017-08-23T21:13:58Z","git_url":"git://github.com/JoelEinbinder/puppeteer.git","ssh_url":"git@github.com:JoelEinbinder/puppeteer.git","clone_url":"https://github.com/JoelEinbinder/puppeteer.git","svn_url":"https://github.com/JoelEinbinder/puppeteer","homepage":null,"size":1555,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"GoogleChrome:master","ref":"master","sha":"a526e9f9fbfaa1253ef2a44ba0c891a4cc53835b","user":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars3.githubusercontent.com/u/1778935?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"repo":{"id":90796663,"name":"puppeteer","full_name":"GoogleChrome/puppeteer","owner":{"login":"GoogleChrome","id":1778935,"avatar_url":"https://avatars3.githubusercontent.com/u/1778935?v=4","gravatar_id":"","url":"https://api.github.com/users/GoogleChrome","html_url":"https://github.com/GoogleChrome","followers_url":"https://api.github.com/users/GoogleChrome/followers","following_url":"https://api.github.com/users/GoogleChrome/following{/other_user}","gists_url":"https://api.github.com/users/GoogleChrome/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleChrome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleChrome/subscriptions","organizations_url":"https://api.github.com/users/GoogleChrome/orgs","repos_url":"https://api.github.com/users/GoogleChrome/repos","events_url":"https://api.github.com/users/GoogleChrome/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleChrome/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/GoogleChrome/puppeteer","description":"Headless Chrome Node API","fork":false,"url":"https://api.github.com/repos/GoogleChrome/puppeteer","forks_url":"https://api.github.com/repos/GoogleChrome/puppeteer/forks","keys_url":"https://api.github.com/repos/GoogleChrome/puppeteer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/GoogleChrome/puppeteer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/GoogleChrome/puppeteer/teams","hooks_url":"https://api.github.com/repos/GoogleChrome/puppeteer/hooks","issue_events_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/events{/number}","events_url":"https://api.github.com/repos/GoogleChrome/puppeteer/events","assignees_url":"https://api.github.com/repos/GoogleChrome/puppeteer/assignees{/user}","branches_url":"https://api.github.com/repos/GoogleChrome/puppeteer/branches{/branch}","tags_url":"https://api.github.com/repos/GoogleChrome/puppeteer/tags","blobs_url":"https://api.github.com/repos/GoogleChrome/puppeteer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/GoogleChrome/puppeteer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/GoogleChrome/puppeteer/git/refs{/sha}","trees_url":"https://api.github.com/repos/GoogleChrome/puppeteer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/GoogleChrome/puppeteer/statuses/{sha}","languages_url":"https://api.github.com/repos/GoogleChrome/puppeteer/languages","stargazers_url":"https://api.github.com/repos/GoogleChrome/puppeteer/stargazers","contributors_url":"https://api.github.com/repos/GoogleChrome/puppeteer/contributors","subscribers_url":"https://api.github.com/repos/GoogleChrome/puppeteer/subscribers","subscription_url":"https://api.github.com/repos/GoogleChrome/puppeteer/subscription","commits_url":"https://api.github.com/repos/GoogleChrome/puppeteer/commits{/sha}","git_commits_url":"https://api.github.com/repos/GoogleChrome/puppeteer/git/commits{/sha}","comments_url":"https://api.github.com/repos/GoogleChrome/puppeteer/comments{/number}","issue_comment_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/comments{/number}","contents_url":"https://api.github.com/repos/GoogleChrome/puppeteer/contents/{+path}","compare_url":"https://api.github.com/repos/GoogleChrome/puppeteer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/GoogleChrome/puppeteer/merges","archive_url":"https://api.github.com/repos/GoogleChrome/puppeteer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/GoogleChrome/puppeteer/downloads","issues_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues{/number}","pulls_url":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls{/number}","milestones_url":"https://api.github.com/repos/GoogleChrome/puppeteer/milestones{/number}","notifications_url":"https://api.github.com/repos/GoogleChrome/puppeteer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/GoogleChrome/puppeteer/labels{/name}","releases_url":"https://api.github.com/repos/GoogleChrome/puppeteer/releases{/id}","deployments_url":"https://api.github.com/repos/GoogleChrome/puppeteer/deployments","created_at":"2017-05-09T22:16:13Z","updated_at":"2017-08-23T21:31:02Z","pushed_at":"2017-08-23T21:29:48Z","git_url":"git://github.com/GoogleChrome/puppeteer.git","ssh_url":"git@github.com:GoogleChrome/puppeteer.git","clone_url":"https://github.com/GoogleChrome/puppeteer.git","svn_url":"https://github.com/GoogleChrome/puppeteer","homepage":null,"size":1563,"stargazers_count":10402,"watchers_count":10402,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":237,"mirror_url":null,"open_issues_count":69,"forks":237,"open_issues":69,"watchers":10402,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/484"},"html":{"href":"https://github.com/GoogleChrome/puppeteer/pull/484"},"issue":{"href":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/484"},"comments":{"href":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/484/comments"},"review_comments":{"href":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/484/comments"},"review_comment":{"href":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/GoogleChrome/puppeteer/pulls/484/commits"},"statuses":{"href":"https://api.github.com/repos/GoogleChrome/puppeteer/statuses/0220307ae50d042621ba4a26cafca11f84574b09"}}}}
{"actor":{"display_login":"aslushnikov"}}