{"action":"created","comment":{"url":"https://api.github.com/repos/angular/ts2dart/pulls/comments/52329692","id":52329692,"diff_hunk":"@@ -354,6 +396,48 @@ export class FacadeConverter extends base.TranspilerBase {\n     },\n   };\n \n+  private es6Promises: ts.Map<CallHandler> = {\n+    'Promise.resolve': (c: ts.CallExpression, context: ts.Expression) => {\n+      this.emit('Future.value(');\n+      this.visitList(c.arguments);  // Should only be 1.\n+      this.emit(')');\n+    },\n+    'Promise.reject': (c: ts.CallExpression, context: ts.Expression) => {\n+      this.emit('Future.error(');\n+      this.visitList(c.arguments);  // Should only be 1.\n+      this.emit(')');\n+    },\n+    'Promise': (c: ts.CallExpression, context: ts.Expression) => {\n+      if (c.kind != ts.SyntaxKind.NewExpression) {\n+        return true;\n+      }\n+      this.assert(c.arguments.length == 1);\n+      const callback = <ts.ArrowFunction>(c.arguments[0]);\n+      this.assert(\n+          callback.kind == ts.SyntaxKind.ArrowFunction ||\n+          callback.kind == ts.SyntaxKind.FunctionDeclaration ||\n+          callback.kind == ts.SyntaxKind.FunctionExpression);\n+      this.assert(callback.parameters.length > 0 && callback.parameters.length < 3);\n+\n+      this.emit('(() {');  // Create a new scope.\n+      this.emit('Completer _completer = new Completer();');","path":"lib/facade_converter.ts","position":77,"original_position":77,"commit_id":"dfa2a528991cb43f29b73affe35d7ecb1be79722","original_commit_id":"dfa2a528991cb43f29b73affe35d7ecb1be79722","user":{"login":"hansl","id":681969,"avatar_url":"https://avatars.githubusercontent.com/u/681969?v=3","gravatar_id":"","url":"https://api.github.com/users/hansl","html_url":"https://github.com/hansl","followers_url":"https://api.github.com/users/hansl/followers","following_url":"https://api.github.com/users/hansl/following{/other_user}","gists_url":"https://api.github.com/users/hansl/gists{/gist_id}","starred_url":"https://api.github.com/users/hansl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansl/subscriptions","organizations_url":"https://api.github.com/users/hansl/orgs","repos_url":"https://api.github.com/users/hansl/repos","events_url":"https://api.github.com/users/hansl/events{/privacy}","received_events_url":"https://api.github.com/users/hansl/received_events","type":"User","site_admin":false},"body":"I agree with you, but the problem is deciding where that code live. I don't mind a PromiseWrapper but we shouldn't include it anywhere. @alexeagle @mprobst What's your opinion on this? Should I create a library that's included in the pub dependencies (a kind of `ts2dart/stdlib`) or should I add a helper function in this file scope?","created_at":"2016-02-09T16:12:00Z","updated_at":"2016-02-09T16:12:00Z","html_url":"https://github.com/angular/ts2dart/pull/340#discussion_r52329692","pull_request_url":"https://api.github.com/repos/angular/ts2dart/pulls/340","_links":{"self":{"href":"https://api.github.com/repos/angular/ts2dart/pulls/comments/52329692"},"html":{"href":"https://github.com/angular/ts2dart/pull/340#discussion_r52329692"},"pull_request":{"href":"https://api.github.com/repos/angular/ts2dart/pulls/340"}}},"pull_request":{"url":"https://api.github.com/repos/angular/ts2dart/pulls/340","id":58709993,"html_url":"https://github.com/angular/ts2dart/pull/340","diff_url":"https://github.com/angular/ts2dart/pull/340.diff","patch_url":"https://github.com/angular/ts2dart/pull/340.patch","issue_url":"https://api.github.com/repos/angular/ts2dart/issues/340","number":340,"state":"open","locked":false,"title":"Implement an inlined facade for Promises","user":{"login":"hansl","id":681969,"avatar_url":"https://avatars.githubusercontent.com/u/681969?v=3","gravatar_id":"","url":"https://api.github.com/users/hansl","html_url":"https://github.com/hansl","followers_url":"https://api.github.com/users/hansl/followers","following_url":"https://api.github.com/users/hansl/following{/other_user}","gists_url":"https://api.github.com/users/hansl/gists{/gist_id}","starred_url":"https://api.github.com/users/hansl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansl/subscriptions","organizations_url":"https://api.github.com/users/hansl/orgs","repos_url":"https://api.github.com/users/hansl/repos","events_url":"https://api.github.com/users/hansl/events{/privacy}","received_events_url":"https://api.github.com/users/hansl/received_events","type":"User","site_admin":false},"body":"After this we don't need a Promise facade, unless for `all`, `catch` and `race`. I need a handler for `then(a, b)` => `then(a).catch(b)`.","created_at":"2016-02-09T06:30:54Z","updated_at":"2016-02-09T16:12:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fd4a747fa21f03e2c6f03879c7c388c41df34ece","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/angular/ts2dart/pulls/340/commits","review_comments_url":"https://api.github.com/repos/angular/ts2dart/pulls/340/comments","review_comment_url":"https://api.github.com/repos/angular/ts2dart/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/ts2dart/issues/340/comments","statuses_url":"https://api.github.com/repos/angular/ts2dart/statuses/dfa2a528991cb43f29b73affe35d7ecb1be79722","head":{"label":"hansl:promises","ref":"promises","sha":"dfa2a528991cb43f29b73affe35d7ecb1be79722","user":{"login":"hansl","id":681969,"avatar_url":"https://avatars.githubusercontent.com/u/681969?v=3","gravatar_id":"","url":"https://api.github.com/users/hansl","html_url":"https://github.com/hansl","followers_url":"https://api.github.com/users/hansl/followers","following_url":"https://api.github.com/users/hansl/following{/other_user}","gists_url":"https://api.github.com/users/hansl/gists{/gist_id}","starred_url":"https://api.github.com/users/hansl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansl/subscriptions","organizations_url":"https://api.github.com/users/hansl/orgs","repos_url":"https://api.github.com/users/hansl/repos","events_url":"https://api.github.com/users/hansl/events{/privacy}","received_events_url":"https://api.github.com/users/hansl/received_events","type":"User","site_admin":false},"repo":{"id":50791751,"name":"ts2dart","full_name":"hansl/ts2dart","owner":{"login":"hansl","id":681969,"avatar_url":"https://avatars.githubusercontent.com/u/681969?v=3","gravatar_id":"","url":"https://api.github.com/users/hansl","html_url":"https://github.com/hansl","followers_url":"https://api.github.com/users/hansl/followers","following_url":"https://api.github.com/users/hansl/following{/other_user}","gists_url":"https://api.github.com/users/hansl/gists{/gist_id}","starred_url":"https://api.github.com/users/hansl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansl/subscriptions","organizations_url":"https://api.github.com/users/hansl/orgs","repos_url":"https://api.github.com/users/hansl/repos","events_url":"https://api.github.com/users/hansl/events{/privacy}","received_events_url":"https://api.github.com/users/hansl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hansl/ts2dart","description":"ts2dart TypeScript to Dart transpiler","fork":true,"url":"https://api.github.com/repos/hansl/ts2dart","forks_url":"https://api.github.com/repos/hansl/ts2dart/forks","keys_url":"https://api.github.com/repos/hansl/ts2dart/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hansl/ts2dart/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hansl/ts2dart/teams","hooks_url":"https://api.github.com/repos/hansl/ts2dart/hooks","issue_events_url":"https://api.github.com/repos/hansl/ts2dart/issues/events{/number}","events_url":"https://api.github.com/repos/hansl/ts2dart/events","assignees_url":"https://api.github.com/repos/hansl/ts2dart/assignees{/user}","branches_url":"https://api.github.com/repos/hansl/ts2dart/branches{/branch}","tags_url":"https://api.github.com/repos/hansl/ts2dart/tags","blobs_url":"https://api.github.com/repos/hansl/ts2dart/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hansl/ts2dart/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hansl/ts2dart/git/refs{/sha}","trees_url":"https://api.github.com/repos/hansl/ts2dart/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hansl/ts2dart/statuses/{sha}","languages_url":"https://api.github.com/repos/hansl/ts2dart/languages","stargazers_url":"https://api.github.com/repos/hansl/ts2dart/stargazers","contributors_url":"https://api.github.com/repos/hansl/ts2dart/contributors","subscribers_url":"https://api.github.com/repos/hansl/ts2dart/subscribers","subscription_url":"https://api.github.com/repos/hansl/ts2dart/subscription","commits_url":"https://api.github.com/repos/hansl/ts2dart/commits{/sha}","git_commits_url":"https://api.github.com/repos/hansl/ts2dart/git/commits{/sha}","comments_url":"https://api.github.com/repos/hansl/ts2dart/comments{/number}","issue_comment_url":"https://api.github.com/repos/hansl/ts2dart/issues/comments{/number}","contents_url":"https://api.github.com/repos/hansl/ts2dart/contents/{+path}","compare_url":"https://api.github.com/repos/hansl/ts2dart/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hansl/ts2dart/merges","archive_url":"https://api.github.com/repos/hansl/ts2dart/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hansl/ts2dart/downloads","issues_url":"https://api.github.com/repos/hansl/ts2dart/issues{/number}","pulls_url":"https://api.github.com/repos/hansl/ts2dart/pulls{/number}","milestones_url":"https://api.github.com/repos/hansl/ts2dart/milestones{/number}","notifications_url":"https://api.github.com/repos/hansl/ts2dart/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hansl/ts2dart/labels{/name}","releases_url":"https://api.github.com/repos/hansl/ts2dart/releases{/id}","deployments_url":"https://api.github.com/repos/hansl/ts2dart/deployments","created_at":"2016-01-31T19:44:58Z","updated_at":"2016-01-31T19:44:58Z","pushed_at":"2016-02-09T06:31:25Z","git_url":"git://github.com/hansl/ts2dart.git","ssh_url":"git@github.com:hansl/ts2dart.git","clone_url":"https://github.com/hansl/ts2dart.git","svn_url":"https://github.com/hansl/ts2dart","homepage":"","size":546,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"angular:master","ref":"master","sha":"d9bdd4204cb870cfed61fdacf9a6609826fc7843","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":32405591,"name":"ts2dart","full_name":"angular/ts2dart","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/ts2dart","description":"ts2dart TypeScript to Dart transpiler","fork":false,"url":"https://api.github.com/repos/angular/ts2dart","forks_url":"https://api.github.com/repos/angular/ts2dart/forks","keys_url":"https://api.github.com/repos/angular/ts2dart/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/ts2dart/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/ts2dart/teams","hooks_url":"https://api.github.com/repos/angular/ts2dart/hooks","issue_events_url":"https://api.github.com/repos/angular/ts2dart/issues/events{/number}","events_url":"https://api.github.com/repos/angular/ts2dart/events","assignees_url":"https://api.github.com/repos/angular/ts2dart/assignees{/user}","branches_url":"https://api.github.com/repos/angular/ts2dart/branches{/branch}","tags_url":"https://api.github.com/repos/angular/ts2dart/tags","blobs_url":"https://api.github.com/repos/angular/ts2dart/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/ts2dart/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/ts2dart/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/ts2dart/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/ts2dart/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/ts2dart/languages","stargazers_url":"https://api.github.com/repos/angular/ts2dart/stargazers","contributors_url":"https://api.github.com/repos/angular/ts2dart/contributors","subscribers_url":"https://api.github.com/repos/angular/ts2dart/subscribers","subscription_url":"https://api.github.com/repos/angular/ts2dart/subscription","commits_url":"https://api.github.com/repos/angular/ts2dart/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/ts2dart/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/ts2dart/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/ts2dart/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/ts2dart/contents/{+path}","compare_url":"https://api.github.com/repos/angular/ts2dart/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/ts2dart/merges","archive_url":"https://api.github.com/repos/angular/ts2dart/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/ts2dart/downloads","issues_url":"https://api.github.com/repos/angular/ts2dart/issues{/number}","pulls_url":"https://api.github.com/repos/angular/ts2dart/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/ts2dart/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/ts2dart/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/ts2dart/labels{/name}","releases_url":"https://api.github.com/repos/angular/ts2dart/releases{/id}","deployments_url":"https://api.github.com/repos/angular/ts2dart/deployments","created_at":"2015-03-17T16:28:22Z","updated_at":"2016-01-21T16:46:46Z","pushed_at":"2016-02-09T06:31:25Z","git_url":"git://github.com/angular/ts2dart.git","ssh_url":"git@github.com:angular/ts2dart.git","clone_url":"https://github.com/angular/ts2dart.git","svn_url":"https://github.com/angular/ts2dart","homepage":"","size":633,"stargazers_count":40,"watchers_count":40,"language":"TypeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":38,"forks":24,"open_issues":38,"watchers":40,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/ts2dart/pulls/340"},"html":{"href":"https://github.com/angular/ts2dart/pull/340"},"issue":{"href":"https://api.github.com/repos/angular/ts2dart/issues/340"},"comments":{"href":"https://api.github.com/repos/angular/ts2dart/issues/340/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/ts2dart/pulls/340/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/ts2dart/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/ts2dart/pulls/340/commits"},"statuses":{"href":"https://api.github.com/repos/angular/ts2dart/statuses/dfa2a528991cb43f29b73affe35d7ecb1be79722"}}}}